{{ $content := replaceRE `(?s)^\n*(.*?)\n*$` "$1\n" .Inner }} {{ $id := delimit (split (md5 $content) "" | shuffle) "" | printf "tp-%s" }}
{{ if .Get "raw" }}
{{ else if .Get "code" }} {{ $content = highlight $content (.Get "code") "linenos=" }} {{ $content = replaceRE `
]*>(?s)(.*)
` "$1" $content }} {{ $content = replaceRE `(]*>)([^<>]*)\[([^<>]+)\]\(([^<>]+)\)([^<>]*)()` "$1$2$6$3$1$5$6" $content }} {{ $content = replaceRE ` ` " " $content | replaceRE `(<\w+) ` "$1 " | replaceRE `\n` "
" }} {{ $content = replaceRE `
` "
" $content }}
{{ else }} {{ $tag := .Get "tag" | default "p" }} {{ $content = $content | markdownify | chomp }} {{ printf "<%s id=%s>" $tag $id $tag | safeHTML }} {{ end }} {{ $typeitMap := .Page.Scratch.Get "typeitMap" }} {{ $group := slice $id }} {{ with .Get "group" }} {{ if $typeitMap }} {{ if index $typeitMap . }} {{ $group = index $typeitMap . | append $id }} {{ end }} {{ $typeitMap = dict . $group | merge $typeitMap }} {{ else }} {{ $typeitMap = dict . $group }} {{ end }} {{ else }} {{ if $typeitMap }} {{ $typeitMap = dict $id $group | merge $typeitMap }} {{ else }} {{ $typeitMap = dict $id $group }} {{ end }} {{ end }} {{ .Page.Scratch.Set "typeitMap" $typeitMap }}