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

Formatting an Astro file with ", ', or ` in the component script can clear the file #9

Closed kylemclean closed 7 months ago

kylemclean commented 7 months ago

I formatted the following file, which cleared the entirety of the component script and layout. It seems to have been caused by the "'" in the third line.

Input file index.astro:

---
const a = 1;
const b = "'";
const c = 2;
---

<html></html>

Output file:

---

---

The following input files also result in the same empty output file:

---
//'
---
---
//"
---
---
//`
---

Here is the dprint.json that was used:

{
  "markup": {
  },
  "excludes": [
    "**/node_modules",
    "**/*-lock.json"
  ],
  "plugins": [
    "https://plugins.dprint.dev/g-plane/markup_fmt-v0.5.0.wasm"
  ]
}

The same behavior occurred with the TypeScript plugin added.

g-plane commented 7 months ago

v0.5.1 is released and it fixed this problem. Feel free to open new issues if you find bugs, also don't forget to give it a star and recommend this project to others.