{{- $content := .Content -}} {{- if $content -}} {{- $content = dict "Content" .Content "Ruby" .Ruby "Fraction" .Fraction "Fontawesome" .Fontawesome | partial "function/content.html" }} {{- /* Keep only the code content: remove highlight/chroma/lntable wrapper and line numbers */ -}} {{- $content = $content | replaceRE `(?s)
| ]*class="lntd"[^>]*>.*? | \s*]*class="lntd"[^>]*>(.*?) | \s*
]*>.*?` $content -}}
{{- if gt (len $codeBlocks) 0 -}}
{{- range $i, $block := $codeBlocks -}}
{{- $newBlock := $block -}}
{{- $textMatches := findRE `>([^<]+)<` $block -}}
{{- if gt (len $textMatches) 0 -}}
{{- range $j, $m := $textMatches -}}
{{- $inner := $m | replaceRE `^>([^<]+)<$` "$1" -}}
{{- $newInner := replace $inner " " " " -}}
{{- $newMatch := printf ">%s<" $newInner -}}
{{- $newBlock = replace $newBlock $m $newMatch -}}
{{- end -}}
{{- end -}}
{{- $content = replace $content $block $newBlock -}}
{{- end -}}
{{- end -}}
{{- /* Keep only the first ...inside a diagram-container */ -}} {{- $content = $content | replaceRE `(?s)
]*class="mermaid"[^>]*>.*?).*?
]*class="mermaid"[^>]*>.*?` $content -}} {{- if gt (len $mermaidMatches) 0 -}} {{- range $i, $m := $mermaidMatches -}} {{- $attrs := $m | replaceRE `(?s)
]*)>.*?` "$1" -}} {{- $inner := $m | replaceRE `(?s)
]*>(.*?)` "$1" -}} {{- $inner = replace $inner " " " " -}} {{- $newPre := printf "
%s" $attrs $inner -}} {{- $content = replace $content $m $newPre -}} {{- end -}} {{- end -}} {{- /* Remove echarts diagram containers entirely */ -}} {{- $content = $content | replaceRE `(?s)
%s" $pretty -}}
{{- /* replace the full original match with the rendered block */ -}}
{{- $content = replace $content $m $replacement -}}
{{- end -}}
{{- end -}}
{{- with .FeaturedImage }}
{{- $content = add (printf "