I am using a tag with v-html to render HTML text and display it, like so:
<div v-html="htmlText"></div>
Vue.filter('highlight', function (word, query) {
if (query !== '') {
let check = new RegExp(query, "ig");
return word.toString().replace(check, function (matchedText, a, b) {
return ('<strong class="mark">' + matchedText + '</strong>');
});
} else {
return word;
}
<div v-html="$options.filters.highlight(htmlText, myWord)">
</div>
I am trying to highlight a specific word within this text without affecting the HTML tags. Can someone please assist? Thank you.