docz: MDX parsing appears broken
I’m trying to interleave MDX inside JSX, as outlined here.
The result is a completely unpredictable parse result which rarely works correctly.
I’ve placed a minimal repo that reproduces the issue here: https://github.com/godmar/gatsby-docz-bug To see it, clone and do
yarn
yarn gatsby develop
The following MDX:
---
title: "Test for Bug"
date: 2019-09-05T14:53:20.798Z"
menu: MenuEntry1
---
import Notice from '../../src/components/Notice'
<Notice type={"tip"} title={"Side note"}>
This text uses *markdown*, but the markdown does not arrive at the component.
</Notice>
Markdown in the *middle* does not work, either. A [link](www.google.com)
<Notice type={"tip"} title={"Tip"}>
The same is _true_ here.
</Notice>
is rendered as:
, but the markdown does not arrive at the component. This text uses Markdown in the middle does not work, either. A link here. The same is
when embedded in the Notice component (which pretty much echoes its children in a box, without manipulating them in any way.
Could this be a parser bug? If so, is it possible to update the mdx parser and override the one gatsby-docz-theme uses?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 15 (3 by maintainers)
I wasn’t able to reproduce this bug with the gatsby mdx starter. You can see that it works just fine without docz: https://github.com/godmar/gatsby-mdx-bug and specifically here.
On the other hand, with gatsby-theme-docz: https://github.com/godmar/gatsby-docz-bug and here it does not. The .mdx files are identical except for the path to my component.
The MDX starter used gatsby-plugin-mdx ^1.0.0 whereas docz uses ^1.0.13, but that doesn’t make a difference. With the MDX starter, it works with gatsby-plugin-mdx 1.0.0 and 1.0.13.
These are both minimal repositories. The docz is created with your starter instructions and just a few files added. The MDX is from the gatsby mdx starter, and gatsby-plugin-mdx is upgraded.
So there must be some setting or option or some divergent version that steers docz away. Could it be that you have other plugins that operate on the AST?
ps: reversing to @mdx-js/mdx 1.1.0 and @mdx-js/react^1.0.27 also doesn’t reproduce the bug.