Skip to content

Improperly escaped code block in MDXError message #15068

@kylejrp

Description

@kylejrp

Astro Info

Astro                    v5.16.6
Vite                     v6.4.1
Node                     v25.2.1
System                   Windows (x64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             @astrojs/mdx (v4.3.13)
                         @astrojs/svelte (v7.2.4)
                         @astrojs/sitemap (v3.6.0)

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

No response

Describe the Bug

I was porting over a markdown file from Eleventy to a MDX file in Astro, and one of the lines was:

- <https://example.com> - Auto-linked URL

This works in Markdown but not MDX, and it correctly throws an error message. However, the error message is garbled at the end:

Unexpected character / (U+002F) before local name, expected a character that can start a name, such as a letter, $, or _ (note: to create a link in MDX, use [text](http://localhost:4321/url)%3C/code%3E)

Which gets rendered as:
Image

(Note the markdown at the end is rendered as just text and does not show the full intended link syntax. The text link points incorrectly to http://localhost:4321/url)%3C/code%3E).

What's the expected result?

The error message should correctly show the intended syntax for a link instead of just rendering as a text link. Something like this:

Image

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-ew5zyahs?file=src%2Fcontent%2Fblog%2Fbroken-post.mdx

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    - P2: nice to haveNot breaking anything but nice to have (priority)feat: errorsRelated to error handling / messages (scope)good first issueGood for newcomers. If you need additional guidance, feel free to post in #contribute on Discord

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions