Footnote Rendering

Last modified by Vincent Massol on 2024/11/19 16:14

Description

Motivation

At the moment, the footnote macro does basically nothing and all parsing is done by the putFootnotes macro that is automatically inserted at the top of the XDOM by the footnote macro but that can also be manually placed anywhere in the document (the macro is only inserted automatically when no putFootnotes macro can be found). The problem of this is that the footnote's content is evaluated in the wrong context.

Goals

  • Parse (and execute) the content of the footnote directly in the footnote macro.
  • Change the overall behavior as little as possible.
  • As we're on it, make sure that ids are actually unique using the id generator. The id generator is now preserved through quite some contexts also, e.g., in the new PDF export and thus allows making ids unique across contexts where the XDOM isn't shared.

Design

The footnote macro parses its content directly (with or without executing transformations) and returns that parsed content as its content (so basically, the footnote macro would be a simple content macro on its own). The putFootnotes macro would then just collect the children of the footnote macro markers, replace them by footnote references and return the collected footnotes together with links back to the original footnote.

Challenges

  • Several putFootnotes macros. At the moment, it is possible to have several putFootnotes macros. This happens automatically, e.g., when you display several documents with footnotes using the display macro. In the current implementation, the last evaluated putFootnotes macros removes all others and then just collects all footnotes again. This is not so easy with the new design as in the new design the "collected" footnotes are not available in their original place anymore. This requires to collect the footnotes of other putFootnotes macros, bring them in the right order and then adjust the references.
  • The ids currently consist of a prefix and the number of the footnote. It would be nice to keep them the same, but at the same time this kind of contradicts the use of the id generator and is especially difficult when multiple putFootnotes macros are involved and footnotes need to be re-numbered as it is not clear if or how ids should be adjusted. A simple idea would be to assign ids the first time a putFootnotes macro processes a footnote and store it in an attribute on the footnote macro marker. That way, subsequent putFootnotes macros can re-use the generated ids. The ids can also be recovered from the references without requiring attributes.

 

Get Connected