withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!
https://astro.build
Other
45.68k stars 2.4k forks source link

MDX closing tag bug #10318

Closed theRealProHacker closed 6 months ago

theRealProHacker commented 6 months ago

Astro Info

Astro                    v4.2.1
Node                     v21.6.0
System                   Windows (x64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             @astrojs/mdx

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

I have an Astro component Abbr which I use in an MDX file, I use the Astro component as explained in https://docs.astro.build/en/guides/markdown-content/#using-components-in-mdx:

---
lang: "en"
--- 

import Abbr from '../../components/Abbr.astro'

<br>
<Abbr e="Natural Language Processing">NLP</Abbr>

The resulting error stack trace is:

MDXError: Expected a closing tag for `</Abbr>` (26:1-26:5)
    at TransformContext.transform (file:///C:/Users/Rashid/Desktop/Programmieren/personal-website/node_modules/@astrojs/mdx/dist/index.js:92:27)
    at async Object.transform (file:///C:/Users/Rashid/Desktop/Programmieren/personal-website/node_modules/astro/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:64063:30)
    at async loadAndTransform (file:///C:/Users/Rashid/Desktop/Programmieren/personal-website/node_modules/astro/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:49741:29)
    at async instantiateModule (file:///C:/Users/Rashid/Desktop/Programmieren/personal-website/node_modules/astro/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:50759:10)

What's the expected result?

The expected result should be that the <br> is auto-closed. Another acceptable but not desired result is an error that tells me that the <br> is not closed.

There are several hints. For example, it is clear that </Abbr> is a closing tag and so the error simply logically makes no sense: A closing tag can impossibly be missing a closing tag.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-ojtesw?file=src%2Fpages%2Findex.mdx

Participation

matthewp commented 6 months ago

Auto-closing tags are not supported in mdx. You can go to mdxjs.com/playground and test it out, you get the same error you're reporting here.

theRealProHacker commented 6 months ago

Sorry, but this doesn't seem satisfactory to me. I explicitly said that auto-closing would be cool, but the minimum is to get a good error. That is the real issue, not that it doesn't auto-close, but I can also open an issue with MDX if that is necessary

theRealProHacker commented 6 months ago

I filed an issue with MDX as this is clearly an issue with MDX: https://github.com/mdx-js/mdx/issues/2451