47 tiling
This commit is contained in:
parent
d9b351ad64
commit
0e913e69a0
8 changed files with 246 additions and 38 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue