forked from mrlan/EnglishPal
更新 app/static/js/highlight.js
parent
d5c76674da
commit
393264a6fe
|
@ -43,11 +43,12 @@ function highLight() {
|
|||
// 删除所有的mark标签,防止标签发生嵌套
|
||||
articleContent = articleContent.replace(/<(mark)[^>]*>/gi, "");
|
||||
articleContent = articleContent.replace(/<(\/mark)[^>]*>/gi, "");
|
||||
// 将文章中所有出现该单词word的地方改为:"<mark>" + word + "<mark>"。
|
||||
// 将文章中所有出现该单词word的地方改为:"<span class='highlighted'>" + word + "</span>"。
|
||||
for (let word of totalSet) {
|
||||
articleContent = articleContent.replace(new RegExp("\\b" + word + "\\b", "g"), "<mark>" + word + "</mark>");
|
||||
articleContent = articleContent.replace(new RegExp("\\b" + word + "\\b", "g"), "<span class='highlighted'>" + word + "</span>");
|
||||
}
|
||||
document.getElementById("article").innerHTML = articleContent;
|
||||
|
||||
}
|
||||
|
||||
function cancelHighlighting() {
|
||||
|
|
Loading…
Reference in New Issue