Yue Yi <[email protected]> writes:
> Hello, Org-mode maintainers,
>
> I found a bug in ox-html's footnote reference handling that generates
> duplicate HTML IDs when a footnote is referenced multiple times. When a
> footnote is referenced more than once, ox-html should generate unique
> IDs for each reference:
>
> - First reference: id="fnr.LABEL"
> - Second reference: id="fnr.LABEL.1"
> - Third reference: id="fnr.LABEL.2"
> - etc.
>
> However, the current implementation generates duplicate IDs for the
> second and subsequent references.
> ...
> The bug is in `org-html-footnote-reference'. The code uses
> `org-export-get-ordinal' to compute the numeric suffix, but
> `org-export-get-ordinal' returns the *footnote number* (which footnote
> it is), not the *reference count* (how many times it has been
> referenced).
That's a bug in org-export-get-ordinal.
Its docstring indeed says
Return value is a list of numbers if ELEMENT is a headline or an
item. It is nil for keywords. It represents the footnote number
for footnote definitions and footnote references.
However, the reason why it returns footnote number of footnote
references is because those can be inline footnote references.
There is no point returning footnote number of normal (non-inline)
references:
Return value is a list of numbers if ELEMENT is a headline or an
item. It is nil for keywords. It represents the footnote number
for footnote definitions and *inline* footnote references.
> * lisp/ox-html.el (org-html-footnote-reference): Count references
> instead of using `org-export-get-ordinal'.
It is better to fix `org-export-get-ordinal' instead.
--
Ihor Radchenko // yantar92,
Org mode maintainer,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>