Repository navigation
Fix indented footnote definitions being silently dropped - #1710
Closed
tony1233200 wants to merge 1 commit into
Closed
tony1233200 wants to merge 1 commit into
tony1233200 wants to merge 1 commit into
Conversation
A footnote definition which is indented as content of another footnote definition was never registered: the definition pattern was matched against the still-indented text, where it cannot match. The definition was therefore dropped and any reference to it pointed at a missing anchor. Search for a definition in the detabbed text when handling the rest of a footnote block and when collecting indented blocks of a footnote, and split the block at the definition when one is found. Only the definition line is detabbed, so following lines keep their original indentation. Fixes Python-Markdown#1681
Member
|
This is not the behavior I described as acceptable in #1710. If we are making any changes, those changes would be to better match PHP Markdown Extra's behavior. At a minimum, we should not recognize a footnote nested in a footnote. It should remain as text in the parent footnote. |
12 of 15 tasks
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.
Description
Fixes #1681. A footnote definition which is indented as content of another footnote definition (for example,
[^2]: Secondindented by four spaces under[^1]: First) was silently dropped:FootnoteBlockProcessormatched its definition pattern against the still-indented text, where the pattern cannot match, so the nested definition was never registered and any reference to it pointed at a#fn:anchor that does not exist in the output.The block processor now also searches for a definition in the detabbed text, both when collecting the indented blocks of a footnote (
detectTabbed) and when handling the rest of a footnote block (run). When an indented definition is found, the block is split at the definition so it is registered like an un-indented one. Only the definition line is detabbed; lines which follow it keep their original indentation, so indented content of the nested footnote (such as a code block) is preserved.Three regression tests cover an indented definition in a following block, in the same block as its parent, and referenced by its parent. All three fail without the change. The full test suite (1221 tests via
python -m unittest discover tests) passes with it.AI Assistance Disclosure
No AI tools were used in preparing this PR.
AI tools were used and I have disclosed which ones, and have fully reviewed and verified their output.
AI tools were use to assist with the following:
The tool used was Claude (Anthropic). It generated the code change in
markdown/extensions/footnotes.py, the three regression tests, the changelog entry, the commit message, and this description. All output was reviewed, and the change was verified locally by reproducing the issue from Footnotes: indented nested footnote definition is silently dropped and produces a dead #fn: anchor #1681 and running the full test suite before submission.Checklist