{{ $self := . }} {{ $content := .Content }} {{/* Wikilinks */}} {{ range (findRE "\\[\\[([^/=]+?)\\]\\]" .Content) }} {{ $wikilink := index (split . "/") 0 }} {{ $slug := replaceRE "\\[\\[|\\]\\]" "" $wikilink }} {{ if hasPrefix $slug "!" }} {{ $name := strings.TrimPrefix "!" $slug }} {{ $image := printf "%s" (partial "img" (dict "name" $name "page" $self)) }} {{ $content = replace $content $wikilink $image }} {{ else }} {{ $title := "" }} {{ $partial := "render-link" }} {{ if in $slug "|" }} {{ $parts := split $slug "|" }} {{ $slug = index $parts 0 }} {{ $title = index $parts 1 }} {{ end }} {{ if hasPrefix $slug "*" }} {{ $slug = strings.TrimPrefix "*" $slug }} {{ $partial = "render-item" }} {{ end }} {{ $page := $.Site.GetPage $slug }} {{ $expanded := printf "%s" $slug }} {{ if $page }} {{ if ne $page.RelPermalink "/" }} {{ $expanded = partial $partial $page }} {{ if ne $title "" }} {{ $expanded = replace $expanded (printf "%s" $page.Title) (printf "%s" $title) }} {{ end }} {{ end }} {{ end }} {{ $content = replace $content $wikilink $expanded }} {{ end }} {{ end }} {{/* symbols */}} {{ range (findRE "\\:([^/=\\s]+?)\\:" .Content) }} {{ $symbol := index (split . "/") 0 }} {{ $slug := replaceRE "\\:|\\:" "" $symbol }} {{ $expanded := $symbol }} {{ if in $.Site.Data.symbols.partials $slug }} {{ $partialName := printf "symbols/%s" $slug }} {{ $expanded = partial $partialName $self }} {{ else if in $.Site.Data.symbols.icons $slug }} {{ $expanded = partial "icon" $slug }} {{ else if hasPrefix $slug "fig_" }} {{ $expanded = printf "Figure ?" $slug }} {{ else if hasPrefix $slug "tbl_" }} {{ $expanded = printf "Table ?" $slug }} {{ else if hasPrefix $slug "exm_" }} {{ $expanded = printf "Example ?" $slug }} {{ else if hasPrefix $slug "eq_" }} {{ $expanded = printf "Equation \\eqref{eq:%s}" (substr $slug 3) }} {{ else if eq $slug "h" }} {{ $expanded = "
" }} {{ else if hasPrefix $slug "h-" }} {{ $expanded = printf "
" $slug }} {{ end }} {{ $content = replace $content $symbol $expanded }} {{ end }} {{/* references */}} {{ range (findRE "\\[@([^\\]]+?)\\]" .Content) }} {{ $reference := index (split . "/") 0 }} {{ $slug := replaceRE "\\[@|\\]" "" $reference }} {{ $page := $.Site.GetPage $slug }} {{ $expanded := partial "render-reference" $page }} {{ $content = replace $content $reference $expanded }} {{ end }}
{{ $content | safeHTML }}