Skip to content
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/semicolon-html-comment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"htmljs-parser": minor
---

Report code after an html comment that follows a concise `;` (eg `div; <!-- a --> span`) as an error, as after any other comment there, instead of reading it as a new line nested in the tag. More comments may still follow.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
1╭─ div; <!-- a --> <!-- b --> // c
│ │ ││ │ │ │ │ ╰─ comment.value " c"
│ │ ││ │ │ │ ╰─ comment "// c"
│ │ ││ │ │ ╰─ comment.value " b "
│ │ ││ │ ╰─ comment "<!-- b -->"
│ │ ││ ╰─ comment.value " a "
│ │ │╰─ comment "<!-- a -->"
│ │ ╰─ openTagEnd
╰─ ╰─ tagName "div"
2╭─ span; <!-- d --> p
│ │ ││ │ ╰─ error(INVALID_CODE_AFTER_SEMICOLON:A semicolon indicates the end of a line. Only comments may follow it.)
│ │ ││ ╰─ comment.value " d "
│ │ │╰─ comment "<!-- d -->"
│ │ ╰─ openTagEnd
│ ├─ closeTagEnd(div)
╰─ ╰─ tagName "span"
3╰─
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
div; <!-- a --> <!-- b --> // c
span; <!-- d --> p
5 changes: 5 additions & 0 deletions src/states/CONCISE_HTML_CONTENT.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,11 @@ export const CONCISE_HTML_CONTENT: StateDefinition = {

break;
}
case STATE.HTML_COMMENT:
// Only reached after a ";" (a line starting with "<" is an html
// block), so only comments may follow it either.
STATE.endConciseLine(this, this.data);
break;
}
},
};
Loading