From 3c54fd7778cd45a7f3045afeace98b21c5a493e6 Mon Sep 17 00:00:00 2001 From: bingus_violet Date: Thu, 5 Dec 2024 01:13:15 -0600 Subject: [PATCH] you can add words to the stoplist for h ighlighting now. wow. that took way longer than it should've. --- pageUpdater.js | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/pageUpdater.js b/pageUpdater.js index 5904b7d..e538d07 100644 --- a/pageUpdater.js +++ b/pageUpdater.js @@ -146,23 +146,34 @@ function highlighter(json, full = true, linkParent = false) { var termKey = "{TERM" + index + "}" var termProps = dict while (element.content.includes(termKey)) { - var endRegex = " " + var endCharacters = [" ", "&"] var termIndex = element.content.indexOf(termKey) - var spanEnd = element.content.indexOf(endRegex, termIndex) + var spanEnd = element.content.length - if (spanEnd == -1) { - spanEnd = element.content.length - } + endCharacters.forEach((char) => { + var end = element.content.indexOf(char, termIndex) + + if (end < spanEnd && end != -1) { + spanEnd = end + } + }) - var spanStart = element.content.substring(0, termIndex).lastIndexOf(endRegex) + 1 + var spanStart = 0 + + endCharacters.forEach((char) => { + var start = element.content.substring(0, termIndex).lastIndexOf(char) + 1 + if (spanStart < start) { + spanStart = start + } + }) // if (highTable[index] == "ULTRAKILL") { // console.log(startContent, " ---- ", endContent) // } - var startContent = element.content.substring(spanStart - 1, termIndex) + var startContent = element.content.substring(spanStart, termIndex) var endContent = element.content.substring(termIndex + termKey.length, spanEnd) if (startContent.includes("(") && !endContent.includes(")")) {