feat: check reference-style links - #11
Merged
Merged
Conversation
added 2 commits
August 11, 2026 15:34
Only inline [text](target) links were resolved, so every reference form was a silent pass — a dead target behind a label went unreported. This was the known gap left open at 0.3.0. All three CommonMark forms now resolve against the document's [label]: target definitions: full [text][label], collapsed [text][], and shortcut [text]. Labels match case-insensitively with whitespace collapsed; definitions may carry a title or <angle-bracket> target, may be indented, and the first definition of a repeated label wins. An explicit reference with no definition is an error: [text][label] without a matching definition renders as literal text, so the link does not exist — a refuted claim, not an unverifiable one. Findings quote the reference form rather than inline syntax the reader would not find. Three false-positive classes closed while building it, each found by probing real markdown shapes rather than by the corpus: - Undefined SHORTCUT references are ordinary prose. "[3]" and "[TODO]" only become links when a definition exists; flagging them would fire on any bracketed text, including every [Unreleased] changelog heading. - GFM footnotes share reference syntax exactly. "[^1]" against "[^1]: Sourced" parsed as a link whose target was the footnote body, flagging "Sourced" as a missing file. The ^ namespace is excluded. - Definition indentation is accepted beyond CommonMark's three-space cap. A definition nested under a list item is real and common, and missing one turns its reference into an error-severity false positive — the costlier direction. Fenced blocks are masked before definitions are read; indented code blocks are not modelled anywhere in the extractor, so this stays consistent with the rest of it. Definitions inside code fences correctly do not define, since a renderer does not read them out of a code block. 153 tests pass, coverage 96% (_extract.py 100%), mutation score 81.3% against a 75% gate.
Promotes the reference-style link work to a release. Additive feature -> minor bump. Two version sites (pyproject, __init__) plus the changelog promotion; test_packaging pins the two versions equal.
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.
Closes the known gap left open at 0.3.0: only inline
[text](target)links were resolved, so every reference form was a silent pass — a dead target behind a label went unreported.What now works
All three CommonMark forms resolve against the document's
[label]: targetdefinitions:[the guide][guide][guide][][guide]Labels match case-insensitively with whitespace collapsed. Definitions may carry a title or
<angle-bracket>target, may be indented, and the first definition of a repeated label wins.An explicit reference with no definition is an error.
[text][label]without a matching definition renders as literal text — the link does not exist, which is a refuted claim rather than an unverifiable one. Findings quote the reference form ([text][label]) rather than inline syntax the reader would not find in their document.Three false-positive classes closed while building it
Each found by probing real markdown shapes, not by the corpus:
[3]and[TODO]only become links when a definition exists. Flagging them would fire on any bracketed text — including every[Unreleased]heading in a Keep a Changelog file. This is the whole reason shortcut support is safe to have.[^1]against[^1]: Sourcedparsed as a link whose target was the footnote body, flaggingSourcedas a missing file. The^namespace is now excluded.Definitions inside code fences correctly do not define — a renderer doesn't read them out of a code block, so a reference depending on one is properly reported as undefined.
Verification
_extract.py100%ruff+blackcleanVersion left at 0.3.0 with the entry under
[Unreleased]; this is additive, so the next release is a 0.4.0 minor.🤖 Generated with Claude Code