47 tiling

This commit is contained in:
りき萌 2024-02-17 21:03:45 +01:00
parent d9b351ad64
commit 0e913e69a0
8 changed files with 246 additions and 38 deletions

View file

@ -58,7 +58,7 @@ function tokenize(text, syntax) {
return tokens;
}
export function highlight(element, syntax) {
export function highlight(element, syntax, customize = null) {
let tokens = tokenize(element.textContent, syntax);
element.textContent = "";
@ -67,6 +67,9 @@ export function highlight(element, syntax) {
let span = document.createElement("span");
span.textContent = token.string;
span.classList.add(token.kind);
if (customize != null) {
customize(token, span);
}
element.appendChild(span);
}
}