Highlights only apply to body, all .files should work now

This commit is contained in:
Bingus_Violet 2024-02-13 08:49:28 -06:00
parent e8f60cd484
commit f9d3659f2a
2 changed files with 13 additions and 9 deletions

View file

@ -76,6 +76,7 @@
"replaceAll": "limegreen", "replaceAll": "limegreen",
"Godot Engine": "#64B5F6", "Godot Engine": "#64B5F6",
"javascript": "yellow", "javascript": "yellow",
"NodeJS": "limegreen" "NodeJS": "limegreen",
"Violet": "rgb(200, 150, 255)"
} }
} }

View file

@ -39,13 +39,6 @@ function converter(html) {
html = html.replaceAll(`{${text}}`, replacers[text]) html = html.replaceAll(`{${text}}`, replacers[text])
} }
var highTable = Object.keys(highlightedWords)
for (let index = 0; index < highTable.length; index++) {
var term = highTable[index];
var replacement = `<span style="color: ${highlightedWords[term]}">${term}</span>`
html = html.replaceAll(term, replacement)
}
while (html.includes("{PATH_")) { while (html.includes("{PATH_")) {
var pagePath = html.substring(html.indexOf("{PATH_")) var pagePath = html.substring(html.indexOf("{PATH_"))
pagePath = pagePath.substring(6, pagePath.indexOf('}')) pagePath = pagePath.substring(6, pagePath.indexOf('}'))
@ -58,6 +51,16 @@ function converter(html) {
html = html.replace(stringIndex, pageHTML) html = html.replace(stringIndex, pageHTML)
} }
var bodyHTML = html.substring(html.indexOf("<body>") + 6, html.lastIndexOf("</body>"))
var highTable = Object.keys(highlightedWords)
for (let index = 0; index < highTable.length; index++) {
var term = highTable[index];
var replacement = `<span style="color: ${highlightedWords[term]}">${term}</span>`
bodyHTML = bodyHTML.replaceAll(term, replacement)
}
html = html.substring(0, html.indexOf("<body>")) + bodyHTML + html.substring(html.indexOf("</body>") + 7)
return html return html
} }
@ -66,7 +69,7 @@ module.exports = {
var filePath = (req.baseUrl + req.path).trim() var filePath = (req.baseUrl + req.path).trim()
if (filePath.includes(".html") || filePath.includes(".css")) { if (filePath.includes(".")) {
} else { } else {
if (filePath.charAt(filePath.length - 1) != '/') { if (filePath.charAt(filePath.length - 1) != '/') {