Update MD001/heading-increment to support front matter title as the first heading of the page.

This commit is contained in:
Alexandre Feblot 2025-06-07 04:54:23 +02:00 committed by GitHub
parent a366f80873
commit 1b6839bff0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 317 additions and 16 deletions

View file

@ -12,6 +12,11 @@ Tags: `headings`
Aliases: `heading-increment`
Parameters:
- `front_matter_title`: RegExp for matching title in front matter (`string`,
default `^\s*title\s*[:=]`)
This rule is triggered when you skip heading levels in a Markdown document, for
example:
@ -40,6 +45,15 @@ level at a time:
### Another Heading 3
```
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.
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/>.

View file

@ -4,6 +4,11 @@ Tags: `headings`
Aliases: `heading-increment`
Parameters:
- `front_matter_title`: RegExp for matching title in front matter (`string`,
default `^\s*title\s*[:=]`)
This rule is triggered when you skip heading levels in a Markdown document, for
example:
@ -32,6 +37,15 @@ level at a time:
### Another Heading 3
```
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.
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/>.