@@ -5,22 +5,21 @@ status: "🔲"
55summary : >-
66 New rule MDS035 that flags renderer-specific
77 table-of-contents directives (`[TOC]`,
8- `[[_TOC_]]`, `[[toc]]`, `${toc}`) that render as
9- empty text on CommonMark / goldmark, and
10- suggests mdsmith's `<?catalog?>` directive as
11- the portable replacement.
8+ `[[_TOC_]]`, `[[toc]]`, `${toc}`) that render
9+ as empty text on CommonMark / goldmark. The
10+ diagnostic points authors at mdsmith's
11+ `<?catalog?>` directive for the file-index use
12+ case; heading-level TOCs have no direct
13+ mdsmith equivalent.
1214---
1315# TOC directive migration aid
1416
1517## Goal
1618
17- Catch renderer-specific TOC directives. These
18- disappear when rendered by CommonMark or
19- goldmark. Suggest the [ ` <?catalog?> ` ] [ catalog ]
20- directive as a portable, regenerable
21- replacement.
22-
23- [ catalog ] : ../internal/rules/MDS019-catalog/README.md
19+ Catch renderer-specific TOC directives that do
20+ not render on CommonMark or goldmark. The
21+ diagnostic tells authors which use case has a
22+ mdsmith equivalent and which does not.
2423
2524## Context
2625
@@ -42,29 +41,49 @@ parse as plain text in a paragraph. The
4241directive simply disappears from the rendered
4342output, which is a silent failure.
4443
44+ ### Heading TOC vs file index
45+
46+ The flagged directives and
47+ [ ` <?catalog?> ` ] [ catalog ] solve different
48+ problems:
49+
50+ | Directive | Generates | Input |
51+ | ----------------| -------------------------------------------| --------------------|
52+ | ` [TOC] ` et al. | Table of ** headings in the current file** | Current doc |
53+ | ` <?catalog?> ` | Table of ** other files** matching a glob | Glob + frontmatter |
54+
55+ [ catalog ] : ../internal/rules/MDS019-catalog/README.md
56+
57+ ` <?catalog?> ` is the right replacement only
58+ when a directive is used on an index page to
59+ list sibling or child documents (e.g. a wiki
60+ homepage with ` [[_TOC_]] ` listing all pages in
61+ the space). For in-document heading TOCs — the
62+ more common case — mdsmith has no built-in
63+ generator; the author must either drop the
64+ directive or maintain a manual list.
65+
4566### Why this rule, not MDS034
4667
4768MDS034 ([ plan 86] ( 86_markdown-flavor-validation.md ) )
4869validates syntax support against a declared
4970flavor. TOC directives are not "flavor features"
50- — they are per-renderer conventions that overlap
51- with mdsmith's own
52- [ ` <?catalog?> ` ] [ catalog ] directive.
53-
54- mdsmith already solves the portable-TOC problem:
55- ` <?catalog?> ` generates a table in-source,
56- regenerated by ` mdsmith fix ` . A dedicated rule
57- for detecting external TOC directives gives
58- migrators a direct on-ramp.
71+ — they are per-renderer conventions with no
72+ canonical spec and no fix path that applies to
73+ every call site. A dedicated opt-in rule with a
74+ diagnostic tailored to the use-case distinction
75+ above is a better fit than folding them into
76+ MDS034's fix pipeline.
5977
6078### Scope
6179
6280Flag only the four directives above. Do not try
6381to auto-generate a ` <?catalog?> ` block — the
6482right glob and front-matter fields depend on the
6583project and are not knowable from the TOC call
66- site. The diagnostic is informational: "this
67- directive will not render; see catalog rule".
84+ site. The diagnostic is informational and names
85+ both the file-index case (points to MDS019) and
86+ the heading-TOC case (no equivalent).
6887
6988## Design
7089
@@ -94,19 +113,19 @@ opt-in posture. No settings.
94113
95114### Error message
96115
97- ` "[TOC]" does not render on CommonMark; use the `
98- ` <?catalog?> directive (see MDS019) `
116+ ``` text
117+ [TOC] does not render on CommonMark or goldmark; mdsmith has no heading-TOC generator. For file-index use cases, see <?catalog?> (MDS019).
118+ ```
99119
100120Severity: ` warning ` .
101121
102122### No auto-fix
103123
104- The rule is detection-only. Auto-generating a
105- ` <?catalog?> ` block would require knowing the
106- project's document glob and front-matter
107- schema. The diagnostic links to the catalog
108- rule README so the author can craft the
109- replacement.
124+ The rule is detection-only. Whether the right
125+ replacement is ` <?catalog?> ` , a manually
126+ maintained list, or deletion depends on intent
127+ that is not recoverable from the directive
128+ alone.
110129
111130## Tasks
112131
@@ -126,8 +145,9 @@ replacement.
126145## Acceptance Criteria
127146
128147- [ ] ` [TOC] ` on its own line produces a
129- diagnostic that names the ` <?catalog?> `
130- replacement
148+ diagnostic that names both the heading-TOC
149+ gap and the ` <?catalog?> ` file-index
150+ alternative
131151- [ ] ` [[_TOC_]] ` on its own line produces the
132152 same diagnostic
133153- [ ] ` [[toc]] ` on its own line produces the
0 commit comments