Skip to content

How pass custom props to code blocks? #2099

Answered by wooorm
allangrds asked this question in Q&A
Discussion options

You must be logged in to vote

If you have elements, you are not making a remark plugin, but a rehype plugin.
If there are h* fields on elements in rehype, something is going horribly wrong. Those fields should be available on mdast (markdown, remark) nodes, they should be gone on hast (HTML, rehype) nodes.

If you want to parse the meta string on fenced code as if it were JSX attributes, then there is already a plugin for that: https://github.com/remcohaszing/remark-mdx-code-meta.

You seem to be making your own plugin to do syntax highlighting.
A good reference for that is: https://github.com/wooorm/starry-night#example-integrate-with-unified-remark-and-rehype.
In hast, when coming from markdown, <code> element have no…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by allangrds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants