aboutsummaryrefslogtreecommitdiffhomepage
path: root/nuldoc-src
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2023-03-15 01:36:13 +0900
committernsfisis <nsfisis@gmail.com>2023-03-15 01:36:58 +0900
commit98682c7a8792e7e79e487fea5024d25cee5aa310 (patch)
treefbf975077f5c1a6ff4f9eee68e4a4908eb7f54a0 /nuldoc-src
parent1fa2ed103dc521698cff261c97ecf275708be58c (diff)
downloadblog.nsfisis.dev-98682c7a8792e7e79e487fea5024d25cee5aa310.tar.gz
blog.nsfisis.dev-98682c7a8792e7e79e487fea5024d25cee5aa310.tar.zst
blog.nsfisis.dev-98682c7a8792e7e79e487fea5024d25cee5aa310.zip
fix(nuldoc): <pre> contained unnecessary whitespaces inside it
Diffstat (limited to 'nuldoc-src')
-rw-r--r--nuldoc-src/html.ts14
1 files changed, 8 insertions, 6 deletions
diff --git a/nuldoc-src/html.ts b/nuldoc-src/html.ts
index 2832490..5e573ad 100644
--- a/nuldoc-src/html.ts
+++ b/nuldoc-src/html.ts
@@ -160,7 +160,7 @@ function elementNodeToHtmlText(e: Element, ctx: Context): string {
}
}
s += ">";
- if (dtd.type === "block") {
+ if (dtd.type === "block" && e.name !== "pre") {
s += "\n";
}
}
@@ -171,7 +171,7 @@ function elementNodeToHtmlText(e: Element, ctx: Context): string {
ctx.isInPre = true;
}
forEachChild(e, (c) => {
- if (dtd.type === "block") {
+ if (dtd.type === "block" && !ctx.isInPre) {
if (isInlineNode(c)) {
if (needsIndent(prevChild)) {
s += indent(ctx);
@@ -191,11 +191,13 @@ function elementNodeToHtmlText(e: Element, ctx: Context): string {
ctx.indentLevel -= 1;
if (e.name !== "__root__" && !dtd.auto_closing) {
- if (dtd.type === "block") {
- if (needsLineBreak(prevChild)) {
- s += "\n";
+ if (e.name !== "pre") {
+ if (dtd.type === "block") {
+ if (needsLineBreak(prevChild)) {
+ s += "\n";
+ }
+ s += indent(ctx);
}
- s += indent(ctx);
}
s += `</${e.name}>`;
if (dtd.type === "block") {