withastro / language-tools

Language tools for Astro
MIT License
240 stars 45 forks source link

🐛 BUG: Missing trailing backslash in void elements breaks code highlighting when inside a map method #852

Closed Axelgustavschnurer closed 2 months ago

Axelgustavschnurer commented 2 months ago

Describe the Bug

As title suggests, using a void element such as
without a trailing backslash and within a map method causes syntax highlighting to break. Example in the code below:

---
let data = [
  'string 1',
  'string 2',
  'string 3'
]
---

<html lang="en">
  <head>
    <meta charset="utf-8" />
    <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
    <meta name="viewport" content="width=device-width" />
    <meta name="generator" content={Astro.generator} />
    <title>Astro</title>
  </head>
    <body>
      <h1>Astro</h1>
        {data.map(element => (
      <p>{element}</p><br>
        ))}
  </body>
</html>

Steps to Reproduce

  1. npm create astro@latest
  2. Create an array
  3. Use the map method to map the array
  4. Use any void element without a trailing backslash in the map method, ex.
    , or
  5. The syntax highlighting for the map function aswell as some closing html tags beneath the void element breaks.
  6. The expected behavior should be that the void element behaves as it does outside the mapping function, where the lack of a trailing backslash does not cause the syntax highlighting to break.
Princesseuh commented 2 months ago

Duplicate of https://github.com/withastro/language-tools/issues/708