From e142f37e8dea7f6f502026cc35ea02390be63556 Mon Sep 17 00:00:00 2001
From: Jacky Zhao <j.zhao2k19@gmail.com>
Date: Tue, 19 Jul 2022 16:03:26 +0000
Subject: [PATCH] Merge branch 'hugo' of https://github.com/jackyzha0/quartz into hugo
---
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