figure shortcode: Support i18n and unnumbered captions

- Figures are now unnumbered by default
- To number a figure, use the form:
  - `{{< figure src="image.jpg" title="Caption" numbered="true" >}}`
- Add i18n translation for "Figure" in captions
- Update English and Chinese language packs

Close #328 and #513
This commit is contained in:
George Cushen committed 2018-04-21 10:35:15 +01:00
1 parent 9fa9d56eb3
commit f23526e55d
4 files changed
+38 -6

No files matched your search

+3
View File
@@ -20,6 +20,9 @@
- id: next
translation: Next
- id: figure
translation: "Figure %d:"
# Buttons
- id: btn_preprint
+9
View File
@@ -14,6 +14,15 @@
- id: minute_read
translation: 分钟阅读时间
- id: previous
translation: 上一页
- id: next
translation: 下一页
- id: figure
translation: "图%d:"
# Buttons
- id: btn_preprint
+9 -6
View File
@@ -139,12 +139,6 @@ video {
margin: 0 auto;
}
figcaption:before {
font-weight: 700;
text-transform: uppercase;
content: "Figure " counter(captions) ": ";
}
figcaption {
display: block;
margin-top: 0.75em;
@@ -152,6 +146,15 @@ figcaption {
font-size: 1rem;
margin-bottom: 1.65rem;
font-family: '{{ .Get "heading_font" }}', sans-serif;
}
figcaption.numbered:before {
font-weight: 700;
text-transform: uppercase;
content: attr(data-pre) counter(captions) attr(data-post);
}
figcaption.numbered {
counter-increment: captions;
}
+17
View File
@@ -0,0 +1,17 @@
<figure{{ with .Get "class" }} class="{{.}}"{{ end }}>
{{ if .Get "link"}}<a href="{{ .Get "link" }}"{{ with .Get "target" }} target="{{ . }}"{{ end }}{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>{{ end }}
<img src="{{ .Get "src" }}" {{ if or (.Get "alt") (.Get "caption") }}alt="{{ with .Get "alt"}}{{.}}{{else}}{{ .Get "caption" }}{{ end }}" {{ end }}{{ with .Get "width" }}width="{{.}}" {{ end }}{{ with .Get "height" }}height="{{.}}" {{ end }}/>
{{ if .Get "link"}}</a>{{ end }}
{{ if or (or (.Get "title") (.Get "caption")) (.Get "attr")}}
{{ $figure := split (i18n "figure" | default "Figure %d:") "%d" }}
<figcaption data-pre="{{ index $figure 0 }}" data-post="{{ index $figure 1 }}" {{ if eq (.Get "numbered") "true" }}class="numbered"{{ end }}>{{ if isset .Params "title" }}
<h4>{{ .Get "title" }}</h4>{{ end }}
{{ if or (.Get "caption") (.Get "attr")}}<p>
{{ .Get "caption" }}
{{ with .Get "attrlink"}}<a href="{{.}}"> {{ end }}
{{ .Get "attr" }}
{{ if .Get "attrlink"}}</a> {{ end }}
</p> {{ end }}
</figcaption>
{{ end }}
</figure>