Conjoined words are now highlighted

This commit is contained in:
bingus_violet 2024-06-02 19:32:47 -05:00
parent 366b1e552b
commit 7332ae9d5e
2 changed files with 21 additions and 5 deletions

View file

@ -50,10 +50,6 @@
"Godot Engine": "#64B5F6",
"Javascript": "yellow",
"NodeJS": "limegreen",
"Violets-Purgatory": "rgb(200, 150, 255)",
"Violets-Cache": "rgb(200, 150, 255)",
"Violet's": "rgb(200, 150, 255)",
"Violets": "rgb(200, 150, 255)",
"Violet": "rgb(200, 150, 255)",
"Purgatory": "rgb(200, 150, 255)",
"Asahi": "rgb(255, 175, 175)",

View file

@ -149,7 +149,27 @@ function converter(html) {
}
for (let index = 0; index < highTable.length; index++) {
element.content = element.content.replaceAll("{TERM" + index + "}", `<span style="color: ${highlightedWords[highTable[index]]}">${highTable[index]}</span>`)
var termKey = "{TERM" + index + "}"
while (element.content.includes(termKey)) {
var termIndex = element.content.indexOf(termKey)
var spanEnd = element.content.indexOf(" ", termIndex)
if (spanEnd == -1) {
spanEnd = element.content.length
}
var endContent = element.content.substring(termIndex + termKey.length, spanEnd)
var spanStart = element.content.substring(0, termIndex).lastIndexOf(" ")
var startContent = element.content.substring(spanStart, termIndex)
var replacement = `<span style="color: ${highlightedWords[highTable[index]]}">${startContent + highTable[index] + endContent}</span>`
element.content = element.content.substring(0, spanStart) + replacement + element.content.substring(spanEnd)
}
// element.content = element.content.replaceAll(termKey, replacement)
}
}
}