Skip to content

@astrojs/mdx: “smart quotes” are broken in HTML headers #10859

@johnnydecimal

Description

@johnnydecimal

Astro Info

Astro                    v4.6.4
Node                     v21.7.1
System                   macOS (arm64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             @astrojs/mdx
                         @astrojs/sitemap

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

No response

Describe the Bug

When Astro renders an MDX page where a header contains "quotes", the rendering of ”smart quotes” in the output is broken: both quotes are rendered as the closing quote.

To reproduce

  1. Create a new project using the blog template, npm create astro@latest.
  2. Edit /src/content/blog/using-mdx.mdx, line 10, to include double-straight-quotes: ## "Why MDX?".
  3. npm run build.
  4. The source of the built page contains incorrect quotes, <h2 id="why-mdx">”Why MDX?”</h2>.

This is much more apparent when one uses a font with highly-stylised quotes. See my built page here for an example.

What's the expected result?

The header currently looks like this:

”Incorrect quotes”

It should look like this:

“Correct quotes”

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-vngmzc?file=src%2Fcontent%2Fblog%2Fusing-mdx.mdx

Participation

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageIssue needs to be triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions