mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Update MD003 to support setext_with_atx.
This commit is contained in:
parent
c2aff32460
commit
fd1215d143
4 changed files with 33 additions and 5 deletions
17
doc/Rules.md
17
doc/Rules.md
|
@ -53,7 +53,7 @@ The first header in the document should be a h1 header:
|
|||
|
||||
Tags: headers
|
||||
|
||||
Parameters: style ("consistent", "atx", "atx_closed", "setext"; default "consistent")
|
||||
Parameters: style ("consistent", "atx", "atx_closed", "setext", "setext_with_atx"; default "consistent")
|
||||
|
||||
This rule is triggered when different header styles (atx, setext, and 'closed'
|
||||
atx) are used in the same document:
|
||||
|
@ -71,9 +71,20 @@ 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:
|
||||
|
||||
Setext style H1
|
||||
===============
|
||||
|
||||
Setext style H2
|
||||
---------------
|
||||
|
||||
### ATX style H3
|
||||
|
||||
Note: the configured header style can be a specific style to use (atx,
|
||||
atx_closed, setext), or simply require that the usage be consistent within the
|
||||
document.
|
||||
atx_closed, setext, setext_with_atx), or simply require that the usage be
|
||||
consistent within the document.
|
||||
|
||||
## MD004 - Unordered list style
|
||||
|
||||
|
|
|
@ -173,10 +173,14 @@ module.exports = [
|
|||
"func": function MD003(params, errors) {
|
||||
var style = params.options.style || "consistent";
|
||||
filterTokens(params, "heading_open", function forToken(token) {
|
||||
var styleForToken = headingStyleFor(token);
|
||||
if (style === "consistent") {
|
||||
style = headingStyleFor(token);
|
||||
style = styleForToken;
|
||||
}
|
||||
if (headingStyleFor(token) !== style) {
|
||||
if ((styleForToken !== style) &&
|
||||
!((style === "setext_with_atx") &&
|
||||
(/h[12]/.test(token.tag) && (styleForToken === "setext")) ||
|
||||
(/h[^12]/.test(token.tag) && (styleForToken === "atx")))) {
|
||||
errors.push(token.lineNumber);
|
||||
}
|
||||
});
|
||||
|
|
6
test/headers_good_setext_with_atx.json
Normal file
6
test/headers_good_setext_with_atx.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"default": true,
|
||||
"MD003": {
|
||||
"style": "setext_with_atx"
|
||||
}
|
||||
}
|
7
test/headers_good_setext_with_atx.md
Normal file
7
test/headers_good_setext_with_atx.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
Header 1
|
||||
========
|
||||
|
||||
Header 2
|
||||
--------
|
||||
|
||||
### Header 3
|
Loading…
Add table
Add a link
Reference in a new issue