summaryrefslogtreecommitdiffhomepage
path: root/services/blog/nuldoc-src/renderers/xml.ts
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2025-07-04 19:21:01 +0900
committernsfisis <nsfisis@gmail.com>2025-07-04 19:21:01 +0900
commit76660a3b367f38ed554d32ec20dbe7a1fd39f470 (patch)
tree3ea11251abc063ba8c71da2a6ad7123f71685f32 /services/blog/nuldoc-src/renderers/xml.ts
parent6b78b4de6ec5f96d82be5b153294797074c8c2b1 (diff)
downloadnsfisis.dev-76660a3b367f38ed554d32ec20dbe7a1fd39f470.tar.gz
nsfisis.dev-76660a3b367f38ed554d32ec20dbe7a1fd39f470.tar.zst
nsfisis.dev-76660a3b367f38ed554d32ec20dbe7a1fd39f470.zip
refactor(blog/nuldoc): refactor DOM-related code
Diffstat (limited to 'services/blog/nuldoc-src/renderers/xml.ts')
-rw-r--r--services/blog/nuldoc-src/renderers/xml.ts14
1 files changed, 6 insertions, 8 deletions
diff --git a/services/blog/nuldoc-src/renderers/xml.ts b/services/blog/nuldoc-src/renderers/xml.ts
index 77cc1574..523567ab 100644
--- a/services/blog/nuldoc-src/renderers/xml.ts
+++ b/services/blog/nuldoc-src/renderers/xml.ts
@@ -24,7 +24,7 @@ function getDtd(name: string): Dtd {
}
function isInlineNode(n: Node): boolean {
- if (n.kind === "text") {
+ if (n.kind === "text" || n.kind === "raw") {
return true;
}
return getDtd(n.name).type === "inline";
@@ -36,11 +36,9 @@ function isBlockNode(n: Node): boolean {
function nodeToXmlText(n: Node, ctx: Context): string {
if (n.kind === "text") {
- if (n.raw) {
- return n.content;
- } else {
- return textNodeToXmlText(n);
- }
+ return textNodeToXmlText(n);
+ } else if (n.kind === "raw") {
+ return n.html;
} else {
return elementNodeToXmlText(n, ctx);
}
@@ -102,8 +100,8 @@ function indent(ctx: Context): string {
}
function getElementAttributes(e: Element): [string, string][] {
- return [...e.attributes.entries()]
- .filter((a) => !a[0].startsWith("--"))
+ return [...Object.entries(e.attributes)]
+ .filter((a) => !a[0].startsWith("__"))
.sort(
(a, b) => {
// Special rules: