2022-10-30 15:13:19 -07:00
|
|
|
# `MD001` - Heading levels should only increment by one level at a time
|
2022-10-29 23:21:45 -07:00
|
|
|
|
2023-11-09 20:05:30 -08:00
|
|
|
Tags: `headings`
|
2022-10-29 23:21:45 -07:00
|
|
|
|
2023-11-09 20:05:30 -08:00
|
|
|
Aliases: `heading-increment`
|
2022-10-29 23:21:45 -07:00
|
|
|
|
2025-06-07 04:54:23 +02:00
|
|
|
Parameters:
|
|
|
|
|
|
|
|
- `front_matter_title`: RegExp for matching title in front matter (`string`,
|
|
|
|
default `^\s*title\s*[:=]`)
|
|
|
|
|
2022-10-29 23:21:45 -07:00
|
|
|
This rule is triggered when you skip heading levels in a Markdown document, for
|
|
|
|
example:
|
|
|
|
|
|
|
|
```markdown
|
|
|
|
# Heading 1
|
|
|
|
|
|
|
|
### Heading 3
|
|
|
|
|
|
|
|
We skipped out a 2nd level heading in this document
|
|
|
|
```
|
|
|
|
|
|
|
|
When using multiple heading levels, nested headings should increase by only one
|
|
|
|
level at a time:
|
|
|
|
|
|
|
|
```markdown
|
|
|
|
# Heading 1
|
|
|
|
|
|
|
|
## Heading 2
|
|
|
|
|
|
|
|
### Heading 3
|
|
|
|
|
|
|
|
#### Heading 4
|
|
|
|
|
|
|
|
## Another Heading 2
|
|
|
|
|
|
|
|
### Another Heading 3
|
|
|
|
```
|
|
|
|
|
2025-06-07 04:54:23 +02:00
|
|
|
If [YAML](https://en.wikipedia.org/wiki/YAML) front matter is present and
|
|
|
|
contains a `title` property (commonly used with blog posts), this rule treats
|
|
|
|
that as a top level heading and will report a violation if the actual first
|
|
|
|
heading is not a level 2 heading. To use a different property name in the
|
|
|
|
front matter, specify the text of a regular expression via the
|
|
|
|
`front_matter_title` parameter. To disable the use of front matter by this
|
|
|
|
rule, specify `""` for `front_matter_title`. When front matter is not present,
|
|
|
|
the first heading can be any level.
|
|
|
|
|
2022-10-29 23:21:45 -07:00
|
|
|
Rationale: Headings represent the structure of a document and can be confusing
|
|
|
|
when skipped - especially for accessibility scenarios. More information:
|
|
|
|
<https://www.w3.org/WAI/tutorials/page-structure/headings/>.
|