Aiden Bai 白宇彤
2022-07-03 015ed4cfa2db4636e03debcda0d4201f24346098
layouts/partials/textprocessing.html
@@ -27,10 +27,8 @@
      {{$inner := . | strings.TrimPrefix "![[" | strings.TrimSuffix "]]" }}
      {{$split := split $inner "|"}}
      {{$path := index $split 0 | relURL}}
      {{$reference := split $path "#"}}
      {{$title := index $reference 0}}
      {{$display := default $title (index $split 1)}}
      {{$img := printf "<img src=\"%s\" title=\"%s\">" $path $display}}
      {{$width := index $split 1}}
      {{$img := printf "<img src=\"%s\" width=\"%s\" />" $path (default "auto" $width)}}
      {{$content = replace $content . $img}}
    {{else}}
      {{$inner := . | strings.TrimPrefix "[[" | strings.TrimSuffix "]]" }}
@@ -39,7 +37,7 @@
      {{$reference := split $path "#"}}
      {{$title := index $reference 0}}
      {{$block := default "" (index $reference 1)}}
      {{$block = strings.TrimRight "/" (cond (eq $block "") $block (printf "#%s" $block))}}
      {{$block = strings.TrimRight "/" (cond (eq $block "") $block (printf "#%s" $block)) | urlize | lower}}
      {{$href := strings.TrimRight "/" ($page.GetPage $title).RelPermalink}}
      {{$display := default $title (index $split 1)}}
      {{if not $href}}
@@ -53,4 +51,8 @@
    {{end}}
  {{end}}
{{end}}
{{/* Add jumpable anchors */}}
{{ $content = $content | replaceRE "(<h[1-9] id=\"([^\"]+)\">)(.+)(</h[1-9]>)" `<a href="#${2}">${1}<span class="hanchor" ariaLabel="Anchor"># </span>${3}${4}</a>` }}
{{ $content | safeHTML }}