Fix overlapping highlights

This commit is contained in:
bingus_violet 2024-06-18 07:26:18 -05:00
parent 3cc2844e1c
commit 10e4a95c7c
2 changed files with 8 additions and 7 deletions

View file

@ -164,9 +164,6 @@
"Teto Territory": {
"color": "rgb(255, 100, 100)",
"caseInsensitive": true
},
"Services": {
},
"Teto": {
"color": "rgb(255, 100, 100)",

View file

@ -171,16 +171,20 @@ function converter(html) {
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 spanStart = element.content.substring(0, termIndex).lastIndexOf(" ") + 1
var startContent = element.content.substring(spanStart - 1, termIndex)
var style = ""
var style = termProps.style || ""
if (termProps.color) {
style += `color: ${termProps.color};`
}
var replacement = `<span style="${style}">${startContent + highTable[index] + endContent}</span>`
if (style.length > 2) {
style = `style="${style}"`
}
var replacement = `<span ${style}>${startContent + highTable[index] + endContent}</span>`
element.content = element.content.substring(0, spanStart) + replacement + element.content.substring(spanEnd)
}