From 1c1d3d95b0ac819e1c1826f04169bd048768b0e3 Mon Sep 17 00:00:00 2001 From: Karlukle Date: Sun, 18 Feb 2024 15:59:35 +0000 Subject: [PATCH] Fix Bugs: Anchors Not Functioning Correctly for CJK Headings While utilizing the Blowfish theme, it was observed that headings containing non-ASCII characters, such as those in Chinese text, were not positioned when clicked on either the Table of Contents (TOC) or the anchor mark (#) preceding the heading. This issue did not occur with headings in plain English. The resolution involved updating the render-heading.html file to implement URL escaping for anchors, enabling accurate positioning for non-ASCII headings. --- layouts/_default/_markup/render-heading.html | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/layouts/_default/_markup/render-heading.html b/layouts/_default/_markup/render-heading.html index f76eb43c..ccc83778 100644 --- a/layouts/_default/_markup/render-heading.html +++ b/layouts/_default/_markup/render-heading.html @@ -1,10 +1,12 @@ +{{ $strAnchor := urlize .Anchor }} +{{ $replacedAnchor := replaceRE "%25" "" $strAnchor }} {{ .Text | safeHTML }} -
+
{{ if.Page.Params.showHeadingAnchors | default (.Page.Site.Params.article.showHeadingAnchors | default true) }} # + style="text-decoration-line: none !important;" href="#{{ $replacedAnchor | safeURL }}" aria-label="{{ i18n "article.anchor_label" }}"># {{ end }}