Only highlight when nesscary
This commit is contained in:
parent
8c2883ba5c
commit
983d221664
1 changed files with 42 additions and 37 deletions
|
@ -244,9 +244,13 @@ function converter(html, dynamic=true) {
|
|||
|
||||
for (let index = 0; index < rpTable.length; index++) {
|
||||
const text = rpTable[index];
|
||||
if (dynamic) {
|
||||
replacers[text] = himalaya.stringify(highlighter(himalaya.parse(replacers[text])))
|
||||
}
|
||||
html = html.replaceAll(`{${text}}`, replacers[text])
|
||||
}
|
||||
|
||||
if (!dynamic) {
|
||||
if (html.includes("<body>")) {
|
||||
var bodyHTML = htmlMinifier.minify(html.substring(html.indexOf("<body>") + 6, html.lastIndexOf("</body>")))
|
||||
var parsedHTML = himalaya.parse(bodyHTML)
|
||||
|
@ -254,9 +258,7 @@ function converter(html, dynamic=true) {
|
|||
var parsedHTML = himalaya.parse(html)
|
||||
}
|
||||
|
||||
// console.log(parsedHTML)
|
||||
|
||||
parsedHTML = highlighter(parsedHTML, dynamic)
|
||||
parsedHTML = highlighter(parsedHTML)
|
||||
|
||||
parsedHTML = himalaya.stringify(parsedHTML)
|
||||
if (html.includes("<body>")) {
|
||||
|
@ -265,8 +267,11 @@ function converter(html, dynamic=true) {
|
|||
} else {
|
||||
html = parsedHTML
|
||||
}
|
||||
}
|
||||
|
||||
if (dynamic) {
|
||||
html = html.replaceAll("{LOAD_TIME}", (Date.now() - startTime).toString() + "ms")
|
||||
}
|
||||
|
||||
return html
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue