asciidoctor / asciidoctor-pdf

:page_with_curl: Asciidoctor PDF: A native PDF converter for AsciiDoc based on Asciidoctor and Prawn, written entirely in Ruby.
https://docs.asciidoctor.org/pdf-converter/latest/
MIT License
1.14k stars 501 forks source link

Orphan detection for heading can leave document in modified state #2288

Closed mojavelinux closed 2 years ago

mojavelinux commented 2 years ago

If orphan detection is enabled on a heading (section title or discrete heading), that operation can leave the document in a modified state. This bug can be observed if there's a footnote in the section. The footnote gets duplicated and the backlinks to and from it break.

To avoid this problem, the scratch document needs to be pushed onto the stack when entering the dry run block and popped when exiting it.