Skip to content

Fix link refs used only inside MyST admonitions being dropped - #51

Open
BetterAndBetterII wants to merge 1 commit into
executablebooks:masterfrom
BetterAndBetterII:fix/admonition-link-refs
Open

Fix link refs used only inside MyST admonitions being dropped#51
BetterAndBetterII wants to merge 1 commit into
executablebooks:masterfrom
BetterAndBetterII:fix/admonition-link-refs

Conversation

@BetterAndBetterII

Copy link
Copy Markdown

Summary

MyST directives are tokenized as fences, so reference-style links that only appear inside an admonition/directive body were treated as unused and their definitions were stripped. Record those labels as used while rendering directive fences (including nested directives). Unused defs outside directives are still removed.

Fixes #22

Test plan

  • Added fixtures for footnote-in-admonition (already preserved) and link-ref-in-admonition (was dropped)
  • pytest tests/test_mdformat_myst.py tests/test_commonmark_compliancy.py — 717 passed

MyST directives are tokenized as fences, so mdformat never saw
reference-style links inside them and stripped the definitions.
Record those labels as used while rendering directive fences.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mdformat incorrectly removes link references that are only used in admonitions

1 participant