Ihor Radchenko <[email protected]> 2026.10.6 Tue 02:55 write: > 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.
Attached is v2, reworked as you suggested: the fix is now in
`org-export-get-ordinal' instead of ox-html.
While redoing it I went through the history of the HTML side, and it
turned out this is a second attempt at the same problem. Commit
e0f24a3f6 ("org-html-footnote-reference: Fix duplicate IDs",
2024-04-28) already tried to number the references; it came out of
the "HTML export does not preserve footnote label" thread:
https://list.orgmode.org/orgmode/[email protected]/
That attempt could not work. `org-export-get-ordinal' has an
unconditional branch for footnote elements
((footnote-definition footnote-reference)
(org-export-get-footnote-number element info))
so it returned the footnote number and never called the TYPES and
PREDICATE arguments the call site passed. In hindsight the suffixes
it produced were exactly the footnote numbers, which are unique only
as long as each footnote is referenced at most twice: with two
references the output looks correct, and the duplicate only shows up
from the third reference on. That is presumably why it went
unnoticed for two years. (FWIW, the code before 2024 used
a hard-coded ".100" suffix, which has the same limitation.)
0001-lisp-ox.el-Fix-org-export-get-ordinal-for-repeated-f.patch
Description: Binary data
