RFC: MDX v2 block parsing
See original GitHub issueCurrently, as implemented in MDX v2, the block parser begins a paragraph inside lines that begin with a component. This was initially intended, but I’m not sure it makes sense in practice. It results in some unexpected behavior (IMO).
Consider the following MDX:
# Hello, world!
<Button>Weee</Button>
We end up with:
<h1>Hello, world!</h1>
<Button>
<p>Weee</p>
</Button>
In v1 we result in:
<h1>Hello, world!</h1>
<Button>Weee</Button>
In v1, you could work around wanting a paragraph with something like:
# Hello, world!
<p>
<Button>Weee</Button>
</p>
Another unexpected case is directly inlining your paragraph tag for the block:
# Hello, world!
<p>
Weee
</p>
Which results in:
<h1>Hello, world!</h1>
<p>
<p>Weee</p>
</p>
Why might you want to do that? It might make sense if your paragraph in MDXProvider has a styling API and you want to make a one off tweak: <p color='red'>Weeee</p>
.
tl;dr I’m thinking that it likely makes the most sense to not continue block parsing inside blocks which begin with JSX. It’s more flexible that way.
Issue Analytics
- State:
- Created 3 years ago
- Comments:23 (13 by maintainers)
Top GitHub Comments
For now, in the beta, you can use braces too I believe, as they “exit” markdown:
{<Buton>x</Buton>}
or<Buton>{x}</Buton>
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.