Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: parsed text placeholders should enter the text state on close qu… #161

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/strong-deers-complain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"htmljs-parser": patch
---

Fixes a regression where the parsed text state (used by eg `script`, `style`) was not properly entering back into text for the closing quote on the string.
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@
│ │╰─ tagName "script"
╰─ ╰─ openTagStart
2╭─ "this is a ${test}"
│ │ │ │ ╰─ text "\"\n \"this is a "
│ │ │ ╰─ placeholder:escape.value "test"
│ │ ╰─ placeholder:escape "${test}"
╰─ ╰─ text "\n \"this is a "
3╭─ "this is a \${test}"
│ │ ╰─ text "${test}\"\n \"/*\"\n \"//\"\n 'this is a "
╰─ ╰─ text "\n \"this is a "
╰─ ╰─ text "${test}\"\n \"/*\"\n \"//\"\n 'this is a "
4├─ "/*"
5├─ "//"
6╭─ 'this is a ${test}'
│ │ │ ╰─ text "'\n 'this is a "
│ │ ╰─ placeholder:escape.value "test"
╰─ ╰─ placeholder:escape "${test}"
7╭─ 'this is a \${test}'
│ │ ╰─ text "${test}'\n '/*'\n '//'\n `this is a ${test}`\n `this is a \\${test}`\n `/*`\n `//`\n"
╰─ ╰─ text "\n 'this is a "
╰─ ╰─ text "${test}'\n '/*'\n '//'\n `this is a ${test}`\n `this is a \\${test}`\n `/*`\n `//`\n"
8├─ '/*'
9├─ '//'
10├─ `this is a ${test}`
Expand Down
1 change: 1 addition & 0 deletions src/states/PARSED_STRING.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const PARSED_STRING: StateDefinition<ParsedStringMeta> = {

char(code, str) {
if (code === str.quoteCharCode) {
this.startText();
this.pos++; // skip end quote
this.exitState();
} else if (!STATE.checkForPlaceholder(this, code)) {
Expand Down