From f6027d6b85440ba3a475e4bf08a29159f1cfc329 Mon Sep 17 00:00:00 2001 From: codepzj <2363435714@qq.com> Date: Tue, 19 Nov 2024 15:53:11 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96stellar=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E5=BC=95=E6=93=8E=20(#538)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复代码块行号开启时搜索到一串代码行号的bug,过滤HTML实体 --- scripts/generators/search.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/generators/search.js b/scripts/generators/search.js index 218eb2e..1bedfd3 100644 --- a/scripts/generators/search.js +++ b/scripts/generators/search.js @@ -31,11 +31,13 @@ hexo.extend.generator.register('search_json_generator', function (locals) { temp_post.path = root + post.path } if (cfg.content != false && post.content) { - var content = stripHTML(post.content).trim() + var content = stripHTML(post.content.replace(/\d+<\/span>/g, '')).trim() // 部分HTML标签 content = content.replace(//g, '') content = content.replace(/
/g, '') content = content.replace(/
/g, '') + // 去除HTML实体 + content = content.replace(/&[^\s;]+;/g, "") // 换行符换成空格 content = content.replace(/\\n/g, ' ') content = content.replace(/\n/g, ' ')