Update MD043/required-headings to support "?" meaning "exactly one unspecified heading" (fixes #475).

This commit is contained in:
David Anson 2025-03-10 21:57:28 -07:00
parent 06b60b7372
commit 5749c8dcf7
15 changed files with 297 additions and 18 deletions

View file

@ -5,7 +5,7 @@ structure for a set of files.
To require exactly the following structure:
```markdown
# Head
# Heading
## Item
### Detail
```
@ -14,7 +14,7 @@ Set the `headings` parameter to:
```json
[
"# Head",
"# Heading",
"## Item",
"### Detail"
]
@ -23,7 +23,7 @@ Set the `headings` parameter to:
To allow optional headings as with the following structure:
```markdown
# Head
# Heading
## Item
### Detail (optional)
## Foot
@ -36,7 +36,7 @@ special value `"+"` meaning "one or more unspecified headings" and set the
```json
[
"# Head",
"# Heading",
"## Item",
"*",
"## Foot",
@ -44,6 +44,24 @@ special value `"+"` meaning "one or more unspecified headings" and set the
]
```
To allow a single required heading to vary as with a project name:
```markdown
# Project Name
## Description
## Examples
```
Use the special value `"?"` meaning "exactly one unspecified heading":
```json
[
"?",
"## Description",
"## Examples"
]
```
When an error is detected, this rule outputs the line number of the first
problematic heading (otherwise, it outputs the last line number of the file).