From 74993d19b72aee78e89b0b13b8f1d4a72fe5fe29 Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Tue, 05 Jul 2022 22:42:57 +0000
Subject: [PATCH] docs + fix: broken partial and description of enableGitHubEdit

---
 layouts/partials/textprocessing.html |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/layouts/partials/textprocessing.html b/layouts/partials/textprocessing.html
index 2312aa4..dfb0ff2 100644
--- a/layouts/partials/textprocessing.html
+++ b/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 }}

--
Gitblit v1.10.0