github.com/choria-io/go-choria@v0.28.1-0.20240416190746-b3bf9c7d5a45/docs/themes/hugo-theme-relearn/layouts/partials/shortcodes/mermaid.html (about) 1 {{- $page := .page }} 2 {{- if and (not $page) .context }} 3 {{- $page = .context }} 4 {{- warnf "%q: DEPRECATED parameter 'context' for shortcode 'mermaid' found, use 'page' instead; see https://mcshelby.github.io/hugo-theme-relearn/basics/migration#5180" $page.File.Filename }} 5 {{- end }} 6 {{- $content := .content }} 7 {{- $align := .align | default "center" }} 8 {{- $zoom := $page.Site.Params.mermaidZoom | default false }} 9 {{- with $page.Params.mermaidZoom }} 10 {{- $zoom = . }} 11 {{- if eq (printf "%T" .) "string" }} 12 {{- $zoom = (eq . "true") }} 13 {{- end }} 14 {{- end }} 15 {{- with .zoom }} 16 {{- $zoom = . }} 17 {{- if eq (printf "%T" .) "string" }} 18 {{- $zoom = (eq . "true") }} 19 {{- end }} 20 {{- end }} 21 22 {{- /* separate shortcode attributes from rest */}} 23 {{- $attributes := .attributes | default dict }} 24 {{- $otherAttributes := dict }} 25 {{- range $k, $v := $attributes }} 26 {{- if eq $k "align" }} 27 {{- else if eq $k "zoom" }} 28 {{- else }} 29 {{- $otherAttributes = (dict $k $v) | merge $otherAttributes }} 30 {{- end }} 31 {{- end }} 32 {{- $attributes = $otherAttributes }} 33 34 {{- /* enrich attributes */}} 35 {{- $attributes = merge $attributes (dict "class" (delimit (append (index $attributes "class" | default slice) "mermaid" slice) " ")) }} 36 {{- $attributes = merge $attributes (dict "class" (delimit (append (index $attributes "class" | default slice) (printf "align-%s" $align) slice) " ")) }} 37 {{- $attributes = merge $attributes (dict "class" (delimit (append (index $attributes "class" | default slice) (printf "%s" (cond $zoom "zoomable" "")) slice) " ")) }} 38 39 {{- with $page }} 40 <pre 41 {{- range $k, $v := $attributes }} 42 {{- if $v }} 43 {{- printf " %s=%q" $k $v | safeHTMLAttr }} 44 {{- end }} 45 {{- end }}>{{ replaceRE "'" "'" ( replaceRE """ "\"" ( $content | safeHTML ) ) }}</pre> 46 {{- .Store.Set "hasMermaid" true }} 47 {{- end }}