Plan 89: TOC generator directive and MDS035 auto-fix - #167
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #167 +/- ##
==========================================
+ Coverage 88.03% 89.60% +1.57%
==========================================
Files 110 112 +2
Lines 14106 12062 -2044
==========================================
- Hits 12418 10808 -1610
+ Misses 1228 796 -432
+ Partials 460 458 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Marks plan 89 as in progress and updates the generated plans catalog accordingly.
Changes:
- Update
plan/89_toc-generator-directive.mdfront-matterstatusfrom 🔲 to 🔳. - Regenerate
PLAN.mdcatalog so plan 89 shows as 🔳 in the plans table.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| plan/89_toc-generator-directive.md | Sets plan 89 status to “in progress” in front matter. |
| PLAN.md | Updates the generated catalog row for plan 89 to reflect the new status. |
Add a native <?toc?>...<?/toc?> generated-section directive (MDS038)
that emits a nested list of the document's headings linked to
GitHub-style anchors. Upgrade MDS035 to FixableRule so it replaces
[TOC], [[_TOC_]], [[toc]], and ${toc} tokens with the canonical
<?toc?>\n<?/toc?> block; a subsequent pass of the same fix run
populates the heading list via MDS038.
- Move Slugify and CollectTOCItems into internal/mdtext (shared)
- Update crossfilereferenceintegrity to call mdtext.Slugify
- Coerce integer/float YAML values to strings in ValidateStringParams
so min-level: 2 works without quoting
- New internal/rules/toc/ package registers as MDS038 (category meta,
enabled by default, fixable), with min-level/max-level params
- MDS035 Fix inserts blank lines around the replacement block;
leaves [TOC] untouched when a link-ref definition is present
- MDS035 diagnostic message updated to name <?toc?> (MDS038)
- Integration test TestMultiPassFix_TOCDirective verifies end-to-end
[TOC] → populated <?toc?> block in one mdsmith fix run
- Update MDS035 README, generated-section archetype doc, and
docs/background/markdown-linters.md to reflect all changes
https://claude.ai/code/session_01CBgiv6yda2F489zPYiNPYu
Cover lines introduced in this PR that were missing test coverage: - mdtext: add Slugify and CollectTOCItems unit tests (including empty-slug skip branch) - gensection/engine: add float64 integer-valued and fractional-valued coercion tests for ValidateStringParams - toc/rule: add TestValidate_InvalidMaxLevel and TestGenerate_InvalidParams to cover the remaining parseLevels and Generate branches - tocdirective/rule: add nil-file tests for Check and Fix to cover defensive nil guards https://claude.ai/code/session_01CBgiv6yda2F489zPYiNPYu
Fixed multiple issues identified in Copilot review: 1. MDS035 Fix now uses AST-based approach (same as Check) to avoid rewriting TOC tokens inside code blocks 2. Anchor disambiguation now guarantees unique anchors by tracking all used anchors, not just base slugs 3. TOC link text now escapes special characters (], [, \) that would break Markdown link syntax 4. Added tests for special characters in headings and code blocks 5. Refactored Fix method to reduce cognitive complexity (35 → <30) All tests pass, linter clean. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Co-authored-by: jeduden <1117699+jeduden@users.noreply.github.com>
|
🟢 Merge Queue — picked up This PR is in the queue and will be batched with other Next: No action needed — you'll get another comment when CI starts on the batch. View merge queue run. |
|
🔵 Merge Queue — CI running Merged into batch branch Next: No action needed — you'll be notified when CI completes. |
|
✅ Merge Queue — merged This PR landed on Next: Done — nothing more to do here. |
Summary
<?toc?>...<?/toc?>generated-section directive (MDS038) and MDS035 auto-fixWhat was built
<?toc?>directive that generates a nested heading list linked to GitHub-style anchors;min-level/max-levelparams; stack-based depth tracking for non-contiguous levels; duplicate-heading disambiguation[TOC],[[_TOC_]],[[toc]],${toc}with<?toc?>\n<?/toc?>blocks; a second fix pass populates the heading list via MDS038; leaves[TOC]untouched when a link-ref definition is presentSlugifyandCollectTOCItemsmoved tointernal/mdtext; integer/float YAML params coerced to strings inValidateStringParamssomin-level: 2works unquotedTestMultiPassFix_TOCDirectiveverifies[TOC]→ populated<?toc?>block in onemdsmith fixrunSee plan/89_toc-generator-directive.md for full design and acceptance criteria.
https://claude.ai/code/session_01CBgiv6yda2F489zPYiNPYu