hunyadi / md2conf

Publish Markdown files to Confluence wiki
MIT License
56 stars 31 forks source link

Visit children before transforming nodes (post-order DFS) #32

Closed AdamGagorik closed 7 months ago

AdamGagorik commented 7 months ago

I noticed links were not working inside admonitions. This is because we never visit them in the node visitor. I think it should be changed from pre-order depth first search to post-order depth first search. This is just something for you to consider, I don't know the full ramifications of this change without more testing. With the change, I see links inside admonitions are working, but I don't know if it broke something else.

AdamGagorik commented 7 months ago

For sure this PR breaks code blocks (some of them render as a single line), so maybe you should not take this change.

hunyadi commented 7 months ago

A more robust approach, in my opinion, is to trigger the node visitor for descendant elements of the admonition, which confines the behavior to that element type, and doesn't interfere with other block types, e.g. code blocks. I have added an example in which links are properly transformed in the context of an admonition using this approach. Changes are pushed to master.