From b44bf78f1037c4ab73acfaad3c33f52168b13ef7 Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Wed, 5 Jan 2022 02:35:12 +0800 Subject: [PATCH] Improve the creation of header anchors (fix #474) --- _includes/refactor-content.html | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/_includes/refactor-content.html b/_includes/refactor-content.html index 8f8b042..bd87864 100644 --- a/_includes/refactor-content.html +++ b/_includes/refactor-content.html @@ -208,7 +208,9 @@ {% capture anchor %}{% endcapture %} {% assign left = snippet | split: mark_end | first %} - {% assign right = snippet | replace: left, '' %} + {% assign _start_index = left | size %} + {% assign _end_index = snippet | size | minus: 1 %} + {% assign right = snippet | slice: _start_index, _end_index %} {% assign _new_content = _new_content | append: mark_start | append: left | append: anchor | append: mark_end | append: right