diff --git a/src/common/marked.js b/src/common/marked.js
index 22ac47c8..c4d1855f 100644
--- a/src/common/marked.js
+++ b/src/common/marked.js
@@ -150,6 +150,16 @@ renderer.code = function (code, infostring, escaped) {
}
+function cleanString(str) {
+ // 移除整个HTML标签及其内容
+ let cleanedStr = str.replace(/<[^>]*>[^<]*<\/[^>]*>/g, '');
+ // 移除剩余的HTML标签
+ cleanedStr = cleanedStr.replace(/<[^>]*>/g, '');
+ // 移除特殊字符
+ cleanedStr = cleanedStr.replace(/[.,/#!$%^&*;:{}=\-_`~():,。¥;「」|?》《~·【】‘、!]/g, '');
+ return cleanedStr;
+}
+
renderer.heading = function (text, level, raw) {
let anchor = this.options.headerPrefix + raw.toLowerCase().replace(/[^\w\\u4e00-\\u9fa5]]+/g, '-');
toc.push({
@@ -157,7 +167,7 @@ renderer.heading = function (text, level, raw) {
level: level,
text: text
})
- let id = anchor.replace(/[.,/#!$%^&*;:{}=\-_`~():,。¥;「」|?》《~·【】‘、!]/g,"");
+ let id = cleanString(anchor);
return '