markdown-rs icon indicating copy to clipboard operation
markdown-rs copied to clipboard

Would `to_mdast()` return variants of `mdast::Node` other than `mdast::Node::Root`?

Open lo48576 opened this issue 1 year ago • 1 comments

I haven't read the parser thoroughly, but it looks like to_mdast() always returns mdast::Node::Root(_) on success, even if the source document looks like a simple "inline" text. If so, isn't it natural and explicit to return mdast::Root directly instead of wrapping it to mdast::Node enum?

Or if it can return something other than mdast::Node::Root(_) variant, the condition would be worth documented.

I'm wondering my converter over md AST can assume that the returned AST is always mdast::Root.

lo48576 avatar Mar 03 '24 01:03 lo48576

Hey! It does indeed always return a root. I don’t have strong opinions on this. The AST can be improved though. That’s one of the main reasons this is still alpha. There are different issues about it.

wooorm avatar Mar 03 '24 14:03 wooorm