MDX renderer fails to apply custom delete (del) component
See original GitHub issueCustom delete component fails to render
First ran into this over in system-ui/theme-ui#401 where applying a custom delete component failed to render when passed into MDXRenderer’s component prop. MDX rendered a del
, but not the custom one.
I’ve tried tracking down exactly where the issue happens, but only managed to get a few failing tests going in mdx-js and mdx-js/react.
Steps to reproduce / Expected / Etc
Here’s a commit with the two failing tests, or see the input/output below.
For mdx core:
const components = {
delete: ({children}) =>
React.createElement('del', {style: {color: 'crimson'}}, children)
}
it('renders delete component from context', async () => {
const result = await renderWithReact(`Hello, ~~world~~ MDX!`, {components})
expect(result).toContain(
'<p>Hello, <del style="color:crimson">world</del> MDX!</p>'
)
})
Expected substring: "<p>Hello, <del style=\"color:crimson\">world</del> MDX!</p>
"
Received string: "<p>Hello, <del>world</del> MDX!</p>"
Similar deal with @mdx-js/react:
const CustomDelete = props => <del style={{color: 'crimson'}} {...props} />
it('Should render delete as del', () => {
const result = renderToString(
<MDXProvider components={{delete: CustomDelete}}>
<Fixture />
</MDXProvider>
)
// CustomDelete is rendered
expect(result).toMatch(/style="color:crimson"/)
})
Expected pattern: /style="color:crimson"/
Received string: "<h1></h1><h2></h2><p>h3, h4</p>"
I suspect it’s further up the chain somewhere, so maybe someone with better knowledge of the ecosystem can hunt it down or point me in the right direction. Thanks!
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Troubleshooting MDX
This article goes through several common problems and errors that might occur when using MDX.
Read more >Gatsby doesn't render MD in component inside of mdx file
What i have tried: Using the MDXRender in Section & Hero => Error; Use the component directly in the MDX file instead of...
Read more >MDX Toolkit | Citrix Product Documentation
A Java command-line tool that wraps Android apps. • XenMobile App SDK: Third-party app developers can use the XenMobile App SDK to perform....
Read more >react-markdown - npm
React component to render markdown. Latest version: 8.0.4, ... If you instead want to use JavaScript and JSX inside markdown files, use MDX....
Read more >MicroStrategy MDX Cube Reporting Guide
You can also use Microsoft Analysis Services 2012, 2014, 2016, 2017,. 2019, and Azure in Tabular Mode using InMemory as the query mode....
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
Thanks for reporting! This definitely looks like a bug. Do you mind opening up a PR with your failing tests @markmichon? That way we could use that as a starting point to get a fix in.
There’s a new release candidate out for v2. See more on the website for that: https://v2.mdxjs.com. One feature that it includes is a one-to-one mapping of HTML tag names to components. That means
del
is now supported. More info on the Table of components: https://v2.mdxjs.com/table-of-components/.