Where is the props of Pre component? #2306
-
Hey guys. I'm having a problem with the This is the example I've created in Playground: The mdx is being compiled to: That's exactly what is happening in my project, I can't find the |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
Welcome @jlenon7! 👋 Understanding mdx's architecture will help clarify this: https://mdxjs.com/packages/mdx/#architecture There are some existing plugins which may already have the behavior you want:
Or if none of those meet your needs, you can create your own plugin. |
Beta Was this translation helpful? Give feedback.
-
I had a similar issue where I was not able to get the properties in my code component.
Later on this is available in the code component as a metaData prop which can be extracted like below -
Using this in gatsby variant of Carbon design system here - https://github.com/carbon-design-system/gatsby-theme-carbon/pull/1289/files#diff-3c2d1eade54db26a66f65bf042875994c93c044734a9c62a19385e0d15435a35R132 Plugin - https://www.npmjs.com/package/rehype-mdx-fenced-code-meta-support |
Beta Was this translation helpful? Give feedback.
Welcome @jlenon7! 👋
Understanding mdx's architecture will help clarify this: https://mdxjs.com/packages/mdx/#architecture
Your first screenshot shows markdown code meta properties, there is no equivalent in HTML (according to commonmark) so it is dropped when converting markdown (mdast) to HTML (hast).
If you'd like to preserve the information, you'll want to add a markdown (remark/mdast) plugin defining how you want the metadata to be preserved.
There are some existing plugins which may already have the behavior you want: