Repository navigation
Conversation
Footnote references are numbered in order of appearance by _do_footnote_marker, but _add_footnotes then sorted the notes by the order of their definitions. When the definitions weren't in reference order, the note numbered 2 in the text could be the first item of the list, and its back-link title said "footnote 1". The sort dates from before _do_footnote_marker numbered references on the final text, when it was needed to undo out-of-order numbering for references inside lists and blockquotes. footnote_ids is now already in numbering order, so drop the sort. Fixes trentm#178 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
|
Looks reasonable, thanks! Mark it as ready whenever and ill take a better look |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #178.
Bug
With the
footnotesextra, if footnote definitions aren't written in the same order as the references, a note's position in the footnote list doesn't match its number in the text:The reference to
[^1]reads 2 in the text, but its note is item 1 of the<ol>, and its back-link title says "footnote 1". The original 2015 report was about footnotes in lists and blockquotes. Those references are numbered correctly in order of appearance now, but the list is still out of step whenever the definitions are ordered differently.Cause
Since #612 (now
_do_footnote_marker, after #672), references are numbered on the final text, in order of appearance, andfootnote_idsis filled in that order._add_footnotesthen still sortsfootnote_idsby definition order. That sort was added in #536, back when numbering happened per span and references inside lists came out of order. #612 fixed the numbering but kept the sort, so now the sort only scrambles a list that is already correct.Fix
Drop the sort, so the notes are listed in the order they're numbered.
footnotes_defined_out_of_ordertest case: references in a paragraph and a blockquote, with definitions in a different order.repeated_footnote_labels.html(from Preserve numbers for repeated footnote references #727) had the mismatch baked in:fn-secondwas listed first with the title "footnote 1", while the text numbered it 2. I updated it sofn-first(1) comes beforefn-second(2).footnotes_order_of_appearanceand the other footnote cases pass unchanged.Both test cases fail without the change and pass with it. With the fix, the full
make testonerun passes, except the 7 pygments-version-gated cases (pygments>=2.21/<2.21), which fail identically onmasterwith my local pygments.🤖 Generated with Claude Code