Closed januswel closed 3 years ago
Why are you adding remark-rehype
to react-markdown
?
It’s already doing that: https://github.com/remarkjs/react-markdown/blob/a2b611babce101fd1e7225f0720819c020c40d94/src/react-markdown.js#L97.
https://github.com/remarkjs/remark/discussions/692 might help you
@wooorm Thank you for your advice!!
Why are you adding remark-rehype to react-markdown? I wanna pass my custom handler to remark-rehype
I read https://github.com/remarkjs/remark/discussions/692, and got your recommendation is using node.data.hName
and node.data.hProperty
in custom mdast -> mdast plugin with remark-rehype
Is my understanding correct??
I don't know what you want to do, so it's hard to suggest the best approach! But yeah, thats often a good way to go.
@wooorm thx!!
I just want to extend Markdown and to use extended one with React
And I believe it's confusing mdast can have information for hast
Is using hName
and hProperties
a workaround for now?
It’s not a workaround. It’s supported for about 6 years now and it’s worked rather well. Though I do get that it’s weird at first. The diagram created by @ChristianMurphy shows it well.
Markdown has certain constructs. HTML has other constructs. To turn one into the other, it has to be defined somewhere how to do that. For a block quote, that’s not too complex: what HTML they turn into is supported by default. For arbitrary nodes (such as directives), there is no way to represent them in HTML.
So remark-rehype
, which is the transform between markdown and HTML, supports how to transform from markdown to HTML embedded in nodes.
@wooorm Thank you for your polite reply 😆 This is the last comment from me
Though I do get that it’s weird at first.
I feel you I'll get used to this
Subject of the issue
Using with react-markdown raises an error
Your environment
Steps to reproduce
With following codes
Expected behavior
Any errors are not raised
Actual behavior
Following error is raised from TypeScript