mermaid: support Markdown attributes #795

This commit is contained in:
Sören Weber 2024-03-11 20:57:21 +01:00
parent 345de238c9
commit a9e7e8a492
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
3 changed files with 28 additions and 11 deletions

View file

@ -1,5 +1,6 @@
{{- partial "shortcodes/mermaid.html" (dict {{- partial "shortcodes/mermaid.html" (dict
"page" .Page "page" .Page
"attributes" .Attributes
"content" .Inner "content" .Inner
"align" (index .Attributes "align") "align" (index .Attributes "align")
) }} ) }}

View file

@ -18,9 +18,30 @@
{{- $zoom = (eq . "true") }} {{- $zoom = (eq . "true") }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- /* separate shortcode attributes from rest */}}
{{- $attributes := .attributes | default dict }}
{{- $otherAttributes := dict }}
{{- range $k, $v := $attributes }}
{{- if eq $k "align" }}
{{- else if eq $k "zoom" }}
{{- else }}
{{- $otherAttributes = (dict $k $v) | merge $otherAttributes }}
{{- end }}
{{- end }}
{{- $attributes = $otherAttributes }}
{{- /* enrich attributes */}}
{{- $attributes = merge $attributes (dict "class" (delimit (append (index $attributes "class" | default slice) "mermaid" slice) " ")) }}
{{- $attributes = merge $attributes (dict "class" (delimit (append (index $attributes "class" | default slice) (printf "align-%s" $align) slice) " ")) }}
{{- $attributes = merge $attributes (dict "class" (delimit (append (index $attributes "class" | default slice) (printf "%s" (cond $zoom "zoomable" "")) slice) " ")) }}
{{- with $page }} {{- with $page }}
<pre class="mermaid align-{{ $align }}{{ if $zoom }} zoomable{{ end }}"> <pre
{{- replaceRE "&#39;" "'" ( replaceRE "&#34;" "\"" ( $content | safeHTML ) ) -}} {{- range $k, $v := $attributes }}
</pre> {{- if $v }}
{{- printf " %s=%q" $k $v | safeHTMLAttr }}
{{- end }}
{{- end }}>{{ replaceRE "&#39;" "'" ( replaceRE "&#34;" "\"" ( $content | safeHTML ) ) }}</pre>
{{- .Store.Set "hasMermaid" true }} {{- .Store.Set "hasMermaid" true }}
{{- end }} {{- end }}

View file

@ -2288,8 +2288,3 @@ html[dir="rtl"] #R-sidebar ul.collapsible-menu > li > label > i.fa-chevron-right
.term-list ul > li ~ li:before { .term-list ul > li ~ li:before {
content: " | " content: " | "
} }
.red {
background-color: red !important;
border: 5px solid #d000d0 !important;
}