Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I custom renderer tag? #1017

Open
dribble-njr opened this issue Mar 26, 2024 · 4 comments
Open

How can I custom renderer tag? #1017

dribble-njr opened this issue Mar 26, 2024 · 4 comments

Comments

@dribble-njr
Copy link

I am trying to implement a blog with chakra-ui and markdown-it.

Now I can parse markdown file to HTML with markdown-it, and I renderer as normal HTML tag like <h1> without any style. But I want to custom style with chakra-ui instead of write CSS code.

How can I costom HTML tag to chakra-ui components. It seems like:

## h2
<Heading as={"h2"}>{...}</Heading>

I am trying to change md.renderer.rules but I doesn't work. So does any other way to impletment it.

Thanks in advance.

@mikelecunio
Copy link

mikelecunio commented May 23, 2024

hey I am interested in taking this issue on @dribble-njr , I know something about rendering issues in chakra-ui through a friend.

@dribble-njr
Copy link
Author

hey I am interested in taking this issue on @dribble-njr , I know something about rendering issues in chakra-ui through a friend.

I solved this problem by ChakraUIRenderer. Actually, it use react-markdown other than markdown-it.

Do you have some idea for rendering custom component with markdown-it?

@mikelecunio
Copy link

Hello,

The React documentation on markdoc.io explains how to use the custom Callout and it works really well :)

If I transform it like this:

Markdoc.transform(node, {
tags: {
callout: {
render: "Callout",
},
},
});
and render it like this:

Markdoc.renderers.react(props.content, React, {
components: {
Callout: Callout,
},
});

Is something similar to what you what you actually wanted to render?

@dribble-njr
Copy link
Author

So it is also using another lib to render markdown. It seems that markdown-it does not provide similar capabilities?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants