Parsing document and nesting in larger AST

Hi I am trying to programmatically create some markdown with cmark by combining parsed sub-document (and some manually created leaf nodes) in a larger AST.

cmark_node_append_child however doesn’t like it when the child node is a document. What’s the best way to get around this? Use the iterator to grab all the immediate children somehow and re-parent them? (If so, I do wish it was fine with child document nodes, and just treated them as “no-op blocks”. That would be much more convenient.)

I made my own solution Allow nested document nodes by Ericson2314 · Pull Request #522 · commonmark/cmark · GitHub

1 Like