withastro/astro

[@astrojs/mdx] Leading spaces in multi line props are getting removed

GiyoMoon opened this issue · 0 comments

Astro Info

Astro                    v5.0.3
Node                     v22.10.0
System                   macOS (arm64)
Package Manager          pnpm
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

mdx seems to strip off 2 spaces of every line in multi line props:

Inside an .mdx file:

import MyComponent from '../components/MyComponent.astro'

<MyComponent code={`
No space leading 
  Two spaces leading 
    Four spaces leading
  Two spaces leading
No space leading
`} />

Printing the code prop in the MyComponent astro component gives:

No space leading 
Two spaces leading 
  Four spaces leading
Two spaces leading
No space leading

Two spaces are removed from every line.

What's the expected result?

Spaces should be preserved in multiline props.

Link to Minimal Reproducible Example

https://github.com/GiyoMoon/astro-mdx-multiline-string-bug

Participation

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