[v2] Lines beginning with `~` inside a JSX block fail to parse
See original GitHub issueWhile using MDX v2.0.0-next.8, it appears that lines beginning with ~
fail to parse when the text is nested inside a JSX block. An error is thrown when the parser tries to parse it:
Unexpected end of file in code, expected a corresponding fence for `~`
Steps to reproduce
You can reproduce this while using the playground and copying this sample code:
<div>
~/.newrelic
</div>
Notice that be removing the <div>
, it is able to parse correctly. I am using the following minimal unified setup to reproduce this:
const mdx = require('remark-mdx');
const parse = require('remark-parse');
const unified = require('unified');
const tree = unified().use(parse).use(mdx).parse(`
<div>
~/.newrelic
</div>
`);
Removing the remark-mdx
plugin parses the tree without error, albeit with html
nodes instead of the additional parsed nodes provided by remark-mdx
.
Expected behaviour
I would expect this to only try and the parse the text as a code block inside JSX nodes when there are 3 or more ~
characters.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Improve JSX block parsing · Issue #195 · mdx-js/mdx - GitHub
This will ensure that JSX blocks that contain empty new lines are parsed as a single, cohesive block.
Read more >Adjacent JSX elements must be wrapped in an enclosing tag ...
The problem. Parse Error: Adjacent JSX elements must be wrapped in an enclosing tag. This means ...
Read more >JSX In Depth - React
User-Defined Components Must Be Capitalized. When an element type starts with a lowercase letter, it refers to a built-in component like <div> or...
Read more >Troubleshooting MDX
This error is thrown by our MDX parser. It was introduced in version 2. It occurs when the keywords import or export are...
Read more >How To Set Up a React Project with Create React App
Starting a new JavaScript project with React used to be a ... Tutorial Series: How To Code in React.js ... Step 2 —...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Oh totally! I’d be happy to use the workaround until this has been updated. I’ll keep tabs on the rewrite of the parser. Thanks for the update!
Closing as this was reported a bit earlier here: #1238. We can discuss there.