SwiftDocOrg / CommonMark

Create, parse, and render Markdown text according to the CommonMark specification
MIT License
179 stars 10 forks source link

Insertion of children is broken for containers #9

Closed Lukas-Stuehrk closed 4 years ago

Lukas-Stuehrk commented 4 years ago

Cmark has a very misleading naming of its arguments for inserting nodes: The cmark_node_insert_after function takes a node and a sibling. https://github.com/SwiftDocOrg/swift-cmark/blob/master/src/node.c#L719

Unlike what you would expect, sibling is the node that is actually inserted. Unfortunately CommonMark uses the wrong order of arguments for all calls to cmark_node_insert_after, e.g. at https://github.com/SwiftDocOrg/CommonMark/blob/master/Sources/CommonMark/Supporting%20Types/Children.swift#L111