Skip to content

Commit 0667998

Browse files
committed
Add legend to figure using tomlToTable
1 parent 80008b3 commit 0667998

File tree

2 files changed

+41
-6
lines changed

2 files changed

+41
-6
lines changed

layouts/shortcodes/figure.html

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,36 @@
99
width = 200
1010
caption = 'A figure is an image with a caption and/or a legend:'
1111
legend = '''
12-
**TODO: need to convert yamltotable to tomltotable**
12+
{{< tomlToTable >}}
13+
14+
[[row]]
15+
type = 'header'
16+
17+
[[row.column]]
18+
body = 'Project'
19+
20+
[[row.column]]
21+
body = 'Available Packages'
22+
23+
[[row]]
24+
25+
[[row.column]]
26+
body = 'NumPy'
27+
28+
[[row.column]]
29+
body = '''Official *source code* (all platforms) and *binaries* for<br />
30+
**Windows**, **Linux**, and **Mac OS X**'''
31+
32+
[[row]]
33+
34+
[[row.column]]
35+
body = 'SciPy'
36+
37+
[[row.column]]
38+
body = '''Official *source code* (all platforms) and *binaries* for<br />
39+
**Windows**, **Linux**, and **Mac OS X**'''
40+
41+
{{< /tomlToTable >}}
1342

1443
This paragraph is also part of the legend.
1544
'''
@@ -46,7 +75,9 @@
4675
</span><a class="headerlink" href="#{{ $id }}" title="Link to this image">#</a></p>
4776
{{- with $figure.legend }}
4877
<div class="legend">
49-
{{ . | markdownify -}}
78+
{{- with (trim . "\n") }}
79+
{{ . | safeHTML }}
80+
{{- end }}
5081
</div>
5182
{{- end }}
5283
</figcaption>

layouts/shortcodes/tomlToTable.html

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,16 @@
5050
{{ $data := .Inner | transform.Unmarshal }}
5151

5252
{{ with $data }}
53-
<table>
54-
{{ range $row := .row }}
55-
<tr>
53+
<table class="table">
54+
{{ range $i, $row := .row }}
55+
{{if (modBool $i 2)}}
56+
<tr class="row-odd">
57+
{{else}}
58+
<tr class="row-even">
59+
{{end}}
5660
{{ $el := "td" }}
5761
{{ if (eq $row.type "header") }}
58-
{{ $el = "th" }}
62+
{{ $el = "th class='head'" }}
5963
{{ end }}
6064
{{ range $col := .column }}
6165
{{ printf "<%s" $el | safeHTML }} colspan="{{ $col.colspan }}" rowspan="{{ $col.rowspan }}" {{ printf ">" | safeHTML }}

0 commit comments

Comments
 (0)