From 282b546edc1b9bcec06c618d2803f144f4c43655 Mon Sep 17 00:00:00 2001 From: "xiaoqi.cxq" Date: Fri, 30 Jun 2023 09:40:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dh=E6=A0=87=E7=AD=BE=E6=B8=B2?= =?UTF-8?q?=E6=9F=93=E5=8C=85=E5=90=AB=E5=9B=BE=E7=89=87=E9=94=9A=E7=82=B9?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E5=B9=B6=E5=9B=BE=E7=89=87=E6=B8=B2=E6=9F=93?= =?UTF-8?q?=E4=B8=8D=E4=BA=86=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/extensions/libs/markdownItAnchor.js | 1 + src/services/editorSvc.js | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/extensions/libs/markdownItAnchor.js b/src/extensions/libs/markdownItAnchor.js index 41856fb7..fd636c6b 100644 --- a/src/extensions/libs/markdownItAnchor.js +++ b/src/extensions/libs/markdownItAnchor.js @@ -56,6 +56,7 @@ export default (md) => { // According to http://pandoc.org/README.html#extension-auto_identifiers let slug = headingContent + .replace(/]*>/g, '') // Replace image to empty .replace(/\s/g, '-') // Replace all spaces and newlines with hyphens .replace(/[\0-,/:-@[-^`{-~]/g, '') // Remove all punctuation, except underscores, hyphens, and periods .toLowerCase(); // Convert all alphabetic characters to lowercase diff --git a/src/services/editorSvc.js b/src/services/editorSvc.js index 2de82a14..536ced66 100644 --- a/src/services/editorSvc.js +++ b/src/services/editorSvc.js @@ -233,7 +233,12 @@ const editorSvc = Object.assign(new Vue(), editorSvcDiscussions, editorSvcUtils, const clonedElt = headingElt.cloneNode(true); clonedElt.removeAttribute('id'); sectionTocElt.appendChild(clonedElt); - headingElt.innerHTML = `${headingElt.innerHTML}`; + const prefixElt = document.createElement('span'); + prefixElt.className = 'prefix'; + headingElt.insertBefore(prefixElt, headingElt.firstChild); + const suffixElt = document.createElement('span'); + suffixElt.className = 'suffix'; + headingElt.appendChild(suffixElt); } if (insertBeforeTocElt) { this.tocElt.insertBefore(sectionTocElt, insertBeforeTocElt);