forked from scientific-python/scientific-python-hugo-theme
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfigure.html
More file actions
102 lines (84 loc) · 4.44 KB
/
figure.html
File metadata and controls
102 lines (84 loc) · 4.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
{{/*
doc: Figures
{{< figure >}}
src = "https://images.unsplash.com/photo-1546238232-20216dec9f72"
alt = "Cute puppies"
height = 200
width = 200
title = "Figure title"
attribution = "Figure Credits: Cute puppies image from unsplash.com"
attributionlink = "https://images.unsplash.com/photo-1546238232-20216dec9f72"
caption = '''
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)**
This paragraph is also part of the legend.
'''
{{< /figure >}}
{{< figure >}}
src = "https://images.unsplash.com/photo-1546238232-20216dec9f72"
alt = "Cute puppies"
attribution = "Figure Credits: Cute puppies image from unsplash.com"
attributionlink = "https://images.unsplash.com/photo-1546238232-20216dec9f72"
align = "left"
height = 150
width = 150
caption = '''
A figure with left alignment.
'''
{{< /figure >}}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
This shortcode can also be used with named parameters. The following example shows how to do so:
{{< figure
src = "https://images.unsplash.com/photo-1546238232-20216dec9f72"
alt = "Cute puppies"
attribution = "Figure Credits: Cute puppies image from unsplash.com"
attributionlink = "https://images.unsplash.com/photo-1546238232-20216dec9f72"
align = "right"
height = 150
width = 150
caption = "A figure with right alignment."
>}}
{{< /figure >}}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
*/}}
{{- $useParams := true -}}
{{- $figure := dict -}}
{{- if strings.TrimSpace .Inner -}}
{{- if not .IsNamedParams -}}
{{- $useParams = false -}}
{{- $figure = .Inner | transform.Unmarshal -}}
{{- end -}}
{{- end -}}
{{/* If we're using params, collect them. */}}
{{- if $useParams -}}
{{- range $key, $value := .Params -}}
{{- $figure = merge $figure (dict $key $value) -}}
{{- end -}}
{{- end -}}
{{- $align := default "default" $figure.align -}}
{{- $id := printf "id%03d" $.Ordinal -}}
<figure class="align-{{ $align }}" id="{{ $id }}">
{{/* Create a clean copy of figure data with align center for image */}}
{{- $image := merge $figure (dict "align" "center") -}}
{{ partial "_elements/image.html" (dict "data" $image) }}
<figcaption>
{{- with $figure.title -}}
<strong class="caption-title">{{ . }}</strong><a class="headerlink" href="#{{ $id }}" title="Link to this image">#</a><br>
{{- end }}
{{- if $figure.attribution -}}
{{- with $figure.attributionlink -}}<a href="{{ . }}">{{- end -}}{{- $figure.attribution -}}{{- if $figure.attributionlink -}}</a>{{- end -}}
{{- end }}
<p><span class="caption-text">
{{- $figure.caption | markdownify -}}
</span>
{{- with $figure.legend }}
<div class="legend">
{{ . | markdownify -}}
</div>
{{- end }}
</figcaption>
</figure>