mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 01:33:04 +00:00
mermaid: support Markdown attributes #795
This commit is contained in:
parent
345de238c9
commit
a9e7e8a492
3 changed files with 28 additions and 11 deletions
|
@ -1,5 +1,6 @@
|
|||
{{- partial "shortcodes/mermaid.html" (dict
|
||||
"page" .Page
|
||||
"attributes" .Attributes
|
||||
"content" .Inner
|
||||
"align" (index .Attributes "align")
|
||||
) }}
|
|
@ -18,9 +18,30 @@
|
|||
{{- $zoom = (eq . "true") }}
|
||||
{{- 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 }}
|
||||
<pre class="mermaid align-{{ $align }}{{ if $zoom }} zoomable{{ end }}">
|
||||
{{- replaceRE "'" "'" ( replaceRE """ "\"" ( $content | safeHTML ) ) -}}
|
||||
</pre>
|
||||
<pre
|
||||
{{- range $k, $v := $attributes }}
|
||||
{{- if $v }}
|
||||
{{- printf " %s=%q" $k $v | safeHTMLAttr }}
|
||||
{{- end }}
|
||||
{{- end }}>{{ replaceRE "'" "'" ( replaceRE """ "\"" ( $content | safeHTML ) ) }}</pre>
|
||||
{{- .Store.Set "hasMermaid" true }}
|
||||
{{- end }}
|
|
@ -2288,8 +2288,3 @@ html[dir="rtl"] #R-sidebar ul.collapsible-menu > li > label > i.fa-chevron-right
|
|||
.term-list ul > li ~ li:before {
|
||||
content: " | "
|
||||
}
|
||||
|
||||
.red {
|
||||
background-color: red !important;
|
||||
border: 5px solid #d000d0 !important;
|
||||
}
|
Loading…
Reference in a new issue