Closed leo-petrucci closed 1 year ago
This is very much intentional. Have you tried typing a < somewhere in a javascript file? It crashes. Why should mdx behave differently?
(And I believe the example you show in expected behavior works fine: < plus a space is allowed)
@wooorm That's fair enough.
Do you have any advice if I was trying to parse a larger Markdown string that might end with a "<"? Any way for remark-mdx
to ignore that single character?
The advise is explained in the article on “What is MDX?” and Troubleshooting. Write MDX, which means in this case: handle <
. By escaping it: \<
.
Initial checklist
Affected packages and versions
remark-mdx@2.3.0
Link to runnable example
https://codesandbox.io/s/remark-mdx-issue-196smb?file=/src/index.js
Steps to reproduce
I'm trying to parse MDX from an editor, but I've encountered an issue whenever I try to type the character "<". The MDX parser thinks it's the start of a component and crashes the entire thing.
Expected behavior
I think the "<" should ideally be escaped like what happens when it's not placed at the end of the file:
Actual behavior
The parser throws an error and crashes.
Runtime
Node v16
Package manager
yarn v3
OS
macOS
Build and bundle tools
webpack