{{ $id := .Get "id" | default (printf "figure-%d" .Ordinal) }} {{ $src := .Get "src" }} {{ $caption := .Get "caption" }} {{ $alt := .Get "alt" | default $caption }} {{ $figures := .Page.Scratch.Get "figures" | default dict }} {{ $number := add (len $figures) 1 }} {{ .Page.Scratch.SetInMap "figures" $id $number }}
{{ with $src }} {{ $alt }} {{ end }} {{ if or $caption .Inner }}
Figure {{ $number }}. {{ with $caption }}{{ . | markdownify }}{{ else }}{{ .Inner | markdownify }}{{ end }}
{{ end }}