-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
Parsing strangeness around flow-level JSX elements #12
Comments
Welcome @iczero! 👋
Happy to discuss how to make the implementation more efficient.
To be clear on the goal of MDX, it is Markdown + JSX, there is no HTML in MDX.
I am against making syntax configurable in core. |
I have closed the PR for now because it uses a terrible approach that doesn't work. I believe it will be more productive to discuss further when I have a prototype that actually works. I will try to make it an extension. Thank you for your time. |
They should not. That is not MDX. It is not a good idea. Your custom versions would not work with other tools that use MDX. Such as site engines. Or it would not have proper syntax highlighting in folks’ editors or on GitHub. As Christian mentions, that was used in MDX 1 and it was the most requested feature to change.
It is not about The solution, whether it’s with how XML-like things are treated in markdown or the complete JSX grammar of MDX, is to teach users. In MDX, it’s as follows: |
This comment has been minimized.
This comment has been minimized.
Hi! Thanks for reaching out! Because we treat issues as our backlog, we close issues that are questions since they don’t represent a task to be completed. See our support docs for how and where to ask questions. Thanks, |
Initial checklist
Problem
The current flow-level JSX tokenizer is only used for single elements. It cannot handle text. This results in some strangeness when tokenizing which causes flow-level elements to be parsed as inline (text) elements instead.
<a>
: mdxJsxFlowTag<a><b>
: mdxJsxFlowTag, mdxJsxFlowTag<a>hello</a>
: +paragraph, mdxJsxTextTag, text, mdxJsxTextTag, -paragraph (transformed as<p><a>hello</a></p>
)This paragraph wrapping behavior causes mdx-js/mdx#1526, which is currently fixed by an AST transform.
Additionally, some users may wish to restore CommonMark behavior for flow-level markdown within tags (mdx-js/mdx#1798). Instead of starting a new paragraph immediately after the tag, the PR requires a blank line to resume flow-level markdown. An opt-in configuration option is used to enable this behavior.
Solution
Please see PR #11. It introduces a new parsing scheme behind a configuration option which allows opting in to new behavior.
Alternatives
Do nothing. The current behavior has existed for a few years and is fine.
The text was updated successfully, but these errors were encountered: