From 2b50e1778b164e641c03c2e77176b6f47ca1e278 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 18 Mar 2023 15:47:05 +0900 Subject: refactor: add RawHTML type to represent text node not being escaped --- nuldoc-src/html.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'nuldoc-src/html.ts') diff --git a/nuldoc-src/html.ts b/nuldoc-src/html.ts index 70b5748..b94877a 100644 --- a/nuldoc-src/html.ts +++ b/nuldoc-src/html.ts @@ -115,15 +115,19 @@ function toHtmlText(dom: Document): string { function nodeToHtmlText(n: Node, ctx: Context): string { if (n.kind === "text") { - return textNodeToHtmlText(n, ctx); + if (n.raw) { + return n.content; + } else { + return textNodeToHtmlText(n, ctx); + } } else { return elementNodeToHtmlText(n, ctx); } } function textNodeToHtmlText(t: Text, ctx: Context): string { - if (ctx.isInPre) return t.content; const s = encodeSpecialCharacters(t.content); + if (ctx.isInPre) return s; // TODO: 日本語で改行するときはスペースを入れない return s -- cgit v1.2.3-70-g09d2