Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions texthighlighter.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,12 @@ class textHighlight {
#markText() {
let txt = this.ele.value.replace(/</g, '&lt;').replace(/>/g, '&gt;');
if (this.searchArg) { console.log(this.ele.value)

let searchArg = this.searchArg.replace(/</g, '&lt;').replace(/>/g, '&gt;');
let boundary = this.word ? '\\b' : '';

let re = new RegExp(boundary + '(' + this.#escapeString(searchArg) + ')' + boundary, 'g' + (this.sensitive ? '' : 'i'));
return txt.replace(re, '<mark>$&</mark>');
let re = new RegExp(this.searchArg);
var tmp = txt.split('\n')
for (var i = 0; i < tmp.length; i++) {
tmp[i] = tmp[i].replace(re, '<mark>$&</mark>');
}
return tmp.join('\n')
} else {
return txt;
}
Expand Down Expand Up @@ -154,4 +154,4 @@ class textHighlight {
}
}
}
}
}