Skip to content

docs: make every anchor resolve, on the wiki as well as GitHub - #542

Merged
godofecht merged 1 commit into
mainfrom
docs/anchor-integrity
Aug 18, 2026
Merged

godofecht merged 1 commit into
mainfrom
docs/anchor-integrity

Conversation

@godofecht

@godofecht godofecht commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Third of the wiki series. Independent of #540 and #541; branches from main and touches different files.

Nothing was checking anchors

Neither check_doc_links.py nor check_wiki_links.py looked at the #fragment half of a link. Both strip it and validate the path. So anchors were free to rot, and had.

I measured all 122 internal anchor links under both slug algorithms before changing anything:

internal anchor links checked: 122
  valid under GitHub slug   : 120
  valid under wiki slug     : 109
  broken under both         : 2

  work on GitHub, broken on the live wiki : 11
  work on wiki, broken on GitHub          :  0

The cause is in the wiki's own slugger

site/wiki.js has this, commented "GitHub/GFM-style heading id (matches LANGUAGE_SPEC.md TOC anchors)":

.replace(/[^\w\s-]/g, '')
.replace(/\s+/g, '-')
.replace(/-+/g, '-')     // <- GitHub does not do this

GitHub does not collapse runs of dashes. A heading like 10. Domain / DSL Surfaces loses the slash and keeps the space either side of it, so GitHub produces 10-domain--dsl-surfaces while the wiki produced 10-domain-dsl-surfaces. Every anchor an author wrote by copying it out of GitHub's rendering therefore worked there and died on the site readers actually use.

That included the entire 10. Domain / DSL Surfaces row of docs/language/spec-index.md, all four links plus the section header. That is the flow / evolves as / dynamics / field-PDE material the vision leads with, linked from the page whose one job is finding parts of the language.

Removing the collapse makes the comment true. Because 0 links depend on the collapsed form, this fixes 11 and breaks nothing.

The two that were broken everywhere

Stale heading text in the spec index, left behind when the headings were renamed:

Link Heading now reads
#36-attributes-selected ### 3.6 Attributes
#45-pipe--declarative-ordering ### 4.5 Pipe / Declarative Ordering and Search

What now guards it

check_doc_links.py validates fragments against the target page's headings, numbering repeats the way GitHub does (notes, notes-1, notes-2) and honouring hand-written <a id="...">. On failure it suggests the closest heading:

1 link(s) to a heading that does not exist:
    docs/language/spec-index.md: ../LANGUAGE_SPEC.md#36-attributes-nonexistent   (closest heading: #36-attributes)

# also came out of the EXTERNAL skip list. A same-page anchor is not an external link, and leaving it there meant 55 of them were never checked. Fragment coverage goes 0 → 122.

A unit test pins site/wiki.js itself, since the Python and JS sluggers are held together only by both refusing to collapse.

Version drift

sync_version.py gains docs/wiki-home.md. The wiki front page was advertising v0.10 and | Version | 0.10.0 | while the canonical version is 0.11.1, because the mirror list covered README.md and four others but never the wiki's own front door. Both strings now read 0.11.1, and future drift fails --check.

Validation

  • 122/122 anchors resolve under both sluggers
  • check_doc_links.py: 1408 links, 122 fragments, all resolve
  • sync_version.py --check: in sync
  • check_wiki_links.py clean, wiki rebuilds
  • Unit suite 1425 passed, 2 skipped (14 new)
  • ruff check src clean
  • Negative test: deliberately breaking an anchor makes the checker fail and name the closest heading

Neither link checker validated the fragment half of a link, so anchors were
free to rot. Measuring them turned up 11 that resolve on GitHub and are
dead on the published wiki, plus 2 dead everywhere.

The cause is in site/wiki.js. Its headingSlug is commented "GitHub/GFM-style
heading id" but ends with .replace(/-+/g, '-'), and GitHub does not collapse
runs of dashes. A heading like `10. Domain / DSL Surfaces` loses the slash
and keeps the spaces either side, so GitHub gives 10-domain--dsl-surfaces
and the wiki gave 10-domain-dsl-surfaces. Every link written against the
rendering on GitHub therefore died on the site readers actually use,
including the whole "10. Domain / DSL Surfaces" row of the language spec
index, which is the DSL feature set the vision leads with.

Removing the collapse makes the comment true. Measured both ways across all
122 internal anchor links first: 11 work on GitHub and not the wiki, 0 work
on the wiki and not GitHub, so this fixes 11 and breaks nothing.

The 2 broken everywhere were stale heading text in the spec index, pointing
at #36-attributes-selected and #45-pipe--declarative-ordering after the
headings were renamed. Both now resolve.

check_doc_links.py gains fragment validation: 122 fragments checked, with a
closest-heading suggestion on failure. `#` came out of the external-skip
list at the same time, because a same-page anchor is not an external link
and 55 of them were being skipped entirely.

sync_version.py gains docs/wiki-home.md. The wiki front page advertised
v0.10 and "Version | 0.10.0" while the canonical version is 0.11.1, because
nothing pointed the version checker at it. Both now read 0.11.1 and drift
fails the check.

122/122 anchors resolve under both sluggers. Unit 1425 passed, ruff clean.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@godofecht
godofecht merged commit 4e21bdf into main Aug 18, 2026
19 checks passed
@godofecht
godofecht deleted the docs/anchor-integrity branch August 18, 2026 09:48
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.

1 participant