diff --git a/assets/theme-css/styles.css b/assets/theme-css/styles.css
index 8c5f562c..9b92e633 100644
--- a/assets/theme-css/styles.css
+++ b/assets/theme-css/styles.css
@@ -168,7 +168,7 @@ a.headerlink {
visibility: hidden;
}
-:is(h1, h2, h3, h4, h5, h6):hover > a.headerlink {
+:is(h1, h2, h3, h4, h5, h6, caption):hover > a.headerlink {
visibility: visible;
}
diff --git a/layouts/shortcodes/figure.html b/layouts/shortcodes/figure.html
index f071ce07..13e6dd89 100644
--- a/layouts/shortcodes/figure.html
+++ b/layouts/shortcodes/figure.html
@@ -14,7 +14,30 @@
A figure is an image with a caption. Figures may also include a tile, legend, and/or attribution.
'''
legend = '''
-**TODO: use tomltotable (https://github.com/scientific-python/scientific-python-hugo-theme/pull/548)**
+{{< tomlToTable >}}
+
+[[row]]
+column = [
+ "Project",
+ "Available Packages",
+ "Download location"
+]
+
+[[row]]
+column = [
+ "NumPy",
+ "Official *source code* (all platforms) and *binaries* for
\n**Windows**, **Linux**, and **Mac OS X**\n",
+ "[PyPi page for NumPy](https://pypi.python.org/pypi/numpy)"
+]
+
+[[row]]
+column = [
+ "SciPy",
+ "Official *source code* (all platforms) and *binaries* for
\n**Windows**, **Linux** and **Mac OS X**\n",
+ "[SciPy release page](https://github.com/scipy/scipy/releases) (sources)
\n[PyPI page for SciPy](https://pypi.python.org/pypi/scipy) (all)\n"
+]
+
+{{< /tomlToTable >}}
This paragraph is also part of the legend.
'''
@@ -59,7 +82,9 @@
{{- with $figure.legend }}
-{{ . | markdownify -}}
+{{- with (trim . "\n") }}
+ {{ . | safeHTML }}
+{{- end }}
{{- end }}
diff --git a/layouts/shortcodes/tomlToTable.html b/layouts/shortcodes/tomlToTable.html
new file mode 100644
index 00000000..bbe06808
--- /dev/null
+++ b/layouts/shortcodes/tomlToTable.html
@@ -0,0 +1,91 @@
+{{/*
+
+doc: Render TOML to an HTML table.
+
+{{< tomlToTable >}}
+
+caption = 'Table caption'
+align = ["left", "left", "right"]
+width = "80%"
+widths = ["10%", "50%", "20%"]
+headerrows = 1
+footer-rows = 3
+stubcolumns = 1
+
+[[row]]
+column = [
+ "Project",
+ "Available Packages",
+ "Download location"
+]
+
+[[row]]
+column = [
+ "NumPy",
+ "Official *source code* (all platforms) and *binaries* for
\n**Windows**, **Linux**, and **Mac OS X**\n",
+ "[PyPi page for NumPy](https://pypi.python.org/pypi/numpy)"
+]
+
+[[row]]
+column = [
+ "SciPy",
+ "Official *source code* (all platforms) and *binaries* for
\n**Windows**, **Linux** and **Mac OS X**\n",
+ "[SciPy release page](https://github.com/scipy/scipy/releases) (sources)
\n[PyPI page for SciPy](https://pypi.python.org/pypi/scipy) (all)\n"
+]
+
+{{< /tomlToTable >}}
+
+*/}}
+
+{{- $data := .Inner | transform.Unmarshal }}
+{{- $id := printf "id%03d" $.Ordinal -}}
+{{- $align := $data.align }}
+{{- $numrows := $data.row | len }}
+{{- $headerrows := or $data.headerrows 0 }}
+{{- $header := first $headerrows $data.row }}
+{{- $body := last (math.Sub $numrows $headerrows) $data.row }}
+
+
+ {{- with $data.caption }}
+ {{ . }}
+ {{- end }}
+ {{- with $data.widths }}
+
+ {{- range . }}
+
+ {{- end }}
+
+ {{ end }}
+ {{- if $header }}
+ {{- range $row_idx, $row := $header }}
+ {{ if (modBool $row_idx 2) }}{{- else }}
{{- end }}
+ {{- range $col_idx, $col := $row.column }}
+ {{- $alignment := or (index $align $col_idx) "left" }}
+ {{- $isStub := compare.Lt $col_idx $data.stubcolumns }}
+ {{- $class := cond $isStub "head stub" "head" }}
+
+ {{ $col | markdownify }}
+ |
+ {{- end }}
+
+ {{- end }}
+
+ {{- end }}
+
+ {{- range $row_idx, $row := $body }}
+ {{ if (modBool (add $row_idx $headerrows) 2) }}{{- else }}
{{- end }}
+ {{- range $col_idx, $col := $row.column }}
+ {{- $alignment := or (index $align $col_idx) "left" }}
+ {{- $isStub := compare.Lt $col_idx $data.stubcolumns }}
+ {{- if $isStub }}
+
+ {{- else }}
+ |
+ {{- end }}
+ {{ $col | markdownify }}
+ {{ cond $isStub "" " | " | safeHTML }}
+ {{- end }}
+
+ {{- end }}
+
+