g-plane / markup_fmt

Configurable HTML, Vue, Svelte, Astro, Angular, Jinja, Twig, Nunjucks and Vento formatter with dprint integration.
https://dprint.dev/plugins/markup_fmt/
MIT License
91 stars 4 forks source link

Something in `dprint` is deleting content #30

Closed horo-fox closed 2 months ago

horo-fox commented 2 months ago

Given the fix for #27 was in 0.10.0, I gave markup_fmt a try on another project. Unfortunately, something in dprint hates a specific comment:

---
({
    // '
})
---

<p>Blah</p>

See dprint playground: https://dprint.dev/playground/#code/LQiwCgAoG8IAgXA9EuByCBfAlBEwIIAeABwD4AhAGwEMALIpcoA/config/N4XyA/plugin/BYFxAcGcC4HpfAGwK4HMCWA7SA6AJuAE5Yj4CmAbrKgLRICGmZsAtvYQNbLgD6AZixA0KABhwBOHGIDu9SCyA (need to switch file extension to .astro)


This probably isn't because of markup_fmt, but that's what lets me use the .astro format so...

g-plane commented 2 months ago

I found this bug was caused by the un-matched single quote. If you add a single quote (to make it match), it will work.

Though it's a bug, the reason is markup_fmt can't parse JS/TS code in Astro frontmatter, and it can't do too much syntax checking. For example, it doesn't know there's a line comment.