Merge branch 'ciwchris-master' (fixes #12).

This commit is contained in:
David Anson 2016-02-24 21:13:07 -08:00
commit dbf909b184
5 changed files with 37 additions and 10 deletions

View file

@ -59,7 +59,8 @@ Tags: headers
Aliases: header-style 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' This rule is triggered when different header styles (atx, setext, and 'closed'
atx) are used in the same document: 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 ## ATX style H2
The setext_with_atx doc style allows atx-style headers of level 3 or more in The setext_with_atx and settext_with_atx_closed doc styles allow atx-style
documents with setext style headers: headers of level 3 or more in documents with setext style headers:
Setext style H1 Setext style H1
=============== ===============
@ -89,8 +90,8 @@ documents with setext style headers:
### ATX style H3 ### ATX style H3
Note: the configured header style can be a specific style to use (atx, 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 atx_closed, setext, setext_with_atx, setext_with_atx_closed), or simply require
consistent within the document. that the usage be consistent within the document.
## MD004 - Unordered list style ## MD004 - Unordered list style

View file

@ -196,12 +196,21 @@ module.exports = [
if (style === "consistent") { if (style === "consistent") {
style = styleForToken; style = styleForToken;
} }
if ((styleForToken !== style) && if (styleForToken !== style) {
!((style === "setext_with_atx") && var h12 = /h[12]/.test(token.tag);
(/h[12]/.test(token.tag) && (styleForToken === "setext")) || var hOther = /h[^12]/.test(token.tag);
(/h[^12]/.test(token.tag) && (styleForToken === "atx")))) { var setextWithAtx =
(style === "setext_with_atx") &&
((h12 && (styleForToken === "setext")) ||
(hOther && (styleForToken === "atx")));
var setextWithAtxClosed =
(style === "setext_with_atx_closed") &&
((h12 && (styleForToken === "setext")) ||
(hOther && (styleForToken === "atx_closed")));
if (!setextWithAtx && !setextWithAtxClosed) {
errors.push(token.lineNumber); errors.push(token.lineNumber);
} }
}
}); });
} }
}, },

View file

@ -5,3 +5,5 @@ Header 2
-------- --------
### Header 3 ### Header 3
#### Header 4 {MD003} ####

View file

@ -0,0 +1,6 @@
{
"default": true,
"MD003": {
"style": "setext_with_atx_closed"
}
}

View file

@ -0,0 +1,9 @@
Header 1
========
Header 2
--------
### Header 3 ###
#### Header 4 {MD003}