Closed TomerAberbach closed 2 years ago
@TomerAberbach Thank you very much for the contribution. I merged it and published it as part of v2.1.2.
I’m curious: What’s the use case for two unified
passes?
No problem!
My use case is:
unified
pass: doing some processing on the server (e.g. parsing Markdown, applying transforms)unified pass
: using rehype-react
to render the AST to React elementsThis issue didn't happen if instead of sending the AST I serialized to HTML and then parsed it back on the client, but that would require me to include a library to parse the HTML (e.g. rehype-dom
) which I didn't want to do if I could avoid it (for a smaller bundle size)
Thanks for sharing. That makes sense 👍
It seems that performing two separate
unified
passes currently causes duplicate root nodes (e.g.{ type: 'root' }
as a child of the top-level root) when an AST from a prior transform is used with this plugin.I was able to fix it by adding the parsed output's children individually rather than adding the root parsed output node. I've also confirmed that the newly added test fails before the change and passes with the change.