Files
betterxen/scripts
Eterna 82ec02e754 docs_hygiene: validate link fragments, not just the file
check_links() only confirmed that a relative link's target file was
tracked; a `#fragment` was never checked, so a link to a renamed or
reworded heading still passed the audit.

Add markdown_slugs(), which reproduces GitHub's heading-slug rules
(lowercase, drop punctuation, spaces to hyphens, underscore and hyphen
kept) and ignores headings inside fenced code blocks. Every link whose
target is a tracked Markdown file now has its fragment checked against
that file's headings; in-page `](#foo)` links are checked against the
same file. External URLs and bare `#` links are still not fetched.

Suffix generation tracks the set of slugs already emitted globally, not
just a count per base: for headings `Foo`, `Foo-1`, `Foo` the third
must be `foo-2`, because a literal `# Foo-1` heading already owns
`foo-1`. Counting identical bases alone handed the third heading
`foo-1` too, so the audit accepted a link to the wrong heading.

Covered by the new scripts/audit/test_docs_hygiene.py (23 tests), which
fails 3 tests against the previous counting-only suffix logic.

Closes #537

Signed-off-by: Eterna <295740124+EternaPeptix@users.noreply.github.com>
2026-11-27 19:38:46 -07:00
..