From 1118b076dd3350165987f04ce63daa2654047118 Mon Sep 17 00:00:00 2001 From: dpiercey Date: Mon, 2 Mar 2026 08:27:13 -0700 Subject: [PATCH] fix: incorrect whitespace removal in concise mode html blocks --- .changeset/metal-bobcats-bathe.md | 5 ++++ .../argument-tag-nested-parens.expected.txt | 1 + .../mixed-block-root.expected.txt | 29 +++++++++++++++++++ .../fixtures/mixed-block-root/input.marko | 11 +++++++ .../multiline-html-block.expected.txt | 2 +- .../open-tag-only-with-body.expected.txt | 2 +- src/states/BEGIN_DELIMITED_HTML_BLOCK.ts | 2 ++ 7 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 .changeset/metal-bobcats-bathe.md create mode 100644 src/__tests__/fixtures/mixed-block-root/__snapshots__/mixed-block-root.expected.txt create mode 100644 src/__tests__/fixtures/mixed-block-root/input.marko diff --git a/.changeset/metal-bobcats-bathe.md b/.changeset/metal-bobcats-bathe.md new file mode 100644 index 00000000..06ef0f93 --- /dev/null +++ b/.changeset/metal-bobcats-bathe.md @@ -0,0 +1,5 @@ +--- +"htmljs-parser": patch +--- + +Fix regression which incorrectly removed some whitespace in concise mode html blocks. diff --git a/src/__tests__/fixtures/argument-tag-nested-parens/__snapshots__/argument-tag-nested-parens.expected.txt b/src/__tests__/fixtures/argument-tag-nested-parens/__snapshots__/argument-tag-nested-parens.expected.txt index ba5b451e..a6c4384a 100644 --- a/src/__tests__/fixtures/argument-tag-nested-parens/__snapshots__/argument-tag-nested-parens.expected.txt +++ b/src/__tests__/fixtures/argument-tag-nested-parens/__snapshots__/argument-tag-nested-parens.expected.txt @@ -8,5 +8,6 @@ 3╭─ │ │ │ ╰─ closeTagEnd(if) │ │ ╰─ closeTagName "if" + │ ├─ text "\n" ╰─ ╰─ closeTagStart " + │ ││ ╰─ openTagEnd + │ │╰─ tagName "div" + ╰─ ╰─ openTagStart +4╭─ 2 + ╰─ ╰─ text "\n 2\n" +5╭─ + │ │ │ ╰─ closeTagEnd(div) + │ │ ╰─ closeTagName "div" + ╰─ ╰─ closeTagStart " + │ ││ ╰─ openTagEnd + │ │╰─ tagName "div" + ╰─ ╰─ openTagStart +8╭─ 4 + ╰─ ╰─ text "\n 4\n" +9╭─ + │ │ │ ╰─ closeTagEnd(div) + │ │ ╰─ closeTagName "div" + ╰─ ╰─ closeTagStart " + 2 + +3 +
+ 4 +
+5 +--- diff --git a/src/__tests__/fixtures/multiline-html-block/__snapshots__/multiline-html-block.expected.txt b/src/__tests__/fixtures/multiline-html-block/__snapshots__/multiline-html-block.expected.txt index bf19c0ee..62701200 100644 --- a/src/__tests__/fixtures/multiline-html-block/__snapshots__/multiline-html-block.expected.txt +++ b/src/__tests__/fixtures/multiline-html-block/__snapshots__/multiline-html-block.expected.txt @@ -9,5 +9,5 @@ │ │ ╰─ openTagStart ╰─ ╰─ text "Hello " 3╭─ Line 2 - ╰─ ╰─ text "Line 2" + ╰─ ╰─ text "\nLine 2" 4╰─ --- \ No newline at end of file diff --git a/src/__tests__/fixtures/open-tag-only-with-body/__snapshots__/open-tag-only-with-body.expected.txt b/src/__tests__/fixtures/open-tag-only-with-body/__snapshots__/open-tag-only-with-body.expected.txt index b78d932e..d6dc0d95 100644 --- a/src/__tests__/fixtures/open-tag-only-with-body/__snapshots__/open-tag-only-with-body.expected.txt +++ b/src/__tests__/fixtures/open-tag-only-with-body/__snapshots__/open-tag-only-with-body.expected.txt @@ -7,7 +7,7 @@ │ │╰─ tagName "img" ╰─ ╰─ openTagStart 3╭─ This is not allowed! - ╰─ ╰─ text " This is not allowed!\n" + ╰─ ╰─ text "\n This is not allowed!\n" 4╭─ │ ├─ error(EXTRA_CLOSING_TAG:The closing "img" tag was not expected) "" ╰─ ╰─ closeTagStart "