fix(decision-records): respect code spans, validate link anchors - #5
Merged
Merged
Conversation
check_links scanned raw text, so a link written inside a code span or fenced block (syntax on display, not a live link) was flagged as broken; and it discarded fragments entirely, so a typo'd or stale anchor passed silently. - strip fenced blocks and inline code spans before scanning for links - validate every #fragment against the target file's headings using GitHub-style slugs (punctuation dropped, spaces to hyphens, -N suffixes for duplicates); pure #fragment links now resolve against the containing file instead of being skipped - report anchor failures as 'broken anchor' distinct from 'broken link'
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.
Problem
check_linkshad two gaps:[term](../../glossary.md#term).target.split("#", 1)[0]), soglossary.md#egres-proxypassed as long asglossary.mdexisted, and pure#fragmentintra-doc links were skipped entirely. Repos adopting glossary-term and section-heading linking get zero protection on the half of the link most likely to rot (promotion moves records between directory depths).Fix
strip_code()blanks fenced blocks and inline code spans before the link scan (line structure preserved).heading_anchors()computes GitHub-style slugs for a file's headings — lowercase, punctuation dropped, spaces→hyphens,-Nsuffixes for duplicate headings, markdown links/backticks in heading text reduced to display text (covers em-dash cases like#appendix--harnesses-evaluated-research-notes-non-binding).#fragmenton a markdown target is validated against the target's slugs; pure#fragmentlinks resolve against the containing file. Failures report asbroken anchor, distinct frombroken link.Testing
&, duplicates, fenced pseudo-headings), code-span and fenced-block links not checked, cross-file anchor validation (pass + fail), intra-doc anchor validation (pass + fail).