1
0
Fork 0

更新 app/static/js/highlight.js

Bug569-YuTianshuai
于天帅 2024-07-05 12:18:06 +08:00
parent 00ae770195
commit 4e8ef0a44c
1 changed files with 1 additions and 2 deletions

View File

@ -42,8 +42,7 @@ function highLight() {
let totalSet = new Set(); let totalSet = new Set();
for (let i = 0; i < list.length; ++i) { for (let i = 0; i < list.length; ++i) {
list[i] = list[i].replace(/(^\W*)|(\W*$)/g, ""); // 消除单词两边的非单词字符 list[i] = list[i].replace(/(^\W*)|(\W*$)/g, ""); // 消除单词两边的非单词字符
list[i] = list[i].replace('|', ""); list[i] = list[i].replace(/[!?()]/g, "");
list[i] = list[i].replace('?', "");
if (list[i] != "" && !totalSet.has(list[i])) { if (list[i] != "" && !totalSet.has(list[i])) {
// 返回所有匹配单词的集合, 正则表达式RegExp()中, "\b"匹配一个单词的边界, g 表示全局匹配, i 表示对大小写不敏感。 // 返回所有匹配单词的集合, 正则表达式RegExp()中, "\b"匹配一个单词的边界, g 表示全局匹配, i 表示对大小写不敏感。
let matches = new Set(articleContent.match(new RegExp("\\b" + list[i] + "\\b", "gi"))); let matches = new Set(articleContent.match(new RegExp("\\b" + list[i] + "\\b", "gi")));