{{ $params := . }} {{ $caption := $params.caption | markdownify }} {{ $compact := $params.compact }} {{ $content := $params.content | markdownify }} {{ $float := $params.float }} {{ $gap := $params.gap }} {{ $height := $params.height }} {{ $horizontal := $params.horizontal | default "center" }} {{ $maxheight := $params.maxheight }} {{ $maxwidth := $params.maxwidth }} {{ $number := $params.number }} {{ $numbered := $params.numbered }} {{ $vertical := $params.vertical | default "center" }} {{ $width := $params.width }} {{ $heightish := or $maxheight $height }} {{ $showcaption := $caption }} {{ $sidemargin := "" }} {{ $style := slice }} {{ $table := false }} {{ $widthish := or $maxwidth $width }} {{ if and $caption (or $compact $float) }} {{ $table = true }} {{ end }} {{ if $height }} {{ $style = $style | append (printf "height: %v" $height) }} {{ end }} {{ if $maxheight }} {{ $style = $style | append (printf "max-height: %v" $maxheight) }} {{ end }} {{ if $maxwidth }} {{ $style = $style | append (printf "max-width: %v" $maxwidth) }} {{ end }} {{ if $width }} {{ $style = $style | append (printf "width: %v" $width) }} {{ end }} {{ $style = delimit ($style | sort | uniq) "; " }} {{ if $float }} {{ if eq $float "start" }} {{ $sidemargin = "me-4" }} {{ else if eq $float "end" }} {{ $sidemargin = "ms-4" }} {{ else }} {{ errorf "invalid float: %q" $float }} {{ end }} {{ end }} {{ if $caption }} {{ if $number }} {{ $caption = printf "%v %v: %v" (i18n "paige_figure") $number $caption }} {{ end }} {{ else }} {{ if $number }} {{ $caption = printf "%v %v" (i18n "paige_figure") $number }} {{ $showcaption = true }} {{ else if $numbered }} {{ $showcaption = true }} {{ end }} {{ end }}
{{ if $table }}
{{ end }}
{{ $content }}
{{ if $showcaption }}
{{ $caption }}
{{ end }} {{ if $table }}
{{ end }}