aboutsummaryrefslogtreecommitdiffhomepage
path: root/services/nuldoc/nuldoc-src/markdown/to_html.ts
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-11-27 06:29:01 +0900
committernsfisis <nsfisis@gmail.com>2025-11-27 06:29:01 +0900
commit83b1286354e0f5e83927c8fb35a584e587b5530b (patch)
treef8771f7808cd68b295c9e57051b7604de15fe8c8 /services/nuldoc/nuldoc-src/markdown/to_html.ts
parent327622573dcb8879b9dba934792403a9fb7239a7 (diff)
downloadnsfisis.dev-83b1286354e0f5e83927c8fb35a584e587b5530b.tar.gz
nsfisis.dev-83b1286354e0f5e83927c8fb35a584e587b5530b.tar.zst
nsfisis.dev-83b1286354e0f5e83927c8fb35a584e587b5530b.zip
refactor(nuldoc): Refactor elem()
Diffstat (limited to 'services/nuldoc/nuldoc-src/markdown/to_html.ts')
-rw-r--r--services/nuldoc/nuldoc-src/markdown/to_html.ts21
1 files changed, 9 insertions, 12 deletions
diff --git a/services/nuldoc/nuldoc-src/markdown/to_html.ts b/services/nuldoc/nuldoc-src/markdown/to_html.ts
index 8219b74..8758b0d 100644
--- a/services/nuldoc/nuldoc-src/markdown/to_html.ts
+++ b/services/nuldoc/nuldoc-src/markdown/to_html.ts
@@ -2,8 +2,9 @@ import { BundledLanguage, bundledLanguages, codeToHtml } from "shiki";
import { Document, TocEntry } from "./document.ts";
import { NuldocError } from "../errors.ts";
import {
+ a,
addClass,
- elem,
+ div,
Element,
forEachChild,
forEachChildRecursively,
@@ -115,7 +116,7 @@ function transformLinkLikeToAnchorElement(doc: Document) {
}
const [_, prefix, url, suffix] = match;
nodes.push(text(prefix));
- nodes.push(elem("a", { href: url, class: "url" }, text(url)));
+ nodes.push(a({ href: url, class: "url" }, text(url)));
restContent = suffix;
}
return nodes;
@@ -188,7 +189,7 @@ function setSectionTitleAnchor(doc: Document) {
);
}
const sectionId = currentSection.attributes.id;
- const aElement = elem("a", undefined, ...c.children);
+ const aElement = a(undefined, ...c.children);
aElement.attributes.href = `#${sectionId}`;
c.children = [aElement];
}
@@ -224,13 +225,11 @@ function transformNoteElement(doc: Document) {
const operationAttr = n.attributes?.operation;
const isEditBlock = editatAttr && operationAttr;
- const labelElement = elem(
- "div",
+ const labelElement = div(
{ class: "admonition-label" },
text(isEditBlock ? `${editatAttr} ${operationAttr}` : "NOTE"),
);
- const contentElement = elem(
- "div",
+ const contentElement = div(
{ class: "admonition-content" },
...n.children,
);
@@ -273,8 +272,7 @@ function traverseFootnotes(doc: Document) {
delete n.attributes.reference;
n.attributes.class = "footnote";
n.children = [
- elem(
- "a",
+ a(
{
id: `footnoteref--${reference}`,
class: "footnote",
@@ -301,8 +299,7 @@ function traverseFootnotes(doc: Document) {
n.attributes.id = `footnote--${id}`;
n.children = [
- elem(
- "a",
+ a(
{ href: `#footnoteref--${id}` },
text(`${footnoteNumber}. `),
),
@@ -373,7 +370,7 @@ async function transformAndHighlightCodeBlockElement(doc: Document) {
delete n.attributes.filename;
n.children = [
- elem("div", { class: "filename" }, text(filename)),
+ div({ class: "filename" }, text(filename)),
rawHTML(highlighted),
];
} else {