mdtablefix --footnotes converts eligible prose outside fenced code blocks,
including bare numeric candidates and the final numbered list, into Markdown
footnote links. Footnote references ([^n]), definitions ([^n]:), and
numeric candidates inside fenced code blocks remain unchanged. Fenced regions
are recognised using matching marker characters and run lengths; a closer must
also have no info string. A fence opened inside a blockquote ends when the
blockquote depth drops below its opening depth.
Conversion runs in three stages, and the order is part of the behaviour. Bare
numeric references are rewritten first, and both references and definition
headers are then renumbered in the order readers meet them, so [^10] becomes
[^1]. Because those rewrites change the length of the line, they run before
the table reflow and the paragraph wrap measure it, so a single pass settles. A
numbered item in the final list is folded into a definition in the same early
stage when a reference points at it, because the two are matched by the number
they share. Folding the rest of the final list, and reordering the definition
block, runs last, after the layout, because both read the document's settled
block structure. The numbers are final by then, so that last stage leaves them
as they are.
The definition block is sorted by those numbers, so it reads in the order the text reaches its references, and the definitions no reference reaches follow at the end, in the order they were written.