Will no longer highlight an already highlighted word

This commit is contained in:
bingus_violet 2024-06-02 18:56:53 -05:00
parent 8949bbfd01
commit 366b1e552b
3 changed files with 7 additions and 5 deletions

View file

@ -64,8 +64,8 @@
"Fedi": "rgb(175, 125, 200)", "Fedi": "rgb(175, 125, 200)",
"Matrix": "limegreen", "Matrix": "limegreen",
"Element": "rgb(100, 255, 200)", "Element": "rgb(100, 255, 200)",
"Code": "rgb(150, 175, 255)",
"Codeberg": "rgb(0, 255, 255)", "Codeberg": "rgb(0, 255, 255)",
"Code": "rgb(150, 175, 255)",
"Docker": "blue", "Docker": "blue",
"Github": "gray", "Github": "gray",
"Steam": "lightgray", "Steam": "lightgray",

View file

@ -142,13 +142,15 @@ function converter(html) {
for (let index = 0; index < highTable.length; index++) { for (let index = 0; index < highTable.length; index++) {
var term = highTable[index]; var term = highTable[index];
var replacement = `<span style="color: ${highlightedWords[term]}">${term}</span>`
element.content = element.content.replaceAll(`{${term}}`, "TEMPORARY_REPLACE") element.content = element.content.replaceAll(`{${term}}`, "TEMPORARY_REPLACE")
element.content = element.content.replaceAll(term, replacement) element.content = element.content.replaceAll(term, "{TERM" + index + "}")
element.content = element.content.replaceAll("TEMPORARY_REPLACE", `${term}`) element.content = element.content.replaceAll("TEMPORARY_REPLACE", `${term}`)
} }
for (let index = 0; index < highTable.length; index++) {
element.content = element.content.replaceAll("{TERM" + index + "}", `<span style="color: ${highlightedWords[highTable[index]]}">${highTable[index]}</span>`)
}
} }
} }

View file

@ -51,7 +51,7 @@
<div> <div>
<h3>Coding</h3> <h3>Coding</h3>
<a class="chip" href="https://git.violets-purgatory.dev/bingus_violet/">Forgejo: bingus_violet (git.violets-purgatory.dev)</a> <a class="chip" href="https://git.violets-purgatory.dev/bingus_violet/">Forgejo: bingus_violet (git.violets-purgatory.dev)</a>
<a class="chip" href="https://codeberg.org/Bingus_violet">{Code}berg: bingus_violet</a> <a class="chip" href="https://codeberg.org/Bingus_violet">Codeberg: bingus_violet</a>
<a class="chip" href="https://hub.docker.com/u/bingusviolet">Docker: bingusviolet</a> <a class="chip" href="https://hub.docker.com/u/bingusviolet">Docker: bingusviolet</a>
<a class="chip" href="https://github.com/violets-puragtory">Github: violets-puragtory</a> <a class="chip" href="https://github.com/violets-puragtory">Github: violets-puragtory</a>
</div> </div>