From b5eb44af9f2dd38797b0a4075d11c89f4d924902 Mon Sep 17 00:00:00 2001 From: n1474335 Date: Tue, 13 Feb 2018 15:43:55 +0000 Subject: [PATCH] When highlighting operation descriptions in search results, HTML tags are now ignored. --- src/web/HTMLOperation.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/web/HTMLOperation.js b/src/web/HTMLOperation.js index ea0d4397..e709066f 100755 --- a/src/web/HTMLOperation.js +++ b/src/web/HTMLOperation.js @@ -110,6 +110,15 @@ HTMLOperation.prototype.highlightSearchString = function(searchStr, namePos, des } 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) + "" + this.description.slice(descPos, descPos + searchStr.length) + "" + this.description.slice(descPos + searchStr.length);