Repository navigation
Fix silently dropped indented nested footnote definitions - #1682
Open
rahul05ranjan wants to merge 1 commit into
Open
rahul05ranjan wants to merge 1 commit into
rahul05ranjan wants to merge 1 commit into
Conversation
An indented footnote definition nested inside another footnote's multi-line content was collected as parent content (detectTabbed ran the definition regex on the still-indented block), then removed again when the parent content was re-rendered internally - after the footnote list had already been built. The nested definition text disappeared from the output and any reference to it linked to a #fn: anchor that was never emitted. Run the definition search on the detabbed block in detectTabbed so an indented nested definition is split out and processed as its own footnote in the same pass, exactly like an un-indented nested definition. Double-indented content is preserved (as code) instead of being dropped. Fixes Python-Markdown#1681 Co-authored-by: rahul05ranjan <11793455+rahul05ranjan@users.noreply.github.com>
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 #1681
Summary
An indented footnote definition nested inside another footnote's multi-line content was silently dropped: the definition text disappeared from the output entirely, and any reference to it linked to a
#fn:anchor that was never emitted (dead internal link). The un-indented variant (definition in the same block as the parent) already worked and is tested, so only the multi-line/indented variant was broken.Root cause
FootnoteBlockProcessor.detectTabbed()collected each 4-space-indented block as content of the parent footnote, but ran the definition regex (^[ ]{0,3}\[\^([^\]]*)\]:) on the still-indented block, so an indented[^2]: ...line never matched and was swallowed into the parent's content. When the parent content was later re-rendered internally,run()matched the now-unindented line as a new definition and removed it — after the footnote<div>/<ol>structure had already been generated, so the nested footnote was never rendered.The fix
Run the definition search on the
detab()-ed block insidedetectTabbed()so an indented nested definition is split out and re-queued for the normal definition processing — exactly like the un-indented case. Double-indented (8-space) content is preserved as code inside the parent instead of being dropped.Verification
[^1]: Firstfollowed by an indented[^2]: Secondnow renders both<li id="fn:1">and<li id="fn:2">; the referenced variant emits a matching#fn:2anchor instead of a dead link.tests/test_syntax/extensions/test_footnotes.py:fnref:2↔fn:2)847 passed, 111 skipped(Python 3.13), including the existingtest_footnote_reference_within_footnote_definition(un-indented nesting) — no regressions.View the OpenClaw team session