Closed chenxsan closed 3 years ago
Hey!
This is one of the (documented) caveats: {
starts an expression in xdm (and mdx-js/mdx@next
).
The reason is that expressions are powerful: you can have code in your MDX:
The sum of 1 + 1 = {1 + 1}
And it would evaluate to 2.
The code inside braces is actually being parsed. In this case as an expression. So the return
fails fatally.
I recommend putting code inside backticks (- `async () => {return;}`
). Alternatively, escape the opening brace like so: - async () => \{return;}
Btw, in v1.5.0, a format
option was added. If the input isn’t MDX but just plain markdown, you can also run that through the same process: https://github.com/wooorm/xdm#optionsformat.
Initial checklist
Latest xdm.
Steps to reproduce
node index.js
It seems the
return
is the culprit.Expected behavior
No error to happen.
Actual behavior
Using markdown content like
- async () => {return;}
would throw an error.Removing
return
would fix it.