diff options
| author | nsfisis <nsfisis@gmail.com> | 2023-03-18 15:47:05 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2023-03-18 15:47:05 +0900 |
| commit | 2b50e1778b164e641c03c2e77176b6f47ca1e278 (patch) | |
| tree | 3fa48f5c5c3c2b9d8753ce82d438aa2523856660 /nuldoc-src/html.ts | |
| parent | 4ce1f674055ac1dd1c4864f366aac212f5643248 (diff) | |
| download | blog.nsfisis.dev-2b50e1778b164e641c03c2e77176b6f47ca1e278.tar.gz blog.nsfisis.dev-2b50e1778b164e641c03c2e77176b6f47ca1e278.tar.zst blog.nsfisis.dev-2b50e1778b164e641c03c2e77176b6f47ca1e278.zip | |
refactor: add RawHTML type to represent text node not being escaped
Diffstat (limited to 'nuldoc-src/html.ts')
| -rw-r--r-- | nuldoc-src/html.ts | 8 |
1 files changed, 6 insertions, 2 deletions
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 |
