Content added Content deleted
(javascript version is older so code must be compatible with the older version) |
m (this thing is annoying) |
||
Line 3: | Line 3: | ||
// for each element do an action |
// for each element do an action |
||
syntaxElements.forEach(checkSyntax); |
syntaxElements.forEach(checkSyntax); |
||
function checkSyntax() { |
function checkSyntax(code) { |
||
// check if it has the specified keyword |
// check if it has the specified keyword |
||
if (code.textContent.indexOf("game.") > -1) { |
if (code.textContent.indexOf("game.") > -1) { |
Revision as of 16:24, 4 November 2023
// syntax highlighter
var syntaxElements = document.querySelectorAll("pre");
// for each element do an action
syntaxElements.forEach(checkSyntax);
function checkSyntax(code) {
// 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>");
}
}