{{- $content := trim .Inner "\n" -}} {{- $classList := .Get "class" | slice -}} {{- $tag := .Get "tag" | default "div" -}} {{- with .Get "code" -}} {{- /* highlight code content without line number */ -}} {{- $content = highlight $content . "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 -}} {{- $classList = $classList | append "highlight" -}} {{- else -}} {{- $content = $content | .Page.RenderString -}} {{- end -}} {{- /* trim the newline */ -}} {{- $id := dict "Content" $content "Scratch" .Page.Scratch | partial "function/id.html" -}} {{- $key := .Get "group" | string | default $id -}} {{- $typeitMap := (.Page.Scratch.Get "this").typeitMap | default dict -}} {{- $group := index $typeitMap $key -}} {{- $group = $group | default slice | append $id -}} {{- dict $key $group | merge $typeitMap | .Page.Scratch.SetInMap "this" "typeitMap" -}}
{{- printf `<%v id="%v" class="%v">` $tag $id (delimit $classList " ") $tag | safeHTML -}}