diff --git a/.changeset/funny-pens-peel.md b/.changeset/funny-pens-peel.md new file mode 100644 index 00000000..2116b2a1 --- /dev/null +++ b/.changeset/funny-pens-peel.md @@ -0,0 +1,5 @@ +--- +"htmljs-parser": patch +--- + +Fix regexp charset parsing issue. diff --git a/src/__tests__/fixtures/attr-regex-character-classes/__snapshots__/attr-regex-character-classes.expected.txt b/src/__tests__/fixtures/attr-regex-character-classes/__snapshots__/attr-regex-character-classes.expected.txt new file mode 100644 index 00000000..24288051 --- /dev/null +++ b/src/__tests__/fixtures/attr-regex-character-classes/__snapshots__/attr-regex-character-classes.expected.txt @@ -0,0 +1,51 @@ +1╭─
+ │ ││ │ ││ ││ │ ╰─ closeTagEnd(div) + │ ││ │ ││ ││ ╰─ closeTagName "div" + │ ││ │ ││ │╰─ closeTagStart "" + │ ││ │ ││ ╰─ openTagEnd + │ ││ │ │╰─ attrValue.value "/[abc/] /" + │ ││ │ ╰─ attrValue "=/[abc/] /" + │ ││ ╰─ attrName "pattern" + │ │╰─ tagName "div" + ╰─ ╰─ openTagStart +2╭─ + │ ││ │ ││ ││ │ ╰─ closeTagEnd(div) + │ ││ │ ││ ││ ╰─ closeTagName "div" + │ ││ │ ││ │╰─ closeTagStart "" + │ ││ │ ││ ╰─ openTagEnd + │ ││ │ │╰─ attrValue.value "/[a-z/] /" + │ ││ │ ╰─ attrValue "=/[a-z/] /" + │ ││ ╰─ attrName "pattern" + │ │╰─ tagName "div" + ╰─ ╰─ openTagStart +3╭─ + │ ││ │ ││ ││ │ ╰─ closeTagEnd(div) + │ ││ │ ││ ││ ╰─ closeTagName "div" + │ ││ │ ││ │╰─ closeTagStart "" + │ ││ │ ││ ╰─ openTagEnd + │ ││ │ │╰─ attrValue.value "/[^abc/] /" + │ ││ │ ╰─ attrValue "=/[^abc/] /" + │ ││ ╰─ attrName "pattern" + │ │╰─ tagName "div" + ╰─ ╰─ openTagStart +4╭─ + │ ││ │ ││ ││ │ ╰─ closeTagEnd(div) + │ ││ │ ││ ││ ╰─ closeTagName "div" + │ ││ │ ││ │╰─ closeTagStart "" + │ ││ │ ││ ╰─ openTagEnd + │ ││ │ │╰─ attrValue.value "/[a\\]b/] /" + │ ││ │ ╰─ attrValue "=/[a\\]b/] /" + │ ││ ╰─ attrName "pattern" + │ │╰─ tagName "div" + ╰─ ╰─ openTagStart +5╭─ + │ ││ │ ││ ││ │ ╰─ closeTagEnd(div) + │ ││ │ ││ ││ ╰─ closeTagName "div" + │ ││ │ ││ │╰─ closeTagStart "" + │ ││ │ ││ ╰─ openTagEnd + │ ││ │ │╰─ attrValue.value "/[\\w\\s/] /" + │ ││ │ ╰─ attrValue "=/[\\w\\s/] /" + │ ││ ╰─ attrName "pattern" + │ │╰─ tagName "div" + ╰─ ╰─ openTagStart +6╰─ \ No newline at end of file diff --git a/src/__tests__/fixtures/attr-regex-character-classes/input.marko b/src/__tests__/fixtures/attr-regex-character-classes/input.marko new file mode 100644 index 00000000..e8649cd6 --- /dev/null +++ b/src/__tests__/fixtures/attr-regex-character-classes/input.marko @@ -0,0 +1,5 @@ + + + + + diff --git a/src/states/REGULAR_EXPRESSION.ts b/src/states/REGULAR_EXPRESSION.ts index 7afaa523..3432e301 100644 --- a/src/states/REGULAR_EXPRESSION.ts +++ b/src/states/REGULAR_EXPRESSION.ts @@ -18,16 +18,23 @@ export const REGULAR_EXPRESSION: StateDefinition