{{ if not ($.Page.Scratch.Get "figurecount") }} {{ end }} {{ $.Page.Scratch.Add "figurecount" 1 }} {{ with .Get "src" }} {{ $.Scratch.Add "thumb" . }} {{ else }} {{ $.Scratch.Add "thumb" (printf "%s." (.Get "thumb") | replace (.Get "link") ".") }} {{ end }} {{ with .Get "link" }} {{ $.Scratch.Add "link" . }} {{ else }} {{ $.Scratch.Add "link" (.Get "src") }} {{ end }} {{ with .Get "alt" }} {{ $.Scratch.Add "alt" .}} {{else}} {{ with .Get "caption" }} {{ $.Scratch.Add "alt" .}} {{ end }} {{ end }}
{{ if or (or (.Get "title") (.Get "caption")) (.Get "attr")}}
{{ with .Get "title" }}

{{.}}

{{ end }} {{ if or (.Get "caption") (.Get "attr")}}

{{ .Get "caption" }} {{ with .Get "attrlink"}}{{ .Get "attr" }}{{ else }}{{ .Get "attr"}}{{ end }}

{{ end }}
{{ end }} {{ with $.Scratch.Get "link" }}{{ end }}