How to define my own plugin to render a button with markdown? #1383
-
Hi, I'm new to the remark community so please forgive my lack of knowledge in this area if I asked anything that stupid. In my project I'm using react-markdown package, to render a markdown snippet as a React component on the frontend. It works well for me until we have a need recently to render a button from a markdown. I know this not standard markdown syntax, so I'm trying to define my own custom syntax for a button and try creating my own plugin to parse it. I started with a rudimentary syntax like this: and tried the following:
and then in my render function:
Apparently this does not work, and it simply returns a link with text "![buttonText]" like this ![buttonText]
Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Welcome @rockcs1992! 👋 ::button[button label to show the user]{href=https://example.com} would be the syntax. |
Beta Was this translation helpful? Give feedback.
-
Hi @ChristianMurphy , Awesome this is exactly what I was looking for. I will take a look at the plugin you mentioned. Thanks! |
Beta Was this translation helpful? Give feedback.
Welcome @rockcs1992! 👋
I'd recommend reading https://github.com/micromark/micromark?tab=readme-ov-file#extending-markdown
Rather than creating a new flavor of markdown, consider leveraging a generic extension like directive https://github.com/remarkjs/remark-directive#readme along with a plugin like https://github.com/IGassmann/remark-directive-rehype
would be the syntax.