Content added Content deleted
(completely different code for syntax highlighting) |
(javascript version is older so code must be compatible with the older version) |
||
Line 2: | Line 2: | ||
var syntaxElements = document.querySelectorAll("pre"); |
var syntaxElements = document.querySelectorAll("pre"); |
||
// for each element do an action |
// for each element do an action |
||
syntaxElements.forEach( |
syntaxElements.forEach(checkSyntax); |
||
function checkSyntax() { |
|||
// check if it has the specified keyword |
|||
if (code.textContent.indexOf("game.") > -1) { |
|||
// (technically) insert elements for specified keywords to color them |
|||
⚫ | |||
code.innerHTML = code.textContent |
|||
⚫ | |||
.replace(".", "<span style='color: #b1ac8b;'>.</span>") |
|||
}); |
|||
⚫ | |||
⚫ | |||
} |
Revision as of 16:11, 4 November 2023
// syntax highlighter
var syntaxElements = document.querySelectorAll("pre");
// for each element do an action
syntaxElements.forEach(checkSyntax);
function checkSyntax() {
// check if it has the specified keyword
if (code.textContent.indexOf("game.") > -1) {
// (technically) insert elements for specified keywords to color them
code.innerHTML = code.textContent
.replace(".", "<span style='color: #b1ac8b;'>.</span>")
.replace("game", "<span style='color: #9cdcfe;'>game</span>");
}
}