Skip to content

Commit

Permalink
feat: support indented comments outside of a parent tag
Browse files Browse the repository at this point in the history
  • Loading branch information
DylanPiercey committed May 26, 2023
1 parent b105718 commit 13a33a3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/warm-olives-warn.md
@@ -0,0 +1,5 @@
---
"htmljs-parser": minor
---

Allow indented javascript style comments that are not under a parent tag in concise mode.
@@ -1,2 +1,5 @@
1╭─ var colors=['red', 'green', 'blue']
1╭─ // I am indented, and that is OK, but the following is not
│ │ ╰─ comment.value " I am indented, and that is OK, but the following is not"
╰─ ╰─ comment "// I am indented, and that is OK, but the following is not"
2╭─ var colors=['red', 'green', 'blue']
╰─ ╰─ error(INVALID_INDENTATION:Line has extra indentation at the beginning)
1 change: 1 addition & 0 deletions src/__tests__/fixtures/bad-tag-indent/input.marko
@@ -1 +1,2 @@
// I am indented, and that is OK, but the following is not
var colors=['red', 'green', 'blue']
14 changes: 8 additions & 6 deletions src/states/CONCISE_HTML_CONTENT.ts
Expand Up @@ -39,12 +39,14 @@ export const CONCISE_HTML_CONTENT: StateDefinition = {
}

if (!parentTag && curIndent) {
this.emitError(
this.pos,
ErrorCode.INVALID_INDENTATION,
"Line has extra indentation at the beginning"
);
return;
if (code !== CODE.FORWARD_SLASH) {
this.emitError(
this.pos,
ErrorCode.INVALID_INDENTATION,
"Line has extra indentation at the beginning"
);
return;
}
}

if (parentTag) {
Expand Down

0 comments on commit 13a33a3

Please sign in to comment.