Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leading spaces in multi line props are getting removed #2574

Closed
4 tasks done
GiyoMoon opened this issue Jan 4, 2025 · 3 comments
Closed
4 tasks done

Leading spaces in multi line props are getting removed #2574

GiyoMoon opened this issue Jan 4, 2025 · 3 comments
Labels
🙅 no/wontfix This is not (enough of) an issue for this project 👎 phase/no Post cannot or will not be acted on

Comments

@GiyoMoon
Copy link

GiyoMoon commented Jan 4, 2025

Initial checklist

Affected package

@mdx-js/[email protected]

Steps to reproduce

<MyComponent code={`
No space leading 
  Two spaces leading 
    Four spaces leading
  Two spaces leading
No space leading
`} />
  • Select "show: compiled code"
  • see how 2 spaces got stripped off on every line in the multi line prop
    image

Actual behavior

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

Expected behavior

Spaces should be preserved in multiline props. I noticed this when using mdx with astro and opened an issue there first, but it seems to be a general issue with mdx.

Runtime

playground version

Package manager

playground version

Operating system

playground version

Build and bundle tools

other (please specify in steps to reproduce)

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Jan 4, 2025
@wooorm
Copy link
Member

wooorm commented Jan 4, 2025

Hi! This is intentional. One level of spaces is eaten. Add more.

@wooorm wooorm closed this as completed Jan 4, 2025
@wooorm wooorm added the 🙅 no/wontfix This is not (enough of) an issue for this project label Jan 4, 2025

This comment has been minimized.

@github-actions github-actions bot added 👎 phase/no Post cannot or will not be acted on and removed 🤞 phase/open Post is being triaged manually labels Jan 4, 2025
@wooorm
Copy link
Member

wooorm commented Jan 4, 2025

There was a similar issue 2 months ago or so but I can’t find it.

In short the reasoning: markdown is a whitespace sensitive language. Whitespace has meaning. You will use spaces to indent things whether you like it or not. We will have to deal with indents whether we like it or not. The most reasonable system thus is to allow a level of indent.

A complex scenario to illustrate is:

> *  <MyComponent
      code={`
    a
     b
      c
       d
        e`}
     />

What is the most reasonable?

I think this current rule is as reasonable enough as any / more reasonable than some

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙅 no/wontfix This is not (enough of) an issue for this project 👎 phase/no Post cannot or will not be acted on
Development

No branches or pull requests

2 participants