-
Hey guys, I'm struggling to understand how handlers work. I've been playing around with some simple ideas, such as adding/modifying properties, but I keep getting various errors. .use(remarkRehype, {
handlers: {
link: (state, node, parent) => {
// ?
}
}
}) Furthermore, when a node has children, and I modify that node with a handler, how do I properly reattach the child nodes? One real world example would be removing/not including the I haven't found much on the topic besides what's in the README, and #21, which got me started at least. I've also checked out the default handlers in |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hey! To change nodes, don’t use 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. |
Beta Was this translation helpful? Give feedback.
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.