You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 5be11fb
Browse filesBrowse the repository at this point in the historyBrowse files
feat: heading-numbering support 0-based sections and multiple positive fixtures
- Treat section as 0-based when first numbered sibling's last segment is 0 (e.g. 0., 0.0., 1.0.).
- Rename positive.md to positive_general.md; add positive_heading_numbering_zero.md.
- Verifier and tests now support multiple positive_*.md fixtures.
- Enforce segment count by numbering root, sequential numbering per section, and consistent period style (e.g. `1. Title` vs `1 Title`).
24
-
- Use when: docs use numbered headings (e.g. `### 1.2.3 Title`) and you want structure and style consistent.
24
+
Default is 1-based (1., 2., 3.); if the first numbered heading in a section starts at 0 (e.g. `0.`, `0.0.`), that section is treated as 0-based and no error is reported.
25
+
- Use when: docs use numbered headings (e.g. `### 1.2.3 Title` or 0-based `### 0. Introduction`) and you want structure and style consistent.
25
26
-[heading-title-case.js](markdownlint-rules/heading-title-case.js) - heading title case.
26
27
- Enforce title case for headings; words in backticks ignored; configurable lowercase words (e.g. vs, and, the).
27
28
- Use when: you want consistent capitalization of headings (first/last and major words capped; small words lowercase in the middle).
@@ -40,7 +41,7 @@ Lint and docs-as-code tooling: custom [markdownlint](https://github.com/DavidAns
40
41
- Use when: copying the rule files; required by several of the rules above.
41
42
42
43
-**JS linting** for the rule code: ESLint (recommended + complexity/max-lines + eslint-plugin-security), aligned with the GitHub Actions workflow.
43
-
-**Markdownlint fixture tests**: [md_test_files/](md_test_files/README.md) includes positive/negative fixtures with explicit expected errors, verified by `test-scripts/verify_markdownlint_fixtures.py`.
44
+
-**Markdownlint fixture tests**: [md_test_files/](md_test_files/README.md) includes positive_*.md and negative_*.md fixtures with explicit expected errors, verified by `test-scripts/verify_markdownlint_fixtures.py`.
44
45
-**Rule unit tests**: Node `node:test` unit tests for each custom rule in `test/markdownlint-rules/` (including security tests for defensive regex handling and ReDoS awareness); run with `make test-rules` or `npm run test:rules`.
45
46
CI runs `make test-rules-coverage` (fails if any rule file is below 90% line/statement coverage).
46
47
-**Python unit tests**: `unittest` tests for [test-scripts/](test-scripts/README.md) in `test-scripts/test_*.py`; run with `make test-python`.
@@ -128,7 +129,7 @@ npm install
128
129
-**`Makefile`** - Local targets (kept in sync with the workflows in `.github/workflows/`).
129
130
-**`markdownlint-rules/`** - Custom rule modules (`*.js`) and [README](markdownlint-rules/README.md).
130
131
Copy into other repos as `.markdownlint-rules`; do not register `utils.js`.
131
-
-**`md_test_files/`** - Test fixtures: `positive.md` (must pass), `negative_*.md` (must fail).
132
+
-**`md_test_files/`** - Test fixtures: `positive_*.md` (must pass), `negative_*.md` (must fail).
132
133
See [md_test_files/README.md](md_test_files/README.md).
Copy file name to clipboardExpand all lines: markdownlint-rules/README.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -327,7 +327,8 @@ The first occurrence is the reference; duplicates are reported with the line num
327
327
The numbering root is the nearest ancestor heading that has no numbering (or document root, level 1).
328
328
Example: H2 under doc root -> 1 segment; H3 under unnumbered `## Section` -> 1 segment; H4 under `### 1. First` -> 1 segment.
329
329
Headings without a numeric prefix are ignored.
330
-
2. **Section-scoped consistency:** For each section (siblings under the same parent), if any sibling has numbering then all siblings at that level must be numbered sequentially (e.g. 1., 2., 3.) and use consistent period style (all `## 1. Title` or all `## 1 Title`).
330
+
2. **Section-scoped consistency:** For each section (siblings under the same parent), if any sibling has numbering then all siblings at that level must be numbered sequentially and use consistent period style (all `## 1. Title` or all `## 1 Title`).
331
+
**Index base:** Default is 1-based (e.g. 1., 2., 3.). If the first numbered sibling in a section has last segment `0` (e.g. `0.`, `0.0.`, `1.0.`), that section is treated as 0-based (0., 1., 2. or 0.0., 0.1., etc.) and no sequence error is reported.
331
332
Unnumbered siblings in a numbered section are reported.
| negative_inline_html.md | allow-custom-anchors (attribute, id pattern, end-of-line) |
21
22
22
23
Note: some negative fixtures intentionally trigger built-in markdownlint rules in addition to custom rules (e.g. MD031/MD032/MD033), so the test suite can assert multiple errors on specific lines.
Expect: heading-numbering (segment count, sequence, period style, unnumbered sibling). All examples are H3/H4 under one H2 so only this section is affected.
5
+
Expect: heading-numbering (segment count, sequence, period style, unnumbered sibling, zero-indexed violations). First block is H3/H4 under one H2; second block covers zero-indexed numbering errors.
6
6
7
7
## Bad Heading Numbering
8
8
@@ -23,3 +23,19 @@ Wrong segment count: H3 under H2 must have 1 segment, not 2.
23
23
### 1.1 Wrong Segment Count
24
24
25
25
#### 1.1.1 Too Many Segments for H4
26
+
27
+
## Zero-Indexed Numbering (Negative Examples)
28
+
29
+
0-based section: first heading is 0., so sequence must be 0, 1, 2, ... Violations below.
30
+
31
+
### 0. Zero-Based Section
32
+
33
+
### 2. Skip 1 (0-Based Sequence; Expected 1.)
34
+
35
+
0-based subsections under 0.: first is 0.0., so next must be 0.1., not 0.2.
0 commit comments