mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Add style option setext_with_atx_closed to header style rule MD003
Atx-style headers which are closed can now be used with setext style headers, when at header level 3 or more.
This commit is contained in:
parent
13ee2a285b
commit
32cd4feaea
4 changed files with 23 additions and 7 deletions
11
doc/Rules.md
11
doc/Rules.md
|
@ -59,7 +59,8 @@ Tags: headers
|
|||
|
||||
Aliases: header-style
|
||||
|
||||
Parameters: style ("consistent", "atx", "atx_closed", "setext", "setext_with_atx"; default "consistent")
|
||||
Parameters: style ("consistent", "atx", "atx_closed", "setext",
|
||||
"setext_with_atx", "setext_with_atx_closed"; default "consistent")
|
||||
|
||||
This rule is triggered when different header styles (atx, setext, and 'closed'
|
||||
atx) are used in the same document:
|
||||
|
@ -77,8 +78,8 @@ Be consistent with the style of header used in a document:
|
|||
|
||||
## ATX style H2
|
||||
|
||||
The setext_with_atx doc style allows atx-style headers of level 3 or more in
|
||||
documents with setext style headers:
|
||||
The setext_with_atx and settext_with_atx_closed doc styles allows atx-style
|
||||
headers of level 3 or more in documents with setext style headers:
|
||||
|
||||
Setext style H1
|
||||
===============
|
||||
|
@ -89,8 +90,8 @@ documents with setext style headers:
|
|||
### ATX style H3
|
||||
|
||||
Note: the configured header style can be a specific style to use (atx,
|
||||
atx_closed, setext, setext_with_atx), or simply require that the usage be
|
||||
consistent within the document.
|
||||
atx_closed, setext, setext_with_atx, setext_with_atx_closed), or simply require
|
||||
that the usage be consistent within the document.
|
||||
|
||||
## MD004 - Unordered list style
|
||||
|
||||
|
|
|
@ -197,9 +197,11 @@ module.exports = [
|
|||
style = styleForToken;
|
||||
}
|
||||
if ((styleForToken !== style) &&
|
||||
!((style === "setext_with_atx") &&
|
||||
!((style === "setext_with_atx" || style === "setext_with_atx_closed") &&
|
||||
(/h[12]/.test(token.tag) && (styleForToken === "setext")) ||
|
||||
(/h[^12]/.test(token.tag) && (styleForToken === "atx")))) {
|
||||
(/h[^12]/.test(token.tag) &&
|
||||
(styleForToken === "atx" || styleForToken === "atx_closed")))
|
||||
) {
|
||||
errors.push(token.lineNumber);
|
||||
}
|
||||
});
|
||||
|
|
6
test/headers_good_setext_with_atx_closed.json
Normal file
6
test/headers_good_setext_with_atx_closed.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"default": true,
|
||||
"MD003": {
|
||||
"style": "setext_with_atx_closed"
|
||||
}
|
||||
}
|
7
test/headers_good_setext_with_atx_closed.md
Normal file
7
test/headers_good_setext_with_atx_closed.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
Header 1
|
||||
========
|
||||
|
||||
Header 2
|
||||
--------
|
||||
|
||||
### Header 3 ###
|
Loading…
Add table
Add a link
Reference in a new issue