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

@ -36,7 +36,7 @@ for (var i = 0; i < globResult.length; i++) {
})
}
(async function() {
(async function () {
globResult = glob.globSync("**/static/**/*.js", { absolute: true })
for (var i = 0; i < globResult.length; i++) {
javascriptCache[globResult[i]] = await minify({
@ -156,13 +156,18 @@ function highlighter(json, full = true) {
classes = `class="${classes}"`
}
var replacement = `<span ${style} ${classes} ${link}>${startContent + highTable[index] + endContent}</span>`
var stuff = (startContent + highTable[index] + endContent).trim()
if (link) {
replacement = `<a href="${link}">${replacement}</a>`
if (!stuff.includes("span")) {
var replacement = `<span ${style} ${classes} ${link}>${stuff}</span>`
if (link) {
replacement = `<a href="${link}">${replacement}</a>`
}
element.content = element.content.substring(0, spanStart) + replacement + element.content.substring(spanEnd)
} else {
element.content = element.content.replace(termKey, highTable[index])
}
element.content = element.content.substring(0, spanStart) + replacement + element.content.substring(spanEnd)
}
}