Skip to content

Mixing markdown/html trees #1322

Answered by wooorm
Fabrizz asked this question in Q&A
Apr 29, 2024 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

Hi!

correctly h just creates html trees, not markdown.

Correct!

Creating a rehype plugin makes more sense, but is the node type maintained from remark to rehype?

Indeed, that’s the correct question to ask.

Well, one way to find out, make a rehype plugin and console.log the tree 😉

Astro might do some things there. But maybe not. Not by default in our stuff.

If not, there are 2 places to do this. Either a) in the step when going from markdown to HTML which is the last time that directive exists, or b) in the markdown phase.

For a), Astro probably has an option for how to configure remark-rehype: you can pass a custom handler for directives.

For b), you can make a remark plugin, as shown…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Fabrizz
Comment options

Answer selected by Fabrizz
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