Closed jmooring closed 8 months ago
Found the root cause:
goldmark's walking algorithm is a bit simplistic: https://github.com/yuin/goldmark/blob/90c46e0829c11ca8d1010856b2a6f6f88bfc68a3/ast/ast.go#L497-L501
for c := n.FirstChild(); c != nil; c = c.NextSibling() {
if st, err := walkHelper(c, walker); err != nil || st == WalkStop {
return WalkStop, err
}
}
In my case, I replace the current node with a new set of nodes, and the call to c.NextSibling
gives nil. Since goldmark doesn't support a worklist style of walk, I'll have to modify my walk to update the node in place.
This test passes:
This test fails:
test output
The only difference between the two tests is the order in which the paragraphs are placed.