mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 07:16:17 -04:00
When highlighting operation descriptions in search results, HTML tags are now ignored.
This commit is contained in:
parent
8518fa67f2
commit
b5eb44af9f
1 changed files with 9 additions and 0 deletions
|
@ -110,6 +110,15 @@ HTMLOperation.prototype.highlightSearchString = function(searchStr, namePos, des
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.description && descPos >= 0) {
|
if (this.description && descPos >= 0) {
|
||||||
|
// Find HTML tag offsets
|
||||||
|
const re = /<[^>]+>/g;
|
||||||
|
let match;
|
||||||
|
while ((match = re.exec(this.description))) {
|
||||||
|
// If the search string occurs within an HTML tag, return without highlighting it.
|
||||||
|
if (descPos >= match.index && descPos <= (match.index + match[0].length))
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.description = this.description.slice(0, descPos) + "<b><u>" +
|
this.description = this.description.slice(0, descPos) + "<b><u>" +
|
||||||
this.description.slice(descPos, descPos + searchStr.length) + "</u></b>" +
|
this.description.slice(descPos, descPos + searchStr.length) + "</u></b>" +
|
||||||
this.description.slice(descPos + searchStr.length);
|
this.description.slice(descPos + searchStr.length);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue