{{- $title := .Get "title" | markdownify -}} {{- $id := .Get "id" -}} {{- $enlarge := .Get "enlarge" -}} {{ if not $id }} {{ errorf "Definition shortcode requires an 'id' parameter" }} {{ end }} {{ $chapternb := index (findRESubmatch `^0*(\d+)` .Page.File.Dir) 0 1 }} {{ $dir := .Page.File.Dir }} {{ if not (.Site.Store.Get "defs") }} {{ .Site.Store.Set "defs" dict }} {{ end }} {{ $defsMap := .Site.Store.Get "defs" }} {{ if not (index $defsMap $dir) }} {{ .Site.Store.SetInMap "defs" $dir dict }} {{ end }} {{ $chapterMap := index $defsMap $dir }} {{ $maxKey := "max_key" }} {{ $definitionNumber := "" }} {{ $definitionNumber = index $chapterMap $id }} {{ if not $definitionNumber }} {{ $currentMax := index $chapterMap $maxKey }} {{ if not $currentMax }} {{ $currentMax = 0 }} {{ end }} {{ $currentMax = add $currentMax 1 }} {{ $definitionNumber = $currentMax }} {{ .Site.Store.SetInMap "defs" $dir (merge $chapterMap (dict $id $definitionNumber $maxKey $currentMax)) }} {{ end }} {{- $blockClass := "definition-block" -}} {{- if $enlarge -}} {{- $blockClass = printf "%s enlarge-%s" $blockClass $enlarge -}} {{- end -}}
Definition {{ $chapternb }}.{{ $definitionNumber }} {{- if $title -}}{{- $title -}}{{- end -}}
{{ .Inner | safeHTML }}