Skip to content

remark-rehype: Custom handlers #249

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

You must be logged in to vote

Hey!

To change nodes, don’t use remark-rehype handlers. Those functions map one mdast node to another hast node. Changing nodes is better done in other tools. How that happens is pretty strongly defined by markdown/GFM. But handlers mostly exist for custom nodes.

I’d recommend making a rehype plugin if you want to change nodes representing HTML elements. That’s the proper place to remove/change/add properties. See https://unifiedjs.com/learn/guide/create-a-rehype-plugin/ for a guide.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jirpok
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