summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--vhosts/blog/nuldoc-src/atom/generate.ts3
-rw-r--r--vhosts/blog/nuldoc-src/pages/about.tsx3
-rw-r--r--vhosts/blog/nuldoc-src/pages/home.tsx3
-rw-r--r--vhosts/blog/nuldoc-src/pages/not_found.tsx3
-rw-r--r--vhosts/blog/nuldoc-src/pages/post.tsx4
-rw-r--r--vhosts/blog/nuldoc-src/pages/post_list.tsx3
-rw-r--r--vhosts/blog/nuldoc-src/pages/slide.tsx3
-rw-r--r--vhosts/blog/nuldoc-src/pages/slide_list.tsx3
-rw-r--r--vhosts/blog/nuldoc-src/pages/tag.tsx3
-rw-r--r--vhosts/blog/nuldoc-src/pages/tag_list.tsx3
-rw-r--r--vhosts/blog/nuldoc-src/renderers/html.ts46
-rw-r--r--vhosts/blog/nuldoc-src/renderers/xml.ts45
12 files changed, 54 insertions, 68 deletions
diff --git a/vhosts/blog/nuldoc-src/atom/generate.ts b/vhosts/blog/nuldoc-src/atom/generate.ts
index d98c4c18..9e30ef3e 100644
--- a/vhosts/blog/nuldoc-src/atom/generate.ts
+++ b/vhosts/blog/nuldoc-src/atom/generate.ts
@@ -50,9 +50,8 @@ export function generateFeedPageFromEntries(
entries: entries_,
};
- const xml = buildXmlTree(feed);
return {
- root: el("__root__", {}, xml),
+ root: buildXmlTree(feed),
renderer: "xml",
destFilePath: feedPath,
href: feedPath,
diff --git a/vhosts/blog/nuldoc-src/pages/about.tsx b/vhosts/blog/nuldoc-src/pages/about.tsx
index ea74fa32..91d7fee4 100644
--- a/vhosts/blog/nuldoc-src/pages/about.tsx
+++ b/vhosts/blog/nuldoc-src/pages/about.tsx
@@ -3,7 +3,6 @@ import GlobalHeader from "../components/GlobalHeader.tsx";
import PageLayout from "../components/PageLayout.tsx";
import StaticScript from "../components/StaticScript.tsx";
import { Config } from "../config.ts";
-import { el } from "../dom.ts";
import { renderToDOM } from "../jsx/render.ts";
import { Page } from "../page.ts";
import { dateToString } from "../revision.ts";
@@ -98,7 +97,7 @@ export async function generateAboutPage(
);
return {
- root: el("__root__", {}, html),
+ root: html,
renderer: "html",
destFilePath: "/about/index.html",
href: "/about/",
diff --git a/vhosts/blog/nuldoc-src/pages/home.tsx b/vhosts/blog/nuldoc-src/pages/home.tsx
index 3e79928a..a9a5d542 100644
--- a/vhosts/blog/nuldoc-src/pages/home.tsx
+++ b/vhosts/blog/nuldoc-src/pages/home.tsx
@@ -3,7 +3,6 @@ import { renderToDOM } from "../jsx/render.ts";
import GlobalHeader from "../components/GlobalHeader.tsx";
import PageLayout from "../components/PageLayout.tsx";
import { Config } from "../config.ts";
-import { el } from "../dom.ts";
import { Page } from "../page.ts";
export type HomePage = Page;
@@ -57,7 +56,7 @@ export async function generateHomePage(config: Config): Promise<HomePage> {
);
return {
- root: el("__root__", {}, html),
+ root: html,
renderer: "html",
destFilePath: "/index.html",
href: "/",
diff --git a/vhosts/blog/nuldoc-src/pages/not_found.tsx b/vhosts/blog/nuldoc-src/pages/not_found.tsx
index f0b5f964..27be0738 100644
--- a/vhosts/blog/nuldoc-src/pages/not_found.tsx
+++ b/vhosts/blog/nuldoc-src/pages/not_found.tsx
@@ -3,7 +3,6 @@ import { renderToDOM } from "../jsx/render.ts";
import GlobalHeader from "../components/GlobalHeader.tsx";
import PageLayout from "../components/PageLayout.tsx";
import { Config } from "../config.ts";
-import { el } from "../dom.ts";
import { Page } from "../page.ts";
export type NotFoundPage = Page;
@@ -31,7 +30,7 @@ export async function generateNotFoundPage(
);
return {
- root: el("__root__", {}, html),
+ root: html,
renderer: "html",
destFilePath: "/404.html",
href: "/404.html",
diff --git a/vhosts/blog/nuldoc-src/pages/post.tsx b/vhosts/blog/nuldoc-src/pages/post.tsx
index 529d6738..541c33e3 100644
--- a/vhosts/blog/nuldoc-src/pages/post.tsx
+++ b/vhosts/blog/nuldoc-src/pages/post.tsx
@@ -4,7 +4,7 @@ import GlobalFooter from "../components/GlobalFooter.tsx";
import GlobalHeader from "../components/GlobalHeader.tsx";
import PageLayout from "../components/PageLayout.tsx";
import { Config, getTagLabel } from "../config.ts";
-import { el, Element } from "../dom.ts";
+import { Element } from "../dom.ts";
import { Document } from "../ndoc/document.ts";
import { Page } from "../page.ts";
import { Date, dateToString, Revision } from "../revision.ts";
@@ -108,7 +108,7 @@ export async function generatePostPage(
"index.html",
);
return {
- root: el("__root__", {}, html),
+ root: html,
renderer: "html",
destFilePath: destFilePath,
href: destFilePath.replace("index.html", ""),
diff --git a/vhosts/blog/nuldoc-src/pages/post_list.tsx b/vhosts/blog/nuldoc-src/pages/post_list.tsx
index 2d32636f..3cf17df4 100644
--- a/vhosts/blog/nuldoc-src/pages/post_list.tsx
+++ b/vhosts/blog/nuldoc-src/pages/post_list.tsx
@@ -4,7 +4,6 @@ import GlobalHeader from "../components/GlobalHeader.tsx";
import PageLayout from "../components/PageLayout.tsx";
import PostPageEntry from "../components/PostPageEntry.tsx";
import { Config } from "../config.ts";
-import { el } from "../dom.ts";
import { Page } from "../page.ts";
import { dateToString } from "../revision.ts";
import { getPostPublishedDate, PostPage } from "./post.tsx";
@@ -45,7 +44,7 @@ export async function generatePostListPage(
);
return {
- root: el("__root__", {}, html),
+ root: html,
renderer: "html",
destFilePath: "/posts/index.html",
href: "/posts/",
diff --git a/vhosts/blog/nuldoc-src/pages/slide.tsx b/vhosts/blog/nuldoc-src/pages/slide.tsx
index 4165163a..843f539b 100644
--- a/vhosts/blog/nuldoc-src/pages/slide.tsx
+++ b/vhosts/blog/nuldoc-src/pages/slide.tsx
@@ -5,7 +5,6 @@ import GlobalHeader from "../components/GlobalHeader.tsx";
import PageLayout from "../components/PageLayout.tsx";
import StaticScript from "../components/StaticScript.tsx";
import { Config, getTagLabel } from "../config.ts";
-import { el } from "../dom.ts";
import { Page } from "../page.ts";
import { Date, dateToString, Revision } from "../revision.ts";
import { Slide } from "../slide/slide.ts";
@@ -92,7 +91,7 @@ export async function generateSlidePage(
"index.html",
);
return {
- root: el("__root__", {}, html),
+ root: html,
renderer: "html",
destFilePath: destFilePath,
href: destFilePath.replace("index.html", ""),
diff --git a/vhosts/blog/nuldoc-src/pages/slide_list.tsx b/vhosts/blog/nuldoc-src/pages/slide_list.tsx
index 31eeca68..e42cfcea 100644
--- a/vhosts/blog/nuldoc-src/pages/slide_list.tsx
+++ b/vhosts/blog/nuldoc-src/pages/slide_list.tsx
@@ -4,7 +4,6 @@ import GlobalHeader from "../components/GlobalHeader.tsx";
import PageLayout from "../components/PageLayout.tsx";
import SlidePageEntry from "../components/SlidePageEntry.tsx";
import { Config } from "../config.ts";
-import { el } from "../dom.ts";
import { Page } from "../page.ts";
import { dateToString } from "../revision.ts";
import { getPostPublishedDate } from "./post.tsx";
@@ -46,7 +45,7 @@ export async function generateSlideListPage(
);
return {
- root: el("__root__", {}, html),
+ root: html,
renderer: "html",
destFilePath: "/slides/index.html",
href: "/slides/",
diff --git a/vhosts/blog/nuldoc-src/pages/tag.tsx b/vhosts/blog/nuldoc-src/pages/tag.tsx
index 8dfc9a39..f7df1f13 100644
--- a/vhosts/blog/nuldoc-src/pages/tag.tsx
+++ b/vhosts/blog/nuldoc-src/pages/tag.tsx
@@ -5,7 +5,6 @@ import PageLayout from "../components/PageLayout.tsx";
import PostPageEntry from "../components/PostPageEntry.tsx";
import SlidePageEntry from "../components/SlidePageEntry.tsx";
import { Config, getTagLabel } from "../config.ts";
-import { el } from "../dom.ts";
import { Page } from "../page.ts";
import { getPostPublishedDate } from "./post.tsx";
import { TaggedPage } from "./tagged_page.ts";
@@ -52,7 +51,7 @@ export async function generateTagPage(
);
return {
- root: el("__root__", {}, html),
+ root: html,
renderer: "html",
destFilePath: `/tags/${tagSlug}/index.html`,
href: `/tags/${tagSlug}/`,
diff --git a/vhosts/blog/nuldoc-src/pages/tag_list.tsx b/vhosts/blog/nuldoc-src/pages/tag_list.tsx
index 5ea6f25f..728384f4 100644
--- a/vhosts/blog/nuldoc-src/pages/tag_list.tsx
+++ b/vhosts/blog/nuldoc-src/pages/tag_list.tsx
@@ -3,7 +3,6 @@ import { renderToDOM } from "../jsx/render.ts";
import GlobalHeader from "../components/GlobalHeader.tsx";
import PageLayout from "../components/PageLayout.tsx";
import { Config } from "../config.ts";
-import { el } from "../dom.ts";
import { Page } from "../page.ts";
import { TagPage } from "./tag.tsx";
@@ -61,7 +60,7 @@ export async function generateTagListPage(
);
return {
- root: el("__root__", {}, html),
+ root: html,
renderer: "html",
destFilePath: "/tags/index.html",
href: "/tags/",
diff --git a/vhosts/blog/nuldoc-src/renderers/html.ts b/vhosts/blog/nuldoc-src/renderers/html.ts
index 70d097b2..5f1342f1 100644
--- a/vhosts/blog/nuldoc-src/renderers/html.ts
+++ b/vhosts/blog/nuldoc-src/renderers/html.ts
@@ -3,7 +3,7 @@ import { DocBookError } from "../errors.ts";
export function renderHtml(root: Node): string {
return `<!DOCTYPE html>\n` + nodeToHtmlText(root, {
- indentLevel: -1,
+ indentLevel: 0,
isInPre: false,
});
}
@@ -17,8 +17,6 @@ type Dtd = { type: "block" | "inline"; auto_closing?: boolean };
function getDtd(name: string): Dtd {
switch (name) {
- case "__root__":
- return { type: "block" };
case "a":
return { type: "inline" };
case "article":
@@ -164,29 +162,29 @@ function elementNodeToHtmlText(e: Element, ctx: Context): string {
const dtd = getDtd(e.name);
let s = "";
- if (e.name !== "__root__") {
- if (isBlockNode(e)) {
- s += indent(ctx);
- }
- s += `<${e.name}`;
- const attributes = getElementAttributes(e);
- if (attributes.length > 0) {
- s += " ";
- for (let i = 0; i < attributes.length; i++) {
- const [name, value] = attributes[i];
- s += `${name === "className" ? "class" : name}="${
- encodeSpecialCharacters(value)
- }"`;
- if (i !== attributes.length - 1) {
- s += " ";
- }
+
+ if (isBlockNode(e)) {
+ s += indent(ctx);
+ }
+ s += `<${e.name}`;
+ const attributes = getElementAttributes(e);
+ if (attributes.length > 0) {
+ s += " ";
+ for (let i = 0; i < attributes.length; i++) {
+ const [name, value] = attributes[i];
+ s += `${name === "className" ? "class" : name}="${
+ encodeSpecialCharacters(value)
+ }"`;
+ if (i !== attributes.length - 1) {
+ s += " ";
}
}
- s += ">";
- if (isBlockNode(e) && e.name !== "pre") {
- s += "\n";
- }
}
+ s += ">";
+ if (isBlockNode(e) && e.name !== "pre") {
+ s += "\n";
+ }
+
ctx.indentLevel += 1;
let prevChild: Node | null = null;
@@ -213,7 +211,7 @@ function elementNodeToHtmlText(e: Element, ctx: Context): string {
}
ctx.indentLevel -= 1;
- if (e.name !== "__root__" && !dtd.auto_closing) {
+ if (!dtd.auto_closing) {
if (e.name !== "pre") {
if (isBlockNode(e)) {
if (needsLineBreak(prevChild)) {
diff --git a/vhosts/blog/nuldoc-src/renderers/xml.ts b/vhosts/blog/nuldoc-src/renderers/xml.ts
index 69b8266c..77cc1574 100644
--- a/vhosts/blog/nuldoc-src/renderers/xml.ts
+++ b/vhosts/blog/nuldoc-src/renderers/xml.ts
@@ -2,7 +2,7 @@ import { Element, forEachChild, Node, Text } from "../dom.ts";
export function renderXml(root: Node): string {
return `<?xml version="1.0" encoding="utf-8"?>\n` + nodeToXmlText(root, {
- indentLevel: -1,
+ indentLevel: 0,
});
}
@@ -14,7 +14,6 @@ type Dtd = { type: "block" | "inline" };
function getDtd(name: string): Dtd {
switch (name) {
- case "__root__":
case "feed":
case "entry":
case "author":
@@ -64,24 +63,23 @@ function encodeSpecialCharacters(s: string): string {
function elementNodeToXmlText(e: Element, ctx: Context): string {
let s = "";
- if (e.name !== "__root__") {
- s += indent(ctx);
- s += `<${e.name}`;
- const attributes = getElementAttributes(e);
- if (attributes.length > 0) {
- s += " ";
- for (let i = 0; i < attributes.length; i++) {
- const [name, value] = attributes[i];
- s += `${name}="${encodeSpecialCharacters(value)}"`;
- if (i !== attributes.length - 1) {
- s += " ";
- }
+
+ s += indent(ctx);
+ s += `<${e.name}`;
+ const attributes = getElementAttributes(e);
+ if (attributes.length > 0) {
+ s += " ";
+ for (let i = 0; i < attributes.length; i++) {
+ const [name, value] = attributes[i];
+ s += `${name}="${encodeSpecialCharacters(value)}"`;
+ if (i !== attributes.length - 1) {
+ s += " ";
}
}
- s += ">";
- if (isBlockNode(e)) {
- s += "\n";
- }
+ }
+ s += ">";
+ if (isBlockNode(e)) {
+ s += "\n";
}
ctx.indentLevel += 1;
@@ -90,13 +88,12 @@ function elementNodeToXmlText(e: Element, ctx: Context): string {
});
ctx.indentLevel -= 1;
- if (e.name !== "__root__") {
- if (isBlockNode(e)) {
- s += indent(ctx);
- }
- s += `</${e.name}>`;
- s += "\n";
+ if (isBlockNode(e)) {
+ s += indent(ctx);
}
+ s += `</${e.name}>`;
+ s += "\n";
+
return s;
}