From 98682c7a8792e7e79e487fea5024d25cee5aa310 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Wed, 15 Mar 2023 01:36:13 +0900 Subject: fix(nuldoc):
 contained unnecessary whitespaces inside it

---
 nuldoc-src/html.ts | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

(limited to 'nuldoc-src')

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 += ``;
     if (dtd.type === "block") {
-- 
cgit v1.2.3-70-g09d2