From 4e8ef0a44c5a85c7d9caaae7eace68e565339441 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8E=E5=A4=A9=E5=B8=85?= <2465011750@qq.com> Date: Fri, 5 Jul 2024 12:18:06 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20app/static/js/highlight.js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/static/js/highlight.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/static/js/highlight.js b/app/static/js/highlight.js index 9646ff3..368ff94 100644 --- a/app/static/js/highlight.js +++ b/app/static/js/highlight.js @@ -42,8 +42,7 @@ function highLight() { let totalSet = new Set(); for (let i = 0; i < list.length; ++i) { list[i] = list[i].replace(/(^\W*)|(\W*$)/g, ""); // 消除单词两边的非单词字符 - list[i] = list[i].replace('|', ""); - list[i] = list[i].replace('?', ""); + list[i] = list[i].replace(/[!?()]/g, ""); if (list[i] != "" && !totalSet.has(list[i])) { // 返回所有匹配单词的集合, 正则表达式RegExp()中, "\b"匹配一个单词的边界, g 表示全局匹配, i 表示对大小写不敏感。 let matches = new Set(articleContent.match(new RegExp("\\b" + list[i] + "\\b", "gi")));