From 1c3674b52d2b286076146ff1b5b31cbd649d9836 Mon Sep 17 00:00:00 2001 From: TomatoCake <60300461+DEVTomatoCake@users.noreply.github.com> Date: Wed, 24 Jul 2024 19:43:44 +0200 Subject: [PATCH] Fix error for empty typebox --- webpage/markdown.ts | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/webpage/markdown.ts b/webpage/markdown.ts index bfbc07b..e2af933 100644 --- a/webpage/markdown.ts +++ b/webpage/markdown.ts @@ -470,30 +470,28 @@ class MarkDown{ restore(); } static gatherBoxText(element:HTMLElement){ - const children=element.childNodes; if(element.tagName.toLowerCase()==="img"){ return (element as HTMLImageElement).alt; } if(element.tagName.toLowerCase()==="br"){ return "\n"; } - if(children.length!==0){ - let build=""; - for(const thing of children){ - if(thing instanceof Text){ + let build=""; + for(const thing of element.childNodes){ - const text=thing.textContent; - build+=text; - continue; - } - const text=this.gatherBoxText(thing as HTMLElement); - if(text){ - build+=text; - } + if(thing instanceof Text){ + + const text=thing.textContent; + build+=text; + continue; + } + const text=this.gatherBoxText(thing as HTMLElement); + if(text){ + build+=text; } - return build; } + return build; } }