asciidoctor.js icon indicating copy to clipboard operation
asciidoctor.js copied to clipboard

AbstractBlock#append() does not dispatch to overwritten append methods (for section/document)

Open simon-spinner opened this issue 3 years ago • 1 comments

In https://github.com/asciidoctor/asciidoctor/blob/d352fa7ef051c7fbcf05ae70ac69eedfd4bdc694/lib/asciidoctor/document.rb#L809 the append method is overwritten to update the section numbers when adding a section to a document (similar code exists for sections). Calling append() on a document in JavaScript seems to dispatch to the AbstractBlock version which does not handle updates to section numbers. As a result section numbering and TOC generation does not work as expected when programmtically adding sections to documents. A workaround is to call document["$<<"](section) directly instead

simon-spinner avatar Sep 23 '22 10:09 simon-spinner

Indeed, we do not define the append method on the Document object. Would you like to submit a pull request (with a test) to fix this issue?

ggrossetie avatar Sep 23 '22 15:09 ggrossetie