question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Line breaks in block-level JSX create unexpected whitespace in the output

See original GitHub issue

Subject of the issue

As we’re trying to improve Prettier’s support of MDX, I’m trying to understand its syntax better. So far it looked like block-level JSX is supposed to be 100% React-compatible for it to be possible to copy-paste React code from JS to MDX (also it would allow Prettier to use the same code for formatting JSX that it uses for JSX in JS). But I found an incompatibility that breaks this use case, namely: a line break between an element and text doesn’t create whitespace in the output in React but does in MDX. Posting here after asking on Spectrum.

Your environment

The official playground https://mdxjs.com/playground/

Steps to reproduce

<b>foo</b>
bar

Expected behaviour

Should be rendered as

foobar

https://codepen.io/thorn0/pen/NWWEaoo

Actual behaviour

Is rendered as

foo bar

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
wooormcommented, Nov 13, 2020

forgot to mention it here, but this landed for v2, on the next branch

0reactions
wooormcommented, Dec 18, 2020

Hi all! I’m going to close this as it landed on the main, the (now default) branch we’re using to gear up to the MDX@2 release.

The reason is so that it’s more clear which issues still need to be solved already and don’t require further work.

Expect another next release soonish, which might include it, or maybe it’s already released as a beta!

For more info, see https://github.com/mdx-js/mdx/issues/1041.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I insert a line break into a <Text> component in ...
Easier in my opinion, because you don't have to insert stuff within the string; just wrap it once and it keeps all your...
Read more >
How whitespace is handled by HTML, CSS, and in the DOM
Whitespace is any string of text composed only of spaces, tabs or line breaks (to be precise, CRLF sequences, carriage returns or line...
Read more >
kramdown Syntax
Any line that just contains white space characters such as spaces and tabs is considered a blank line by kramdown. One or more...
Read more >
Create Line Breaks Without Having to Use br in HTML
The 'content' property describes the stuff we want injected into the span. The white-space property tells us if we are to preserve the ......
Read more >
Changelog | Stylelint
Fixed: inconsistent trailing newlines in CLI error output (#4876). ... Removed: styled and jsx syntax options that were replaced with css-in-js in v9.10.0 ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found