{{- /* only the trailing newline is retained */ -}} {{- $content := replaceRE `(?s)^\n*(.*?)\n*$` "$1\n" .Inner | .Page.RenderString -}} {{- /* shuffle md5 as id */ -}} {{- $id := delimit (split (md5 $content) "" | shuffle) "" | printf "typeit-%s" -}}
{{- /* raw html content */ -}} {{- if .Get "raw" -}}
{{- else if .Get "code" -}} {{- /* highlight code content without line number */ -}} {{- $content = highlight $content (.Get "code") "linenos=false" -}} {{- /* delete outer label */ -}} {{- $content = replaceRE `
]*>(?s)(.*)
` "$1" $content -}} {{- /* parsing markdown links */ -}} {{- $content = replaceRE `(]*>)([^<>]*)\[([^<>]+)\]\(([^<>]+)\)([^<>]*)()` "$1$2$6$3$1$5$6" $content -}} {{- /* replace " " to " " and replace "\n" to "
" */ -}} {{- $content = replaceRE ` ` " " $content | replaceRE `(<\w+) ` "$1 " | replaceRE `\n` "
" -}} {{- /* fix "
" location error which is a bug of Typeit HTML parser */ -}} {{- $content = replaceRE `
` "
" $content -}}
{{- else -}} {{- $tag := .Get "tag" | default "p" -}} {{- $content = $content | chomp -}} {{- printf "<%s id=%s>" $tag $id $tag | safeHTML -}} {{- end -}} {{- $key := .Get "group" | default $id -}} {{- $group := index (.Page.Scratch.Get "typeitMap" | default dict) $key -}} {{- $group = $group | default slice | append $id -}} {{- .Page.Scratch.SetInMap "typeitMap" $key $group -}}