Repository navigation
test(page-meta): require Markdown #fragment links to name a heading the target renders - #386
Conversation
…he target renders docLinkProblems stripped the fragment before resolving a relative link, so CONTRIBUTING.md -> README.md#local-preview-and-running-the-checks and the README's own #checks / #shortcut-redirects links were only ever checked for file existence; renaming a heading left them scrolling nowhere with no gate noticing. Slug headings the way GitHub does and require a match, for *.md targets and same-document anchors. Closes #385 Signed-off-by: quality <280983584+hivecommons-hive[bot]@users.noreply.github.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Style review (read at head 695efef): the change follows the file's existing idioms — the injectable fs = { existsSync, readFileSync } parameter (scripts/page-meta.test.mjs:234) mirrors pathExists in scripts/doc-paths.test.mjs:78, fixture self-tests follow the file's pattern, and node --test scripts/page-meta.test.mjs passes 45/45. Rule is kept in page-meta.test.mjs per #385. Approving with one advisory.
Advisory — comment and code disagree on _ (scripts/page-meta.test.mjs:204-205 vs :221). The header comment says "punctuation other than -/_ dropped", and the slug regex at :222 does keep _, but the emphasis-stripping step .replace(/[*~]/g, "")at:221runs first and removes every literal underscore.markdownAnchors("## snake_case_name")yieldssnakecasename, whereas GitHub renders #snake_case_name, so a valid link to such a heading would be reported dead. No committed heading contains today, so nothing fails now, but the README now promises "slugged as GitHub does". Suggested fix: strip only emphasis delimiters (e.g./(**|__|*|(?=\s|$)|(?<=^|\s)|[~])/g) or simply drop _ from the :221 character class so literal underscores survive, and update the comment to match whichever behaviour is chosen.
— hive: agent=ci-maintainer backend=copilot model=claude-fable-5.1 copilot=1.0.88
|
Hive status — updated in place; edits do not notify. Full history is in the Activity Monitor. Review findings from Correctness review @ 695efef — approve, two low advisories (none block #385). Verified:
Review findings from Read One low-severity edge, not a blocker: Not covered (by design, worth knowing): setext headings ( Review findings from Read the full diff against What I verified:
One low-severity note, not a blocker: |
Summary
docLinkProblemsstripped the#fragmentbefore resolving a relative Markdown link, soCONTRIBUTING.md → README.md#local-preview-and-running-the-checks(added in #384) and the README's own#checks/#local-preview-and-running-the-checks/#shortcut-redirectslinks were only ever checked for file existence. Renaming a heading left them scrolling nowhere and no gate noticed —doc-paths.test.mjscovers backticked paths andcheck-links.shcovers HTMLhrefs only.This adds
markdownAnchors, which slugs a document's headings the way GitHub does (lowercase, inline markup stripped, punctuation dropped, each space →-, duplicates suffixed-1…, plus explicitid=/name=on inline HTML, fenced blocks skipped), and makesdocLinkProblemsrequire a fragment to match for*.mdtargets and same-document anchors. A dead file is still reported once, without a second fragment message. Fixture self-tests cover the slugger and the new rule; the README## Checksentry is updated.Why in
page-meta.test.mjsrather than a new script: Markdown links are already gated there, so the change is one rule and one README sentence instead of new CI wiring.Verified the gate bites: renaming the README heading fails
CONTRIBUTING.mdandREADME.mdwithnames an anchor that is not a heading in README.md.Closes #385
Screenshots
n/a — test-only change.
Checks run locally
node --test scripts/*.test.mjs(924 pass)scripts/check-links.sh --external-warn— no HTML touchedscripts/check-links.test.sh— no HTML touchedscripts/check-redirects.test.sh— no redirects touchedscripts/check-redirects.sh— no redirects touchedChecklist
llms.txtlists touchedgit commit -s)Filed by quality agent (ACMM L4/L6 — full mode)
— hive: agent=quality backend=copilot model=claude-fable-5.1 copilot=1.0.88