summaryrefslogtreecommitdiffhomepage
path: root/vhosts/blog/nuldoc-src/dom.ts
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-03-29 00:47:55 +0900
committernsfisis <nsfisis@gmail.com>2025-03-29 00:55:14 +0900
commitd30dfc89bf1b673b2fdc0638766b930adaec228c (patch)
tree739d8826451947adfeb526ef1adeb1db397a9af4 /vhosts/blog/nuldoc-src/dom.ts
parentf65ec15aaf8fc46685c39d721cab82f64baead8c (diff)
downloadnsfisis.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.ts22
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);
+}