Continuing to pollute and overcomplicate the highlight system
This commit is contained in:
parent
dde5fbcce9
commit
1d6696999a
1 changed files with 23 additions and 6 deletions
|
@ -146,15 +146,17 @@ function highlighter(json, full = true, linkParent = false) {
|
|||
var termKey = "{TERM" + index + "}"
|
||||
var termProps = dict
|
||||
while (element.content.includes(termKey)) {
|
||||
var endRegex = " "
|
||||
|
||||
var termIndex = element.content.indexOf(termKey)
|
||||
|
||||
var spanEnd = element.content.indexOf(" ", termIndex)
|
||||
var spanEnd = element.content.indexOf(endRegex, termIndex)
|
||||
|
||||
if (spanEnd == -1) {
|
||||
spanEnd = element.content.length
|
||||
}
|
||||
|
||||
var spanStart = element.content.substring(0, termIndex).lastIndexOf(" ") + 1
|
||||
var spanStart = element.content.substring(0, termIndex).lastIndexOf(endRegex) + 1
|
||||
|
||||
// if (highTable[index] == "ULTRAKILL") {
|
||||
// console.log(startContent, " ---- ", endContent)
|
||||
|
@ -164,12 +166,27 @@ function highlighter(json, full = true, linkParent = false) {
|
|||
var endContent = element.content.substring(termIndex + termKey.length, spanEnd)
|
||||
|
||||
if (startContent.includes("(") && !endContent.includes(")")) {
|
||||
spanEnd = element.content.indexOf(")", spanStart) + 1
|
||||
endContent = element.content.substring(termIndex + termKey.length, spanEnd)
|
||||
var newSpanEnd = element.content.indexOf(")", spanStart) + 1
|
||||
var newEndContent = element.content.substring(termIndex + termKey.length, newSpanEnd)
|
||||
if (newEndContent.includes("<") || newEndContent.includes("TERM")) {
|
||||
spanStart += 1
|
||||
startContent = startContent.substring(2)
|
||||
} else {
|
||||
spanEnd = newSpanEnd
|
||||
endContent = newEndContent
|
||||
}
|
||||
}
|
||||
else if (endContent.includes(")") && !startContent.includes("(")) {
|
||||
spanStart = element.content.substring(0, spanStart).lastIndexOf("(")
|
||||
startContent = element.content.substring(spanStart - 1, termIndex)
|
||||
var newSpanStart = element.content.substring(0, spanStart).lastIndexOf("(")
|
||||
var newStartContent = element.content.substring(newSpanStart - 1, termIndex)
|
||||
if (newStartContent.includes("<") || newStartContent.includes("TERM")) {
|
||||
spanEnd -= 1
|
||||
endContent = endContent.substring(0, endContent.length - 1)
|
||||
} else {
|
||||
console.log(newStartContent)
|
||||
spanStart = newSpanStart
|
||||
startContent = newStartContent
|
||||
}
|
||||
}
|
||||
|
||||
var style = termProps.style || ""
|
||||
|
|
Loading…
Reference in a new issue