Can't get rehypeReact to parse HTML into React nodes. #126
-
I want to parse markdown to React nodes, and replace some of the nodes. For example, I want to replace After reading the documentation, I assumed that the following code would do the trick. const result = unified()
.use(remarkParse)
.use(remarkRehype)
.use(rehypeReact, {
createElement,
Fragment,
components: {
a: CustomLink
}
})
.processSync(markdown); That did not work, so I searched around and found rehypejs/rehype-react#15, which is a bit different from the basic examples. However, this too produced the same result. When replacing I'm probably missing something, but I can't seem to find it. Does anyone have a working example? Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi! What didn’t work? What you call |
Beta Was this translation helpful? Give feedback.
Hi! What didn’t work?
What you call
const result
, isn’t the result. That’s aVFile
. Which has a property called.result
.The example in the readme is a working example: https://github.com/rehypejs/rehype-react#use