diff options
| author | nsfisis <nsfisis@gmail.com> | 2025-03-29 00:47:55 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2025-03-29 00:55:14 +0900 |
| commit | d30dfc89bf1b673b2fdc0638766b930adaec228c (patch) | |
| tree | 739d8826451947adfeb526ef1adeb1db397a9af4 /vhosts/blog/nuldoc-src/dom.ts | |
| parent | f65ec15aaf8fc46685c39d721cab82f64baead8c (diff) | |
| download | nsfisis.dev-d30dfc89bf1b673b2fdc0638766b930adaec228c.tar.gz nsfisis.dev-d30dfc89bf1b673b2fdc0638766b930adaec228c.tar.zst nsfisis.dev-d30dfc89bf1b673b2fdc0638766b930adaec228c.zip | |
feat(blog/nuldoc): migrate syntax highlighter from highlight.js to shiki.js
Diffstat (limited to 'vhosts/blog/nuldoc-src/dom.ts')
| -rw-r--r-- | vhosts/blog/nuldoc-src/dom.ts | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/vhosts/blog/nuldoc-src/dom.ts b/vhosts/blog/nuldoc-src/dom.ts index 478cbc6c..ed7ffd31 100644 --- a/vhosts/blog/nuldoc-src/dom.ts +++ b/vhosts/blog/nuldoc-src/dom.ts @@ -69,6 +69,15 @@ export function forEachChild(e: Element, f: (n: Node) => void) { } } +export async function forEachChildAsync( + e: Element, + f: (n: Node) => Promise<void>, +): Promise<void> { + for (const c of e.children) { + await f(c); + } +} + export function forEachChildRecursively(e: Element, f: (n: Node) => void) { const g = (c: Node) => { f(c); @@ -78,3 +87,16 @@ export function forEachChildRecursively(e: Element, f: (n: Node) => void) { }; forEachChild(e, g); } + +export async function forEachChildRecursivelyAsync( + e: Element, + f: (n: Node) => Promise<void>, +): Promise<void> { + const g = async (c: Node) => { + await f(c); + if (c.kind === "element") { + await forEachChildAsync(c, g); + } + }; + await forEachChildAsync(e, g); +} |
