Suggest: Create inline node in parse time instead of convert time

Posted by chloerei on
URL: https://discuss.asciidoctor.org/Suggest-Create-inline-node-in-parse-time-instead-of-convert-time-tp7500.html

Asciidoctor currently does not create inline node during parsing, this means can not get inline node after parsing the document.

For example, I want to create a multipage converter, after split document to several sub document, I can not know if this sub document have any footnotes during convert time.

Currently I convert the document to HTML first, use specific mark to represent inline footnote, and then postprocess the HTML to extract footnotes.

Another issue is Asciidoctor will create duplicate footnotes after repeatedly convert.

For example:

irb> doc = Asciidoctor.load 'footnote:[text]'
irb> doc.convert
=> "<div class=\"paragraph\">\n<p><sup class=\"footnote\">[<a id=\"_footnoteref_1\" class=\"footnote\" href=\"#_footnotedef_1\" title=\"View footnote.\">1]</sup></p>\n</div>\n<div id=\"footnotes\">\n<hr>\n<div class=\"footnote\" id=\"_footnotedef_1\">\n<a href=\"#_footnoteref_1\">1. text\n</div>\n</div>"
irb> doc.convert
=> "<div class=\"paragraph\">\n<p><sup class=\"footnote\">[<a id=\"_footnoteref_2\" class=\"footnote\" href=\"#_footnotedef_2\" title=\"View footnote.\">2]</sup></p>\n</div>\n<div id=\"footnotes\">\n<hr>\n<div class=\"footnote\" id=\"_footnotedef_1\">\n<a href=\"#_footnoteref_1\">1. text\n</div>\n<div class=\"footnote\" id=\"_footnotedef_2\">\n<a href=\"#_footnoteref_2\">2. text\n</div>\n</div>"

This is weird because the documentation itself has not changed.

This is not an urgent issue, and it would be better if an API for finding inline nodes could be provided in the future.