{{- /* Mermaid rendering partial for code fences extended syntax and shortcode usage. - Skips rendering when MarkupScope is home. - Supports wrapped view with tabs/actions and plain diagram mode. - Supports per-diagram filename for code/download actions. @param {Object} [.Options] render options from shortcode or code fence attributes @param {Boolean} [.Options.wrapper] whether to enable wrapped diagram UI @param {String} [.Options.filename] filename used by diagram/code actions @param {String} [.Inner] inline Mermaid source content @param {Object} [.Page] current page context */ -}} {{- if ne hugo.Context.MarkupScope "home" -}} {{- $code := strings.TrimSpace .Inner -}} {{- $wrapped := .Options.wrapper | default site.Params.mermaid.wrapper -}} {{- if $wrapped -}} {{- $labelDiagram := T "tabs.diagram" -}} {{- $labelCode := T "tabs.code" -}} {{- $labelZoomIn := T "diagram.zoomIn" -}} {{- $labelZoomOut := T "diagram.zoomOut" -}} {{- $labelReset := T "diagram.reset" -}} {{- $labelDownload := T "diagram.download" -}} {{- $filename := .Options.filename | default "mermaid.mmd" -}} {{- $codeAttrs := printf `{copyable=true, fullscreen=true, filename="%s", class="diagram-code"}` $filename -}} {{- $codeFence := printf "```text %s\n%s\n```" $codeAttrs $code -}}
{{ $labelDiagram }} {{ $labelCode }}
{{ $code | safeHTML }}
{{ $code | safeHTML }}
{{ $code | safeHTML }}
{{- $codeFence | .Page.RenderString (dict "display" "block") -}}
{{- .Page.Store.Set "hasPanzoom" true -}} {{- else -}}
{{ $code | safeHTML }}
{{ $code | safeHTML }}
{{ $code | safeHTML }}
{{- dict "Label" "Copy Mermaid code" | partial "plugin/diagram-copy-btn.html" -}}
{{- end -}} {{- .Page.Store.Set "hasMermaid" true -}} {{- end -}}