mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Add test for new behavior, refactor to fix and clarify.
This commit is contained in:
parent
d06681198a
commit
f866fac2d3
3 changed files with 18 additions and 7 deletions
19
lib/rules.js
19
lib/rules.js
|
@ -196,14 +196,21 @@ module.exports = [
|
|||
if (style === "consistent") {
|
||||
style = styleForToken;
|
||||
}
|
||||
if ((styleForToken !== style) &&
|
||||
!((style === "setext_with_atx" || style === "setext_with_atx_closed") &&
|
||||
(/h[12]/.test(token.tag) && (styleForToken === "setext")) ||
|
||||
(/h[^12]/.test(token.tag) &&
|
||||
(styleForToken === "atx" || styleForToken === "atx_closed")))
|
||||
) {
|
||||
if (styleForToken !== style) {
|
||||
var h12 = /h[12]/.test(token.tag);
|
||||
var hOther = /h[^12]/.test(token.tag);
|
||||
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);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
|
|
@ -5,3 +5,5 @@ Header 2
|
|||
--------
|
||||
|
||||
### Header 3
|
||||
|
||||
#### Header 4 {MD003} ####
|
||||
|
|
|
@ -5,3 +5,5 @@ Header 2
|
|||
--------
|
||||
|
||||
### Header 3 ###
|
||||
|
||||
#### Header 4 {MD003}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue