Skip to content

Commit 13a33a3

Browse files
committed
feat: support indented comments outside of a parent tag
1 parent b105718 commit 13a33a3

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

.changeset/warm-olives-warn.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"htmljs-parser": minor
3+
---
4+
5+
Allow indented javascript style comments that are not under a parent tag in concise mode.
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
1╭─ var colors=['red', 'green', 'blue']
1+
1╭─ // I am indented, and that is OK, but the following is not
2+
│ │ ╰─ comment.value " I am indented, and that is OK, but the following is not"
3+
╰─ ╰─ comment "// I am indented, and that is OK, but the following is not"
4+
2╭─ var colors=['red', 'green', 'blue']
25
╰─ ╰─ error(INVALID_INDENTATION:Line has extra indentation at the beginning)
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
// I am indented, and that is OK, but the following is not
12
var colors=['red', 'green', 'blue']

src/states/CONCISE_HTML_CONTENT.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,14 @@ export const CONCISE_HTML_CONTENT: StateDefinition = {
3939
}
4040

4141
if (!parentTag && curIndent) {
42-
this.emitError(
43-
this.pos,
44-
ErrorCode.INVALID_INDENTATION,
45-
"Line has extra indentation at the beginning"
46-
);
47-
return;
42+
if (code !== CODE.FORWARD_SLASH) {
43+
this.emitError(
44+
this.pos,
45+
ErrorCode.INVALID_INDENTATION,
46+
"Line has extra indentation at the beginning"
47+
);
48+
return;
49+
}
4850
}
4951

5052
if (parentTag) {

0 commit comments

Comments
 (0)