diff --git a/.changeset/gorgeous-laws-grin.md b/.changeset/gorgeous-laws-grin.md new file mode 100644 index 00000000..af8281ff --- /dev/null +++ b/.changeset/gorgeous-laws-grin.md @@ -0,0 +1,5 @@ +--- +"htmljs-parser": patch +--- + +Fix regression that causes incorrect expression continuations after regexps. diff --git a/src/__tests__/fixtures/attr-regexp/__snapshots__/attr-regexp.expected.txt b/src/__tests__/fixtures/attr-regexp/__snapshots__/attr-regexp.expected.txt new file mode 100644 index 00000000..ccbdc2c3 --- /dev/null +++ b/src/__tests__/fixtures/attr-regexp/__snapshots__/attr-regexp.expected.txt @@ -0,0 +1,10 @@ +1╭─ + │ ││ │ ││ │ ││ ╰─ openTagEnd + │ ││ │ ││ │ │╰─ attrValue.value "\"test\"" + │ ││ │ ││ │ ╰─ attrValue "=\"test\"" + │ ││ │ ││ ╰─ attrName "name" + │ ││ │ │╰─ attrValue.value "/\\s*?\\S+\\s*?/" + │ ││ │ ╰─ attrValue "=/\\s*?\\S+\\s*?/" + │ ││ ╰─ attrName "pattern" + │ │╰─ tagName "input" + ╰─ ╰─ openTagStart \ No newline at end of file diff --git a/src/__tests__/fixtures/attr-regexp/input.marko b/src/__tests__/fixtures/attr-regexp/input.marko new file mode 100644 index 00000000..5eabfe83 --- /dev/null +++ b/src/__tests__/fixtures/attr-regexp/input.marko @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/__tests__/fixtures/comments-within-open-tag/__snapshots__/comments-within-open-tag.expected.txt b/src/__tests__/fixtures/comments-within-open-tag/__snapshots__/comments-within-open-tag.expected.txt index 0c89d8d0..5649bbd5 100644 --- a/src/__tests__/fixtures/comments-within-open-tag/__snapshots__/comments-within-open-tag.expected.txt +++ b/src/__tests__/fixtures/comments-within-open-tag/__snapshots__/comments-within-open-tag.expected.txt @@ -3,23 +3,23 @@ │ ││ │ ││ │ ││ ││ ╰─ closeTagName "div" │ ││ │ ││ │ ││ │╰─ closeTagStart "" │ ││ │ ││ │ ││ ╰─ openTagEnd - │ ││ │ ││ │ │╰─ attrValue.value "\"world\"" - │ ││ │ ││ │ ╰─ attrValue "=\"world\"" + │ ││ │ ││ │ │╰─ attrValue.value "\"world\" /* this is another comment */" + │ ││ │ ││ │ ╰─ attrValue "=\"world\" /* this is another comment */" │ ││ │ ││ ╰─ attrName "hello" - │ ││ │ │╰─ attrValue.value "\"bar\"" - │ ││ │ ╰─ attrValue "=\"bar\"" + │ ││ │ │╰─ attrValue.value "\"bar\" /*this is a comment*/" + │ ││ │ ╰─ attrValue "=\"bar\" /*this is a comment*/" │ ││ ╰─ attrName "foo" │ │╰─ tagName "div" ╰─ ╰─ openTagStart 2╭─
│ ││ │ ╰─ closeTagEnd(div) diff --git a/src/states/EXPRESSION.ts b/src/states/EXPRESSION.ts index d8819e17..5fa20467 100644 --- a/src/states/EXPRESSION.ts +++ b/src/states/EXPRESSION.ts @@ -87,10 +87,13 @@ export const EXPRESSION: StateDefinition