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.

[v2] Lines beginning with `~` inside a JSX block fail to parse

See original GitHub issue

While 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:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jerelmillercommented, Oct 7, 2020

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!

0reactions
wooormcommented, Nov 13, 2020

Closing as this was reported a bit earlier here: #1238. We can discuss there.

Read more comments on GitHub >

github_iconTop 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 >

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