Closed davidtheclark closed 7 years ago
Hi! 👋 Good Q!
First of: if you want to do things with HTML (and you probably do), not just markdown, then remark-rehype
is the good choice! Otherwise, remark-html
with {allowDangerousHTML: true}
is fine.
If you want to properly deal with HTML in markdown, you’ll need rehype-raw
after remark-rehype
. The example in its readme shows how to use these two together. (note: I just added that here too)
The downside of rehype-raw
is that it contains a full-fledged HTML parser. If you can’t spare the resources for that (e.g., browser), you can pass {allowDangerousHTML: true}
to remark-rehype
and rehype-stringify
respectively to get the comments to show up.
Does this help?
@wooorm: This was exactly the advice I needed. Thanks!
I would like HTML comments from Markdown to remain in the tree ... but it seems that they're removed. If, however, I use
remark-html
to stringify the Markdown AST, then parse that withrehype-parse
, the comments remain. It seems it would be more efficient if I could just useremark-rehype
and keep the comments — but I can't figure out how to do that.I've been jumping around between these module trying to figure this out and come up empty handed. Am I missing something?