Skip to content

Commit a5ee2b4

Browse files
committed
Revert the default behavior of USE_DEFINITION_ORDER
The new behavior introduced in 3.9.0 is experimental and results are inconsistent. It should not have been made the default behavior. Relates to #1561.
1 parent 5354daf commit a5ee2b4

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

docs/changelog.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ See the [Contributing Guide](contributing.md) for details.
1414

1515
### Fixed
1616

17-
* Fix an HTML comment parsing case in some Python versions that can cause an infinite loop (#1554).
17+
* Fix an HTML comment parsing case in some Python versions that can cause an
18+
infinite loop (#1554).
19+
* Revert the default behavior of `USE_DEFINITION_ORDER` (to `True`). The new
20+
behavior introduced in 3.9.0 is experimental and results are inconsistent.
21+
It should not have been made the default behavior (#1561).
1822

1923
## [3.9.0] - 2025-09-04
2024

docs/extensions/footnotes.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,13 +106,12 @@ The following options are provided to configure the output:
106106
The text string used to set the footnote separator. Defaults to `:`.
107107

108108
* **`USE_DEFINITION_ORDER`**:
109-
Whether to order footnotes by the occurrence of footnote definitions
110-
in the document. Defaults to `False`.
109+
Order footnotes by definition order (`True`) or by document order (`False`).
110+
Defaults to `True`.
111111

112-
Introduced in version 3.9.0, this option allows footnotes to be ordered
113-
by the occurrence of their definitions in the document, rather than by the
114-
order of their references in the text. This was the behavior of
115-
previous versions of the extension.
112+
The default behavior matches the behavior prior to this option being added.
113+
Disabling this option (setting to `False`) is experimental and results may not
114+
be consistent.
116115

117116
A trivial example:
118117

markdown/extensions/footnotes.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,9 @@ def __init__(self, **kwargs):
6464
':', 'Footnote separator.'
6565
],
6666
'USE_DEFINITION_ORDER': [
67-
False, 'Whether to order footnotes by footnote content rather than by footnote label.'
67+
True,
68+
'Order footnote labels by definition order (True) or by document order (False). '
69+
'Default: True.'
6870
]
6971
}
7072
""" Default configuration options. """

tests/test_syntax/extensions/test_footnotes.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,8 @@ def test_superscript_text(self):
337337
extension_configs={'footnotes': {'SUPERSCRIPT_TEXT': '[{}]'}}
338338
)
339339

340-
def test_footnote_order(self):
341-
"""Test that footnotes occur in order of reference appearance."""
340+
def test_footnote_order_by_doc_order(self):
341+
"""Test that footnotes occur in order of reference appearance when so configured."""
342342

343343
self.assertMarkdownRenders(
344344
self.dedent(
@@ -364,7 +364,8 @@ def test_footnote_order(self):
364364
'title="Jump back to footnote 2 in the text">&#8617;</a></p>\n'
365365
'</li>\n'
366366
'</ol>\n'
367-
'</div>'
367+
'</div>',
368+
extension_configs={'footnotes': {'USE_DEFINITION_ORDER': False}}
368369
)
369370

370371
def test_footnote_order_tricky(self):

0 commit comments

Comments
 (0)