Fix wacky highlighting stuff

This commit is contained in:
bingus_violet 2024-06-27 00:45:19 -05:00
parent c574a2b48a
commit 3fd257cbe7

View file

@ -156,13 +156,18 @@ function highlighter(json, full = true) {
classes = `class="${classes}"` classes = `class="${classes}"`
} }
var replacement = `<span ${style} ${classes} ${link}>${startContent + highTable[index] + endContent}</span>` var stuff = (startContent + highTable[index] + endContent).trim()
if (!stuff.includes("span")) {
var replacement = `<span ${style} ${classes} ${link}>${stuff}</span>`
if (link) { if (link) {
replacement = `<a href="${link}">${replacement}</a>` replacement = `<a href="${link}">${replacement}</a>`
} }
element.content = element.content.substring(0, spanStart) + replacement + element.content.substring(spanEnd) element.content = element.content.substring(0, spanStart) + replacement + element.content.substring(spanEnd)
} else {
element.content = element.content.replace(termKey, highTable[index])
}
} }
} }