syntax-tree / mdast-util-to-hast

utility to transform mdast to hast
https://unifiedjs.com
MIT License
102 stars 42 forks source link

Embedding JSX into Markdown #18

Closed mrpotatoes closed 6 years ago

mrpotatoes commented 6 years ago

I'm coming up against issues and I know to where I am failing.

The mdast tree needs to get converted to an hast tree but any custom nodes are replaced with div nodes. I'm looking to allow any custom nodes (like XML).

How can I make this possible?

mrpotatoes commented 6 years ago

I was able to get it to work by modifying line 78 in lib/index.js to: tagName: node.tagName || tagName,

If it is converted to this then I can do what I need. I'm thinking that this isn't going to be an option for you but it'll work nicely for my plugin and I'll just make a copy of this code with the custom modification. If in the future you do make that an option I would be thrilled!

wooorm commented 6 years ago

Hey Andric! This is described in the notes, specifically, use node.data.hName to set tag names on MDAST nodes for use in HAST! Does that help? Comment if not, and I’ll re-open this issue!

mrpotatoes commented 6 years ago

Excellent, I'll give that a look when I get home tonight!