You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
2.6 KiB
HTML

{{ $align := .align | default "center" }}
{{ $caption := .caption | markdownify }}
{{ $compact := .compact }}
{{ $content := .content | markdownify }}
{{ $float := .float }}
{{ $gap := .gap }}
{{ $height := .height }}
{{ $maxheight := .maxheight }}
{{ $maxwidth := .maxwidth }}
{{ $width := .width }}
{{ $table := false }}
{{ if and $caption (or $compact $float) }}
{{ $table = true }}
{{ end }}
{{ $style := "" }}
{{ if $height }}
{{ with printf "height: %v" $height }}
{{ if $style }}
{{ $style = printf "%v; %v" $style . }}
{{ else }}
{{ $style = . }}
{{ end }}
{{ end }}
{{ end }}
{{ if $maxheight }}
{{ with printf "max-height: %v" $maxheight }}
{{ if $style }}
{{ $style = printf "%v; %v" $style . }}
{{ else }}
{{ $style = . }}
{{ end }}
{{ end }}
{{ end }}
{{ if $maxwidth }}
{{ with printf "max-width: %v" $maxwidth }}
{{ if $style }}
{{ $style = printf "%v; %v" $style . }}
{{ else }}
{{ $style = . }}
{{ end }}
{{ end }}
{{ end }}
{{ if $width }}
{{ with printf "width: %v" $width }}
{{ if $style }}
{{ $style = printf "%v; %v" $style . }}
{{ else }}
{{ $style = . }}
{{ end }}
{{ end }}
{{ end }}
{{ $sidemargin := "" }}
{{ 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 }}
<figure class="align-items-{{ $align }} d-flex flex-column {{ with $float }} float-{{ . }} {{ end }} justify-content-center {{ if $compact }} mb-0 {{ end }} {{ if $float }} {{ $sidemargin }} {{ end }} paige-figure" {{ if and $float $style }} style="{{ $style | safeCSS }}" {{ end }}>
{{ if and (not $float) $style }}
<div class="align-items-{{ $align }} d-flex flex-column {{ if $height }} h-100 {{ end }} justify-content-center" style="{{ $style | safeCSS }}">
{{ end }}
{{ if $table }}
<div class="d-table">
{{ end }}
<div class="text-{{ $align }}">{{ $content }}</div>
{{ with $caption }}
<figcaption class="figure-caption {{ with $gap }} mt-{{ . }} {{ end }} text-{{ $align }}" {{ if $table }} style="caption-side: bottom; display: table-caption" {{ end }}>{{ . }}</figcaption>
{{ end }}
{{ if $table }}
</div>
{{ end }}
{{ if and (not $float) $style }}
</div>
{{ end }}
</figure>