only add URL if no parent is a
This commit is contained in:
parent
715d4f1658
commit
07d69cea8b
1 changed files with 6 additions and 4 deletions
|
@ -92,7 +92,7 @@ function pathReplacer(html) {
|
|||
return html
|
||||
}
|
||||
|
||||
function highlighter(json, full = true) {
|
||||
function highlighter(json, full = true, linkParent = false) {
|
||||
for (var i = 0; i < json.length; i++) {
|
||||
var element = json[i]
|
||||
if (element.type == "element") {
|
||||
|
@ -113,7 +113,7 @@ function highlighter(json, full = true) {
|
|||
}
|
||||
|
||||
if (valid) {
|
||||
element.children = highlighter(element.children, full)
|
||||
element.children = highlighter(element.children, full, linkParent || element.tagName == "a")
|
||||
}
|
||||
}
|
||||
} else if (element.type == "text") {
|
||||
|
@ -205,13 +205,15 @@ function highlighter(json, full = true) {
|
|||
var stuff = (startContent + dict.words[x] + endContent).trim()
|
||||
|
||||
if (!stuff.includes("span")) {
|
||||
var replacement = `<span ${style} ${classes} ${link}>${stuff}</span>`
|
||||
var replacement = `<span ${style} ${classes}>${stuff}</span>`
|
||||
|
||||
if (link) {
|
||||
if (link && !linkParent) {
|
||||
replacement = `<a href="${link}">${replacement}</a>`
|
||||
// console.log(replacement)
|
||||
}
|
||||
element.content = element.content.substring(0, spanStart) + replacement + element.content.substring(spanEnd)
|
||||
} else {
|
||||
|
||||
element.content = element.content.replace(termKey, dict.words[x])
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue