Repository navigation
fix(skill-validator): match GitHub anchor algorithm for repeated whitespace - #65
Merged
Merged
Conversation
…espace `slugify` was using `re.sub(r"[\s]+", "-", text)` which collapses runs of whitespace into a single dash. GitHub's anchor renderer (and doctoc) replace each whitespace character one-for-one, so headings whose text contains an em-dash (which strips to "" between two surrounding spaces) yield double-dash anchors. Concretely, "Mode B — conversational mentoring" must slugify to `mode-b--conversational-mentoring`, matching the doctoc-generated TOC anchor in `docs/modes.md`. Validator was therefore producing single-dash slugs and reporting ~38 false-positive "anchor not found" violations against the real repo. Drop the `+` quantifier so each whitespace becomes its own dash, and update the existing `test_multiple_spaces` expectation to match the actual GitHub algorithm. Add `test_em_dash_in_heading` to pin the canonical case.
4 of 5 tasks
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.
Summary
skill-validator'sslugify()was usingre.sub(r"[\s]+", "-", text), which collapses runs of whitespace into a single dash. GitHub's anchor renderer (and doctoc, which generates our TOCs) replaces each whitespace character one-for-one, so a heading whose text contains an em-dash, like## Mode B — conversational mentoring, hasmode-b--conversational-mentoringas its real anchor (em-dash strips to"", leaving two adjacent spaces, each becoming a dash).The validator was producing
mode-b-conversational-mentoring(single dash) and reportinganchor 'X' not foundagainst the doctoc-generated TOC anchor it had just slugified differently. Runningskill-validatelocally onmaincuts from 191 violations to 153 with this single one-character fix, all of the dropped violations being false positives of this exact shape.Change
tools/skill-validator/src/skill_validator/__init__.py: drop the+quantifier fromANCHOR_SPACE_PATTERNso each whitespace becomes its own dash.tools/skill-validator/tests/test_validator.py: update the existingtest_multiple_spacesexpectation to match the actual GitHub algorithm (it had been pinning the bug), and addtest_em_dash_in_headingfor the canonical case.Why now
This unblocks wiring
skill-validatorinto prek + CI in a follow-up. With the false-positive noise removed, the remaining violations are real (broken links, missing-frontmatter keys, anchor renames the skills did not follow) and worth gating on.What this does not fix
license: Apache-2.0frontmatter (see #pending sibling PR).code-review.instructions.md.<...>placeholders inpr-management-triage/comment-templates.md(need a decision on adopter-config convention vs. literal substitution).Each is a separate, scoped follow-up.