withastro / prettier-plugin-astro

Prettier plugin for Astro
Other
479 stars 36 forks source link

🐛 BUG: inserts space between pre and code, breaks file #419

Closed hyperknot closed 4 months ago

hyperknot commented 4 months ago

Describe the Bug

It inserts a newline / space between pre and code tags when inside an if-block.

Steps to Reproduce

This is still formatted correctly:

<>
  <pre
    id="style-url-pre"><code id="style-url-code">https://tiles.openfreemap.org/styles/liberty</code></pre>
</>

But if I put it inside an if-block, it breaks the DOM:

{
  showStyleURL && (
    <>
      <pre id="style-url-pre">
        <code id="style-url-code">https://tiles.openfreemap.org/styles/liberty</code>
      </pre>
    </>
  )
}
Princesseuh commented 4 months ago

Duplicate of https://github.com/withastro/prettier-plugin-astro/issues/308

hyperknot commented 4 months ago

And with both of my issues closed, could you help me how can I possibly have this code working?

{
  showStyleURL && (
    <pre id="style-url-pre"><code id="style-url-code">https://tiles.openfreemap.org/styles/liberty</code></pre>
  )
}

<script is:inline src="https://unpkg.com/maplibre-gl/dist/maplibre-gl.js"></script>