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

🐛 BUG: Cannot handle HTML comments inside conditional blocks #403

Open
dhruvkb opened this issue Jan 11, 2024 · 1 comment
Open

🐛 BUG: Cannot handle HTML comments inside conditional blocks #403

dhruvkb opened this issue Jan 11, 2024 · 1 comment
Labels
- P4: important Violate documented behavior or significantly improves performance (priority) feat: expression Issue related to formatting of expressions

Comments

@dhruvkb
Copy link

dhruvkb commented Jan 11, 2024

Describe the Bug

This plugin raises "Syntax error: Unexpected token" when HTML comments are used in Astro components inside conditional block.

Steps to Reproduce

when formatting this component...

---
const condition = true
---

<div>
  <span>A<!-- A HTML comment --></span>
  {condition && <span>B<!-- A HTML comment --></span>}
</div>

...the following error is raised.

packages/site/src/components/TestComp.astro
[error] packages/site/src/components/TestComp.astro: SyntaxError: Unexpected token (1:25)
[error] > 1 | condition && <span>B<!-- A HTML comment --></span>
[error]     |                         ^
@Princesseuh Princesseuh added - P4: important Violate documented behavior or significantly improves performance (priority) feat: expression Issue related to formatting of expressions labels Jan 11, 2024
@g-plane
Copy link

g-plane commented Mar 6, 2024

What about giving a try to dprint with markup_fmt? markup_fmt can correctly format HTML comments in Astro expressions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P4: important Violate documented behavior or significantly improves performance (priority) feat: expression Issue related to formatting of expressions
Projects
None yet
Development

No branches or pull requests

3 participants