Skip to content

fix: number nested-block footnotes in document order - #1626

Open
BetterAndBetterII wants to merge 2 commits into
Python-Markdown:masterfrom
BetterAndBetterII:fix/footnote-nested-block-order
Open

fix: number nested-block footnotes in document order#1626
BetterAndBetterII wants to merge 2 commits into
Python-Markdown:masterfrom
BetterAndBetterII:fix/footnote-nested-block-order

Conversation

@BetterAndBetterII

Copy link
Copy Markdown

Summary

With USE_DEFINITION_ORDER=False, footnote reference numbers followed the breadth-first inline parse order rather than source/document order. Refs inside lists and blockquotes therefore got the wrong superscripts (e.g. 1, 4, 2, 5, 3 instead of 1–5).

This rebuilds footnote_order from the already-rendered tree in document order, renumbers the superscripts, then reorders the footnote list — without changing core inline walking.

Fixes #1561

Test plan

  • python -m unittest tests.test_syntax.extensions.test_footnotes (28 OK)
  • New cases: nested list/blockquote refs; nested refs where definition order ≠ document order

With USE_DEFINITION_ORDER=False, footnote refs were numbered by
breadth-first inline walk order, so refs inside lists/blockquotes
got wrong superscripts. Rebuild footnote_order from the tree in
document order and renumber refs before reordering the footnote list.

Fixes Python-Markdown#1561
@waylan

waylan commented Sep 2, 2026

Copy link
Copy Markdown
Member

You seem to have deleted the pull request template from your submission. Could you please copy that into a comment and provide the requested information before we use our time to review your submission?

Satisfy changelog-enforcer and checkspelling for the Python-Markdown#1561 footnote order fix.
@waylan waylan added the more-info-needed More information needs to be provided. label Sep 3, 2026
@waylan

waylan commented Sep 3, 2026

Copy link
Copy Markdown
Member

This appears to be a bug-fix, not an enhancement. Therefore, the feature freeze on extensions does not apply. However, I will not review this any further until the requested information is provided. Specifically, we would like to know about any AI use which may or may not have contributed to this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

more-info-needed More information needs to be provided.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nested block footnotes rendered in wrong order

2 participants