Skip to content

I can't add any custom properties in remark plugin #859

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

You must be logged in to vote

You seem to be using TypeScript. TypeScript can be useful in this case, but you’re setting everything to anys.

The markdown syntax tree (called mdast, used by remark) does not have properties. You can’t set properties there. You‘re not supposed to.

The HTML syntax tree (called hast, used by rehype) does have properties. You can set them there.

If I add a "rehype" plugin, the data has disappeared already. But interestingly enough if I add custom data in "rehype" plugin then it will stay and my custom component renderer will receive it!

Indeed. You want to set properties in html/hast/rehype.

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@wooorm
Comment options

@ChristianMurphy
Comment options

@mvalts
Comment options

@mvalts
Comment options

@wooorm
Comment options

Answer selected by mvalts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants