mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Add MD004 with tests, support disabling rules.
This commit is contained in:
parent
d2e38c1646
commit
2da9462e45
13 changed files with 201 additions and 7 deletions
32
lib/rules.js
32
lib/rules.js
|
@ -14,6 +14,19 @@ function headingStyleFrom(token, lines) {
|
|||
return "setext";
|
||||
}
|
||||
|
||||
function unorderedListStyleFrom(token, lines) {
|
||||
switch (lines[token.lines[0]].trim().substr(0, 1)) {
|
||||
case "*":
|
||||
return "asterisk";
|
||||
case "-":
|
||||
return "dash";
|
||||
case "+":
|
||||
return "plus";
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function padAndTrim(lines) {
|
||||
return [].concat(
|
||||
"",
|
||||
|
@ -75,6 +88,25 @@ module.exports = [
|
|||
}
|
||||
},
|
||||
|
||||
{
|
||||
"name": "MD004",
|
||||
"desc": "Unordered list style",
|
||||
"func": function MD004(params, errors) {
|
||||
var style = params.options.style || "consistent";
|
||||
var listItems = params.tokens.filter(function filterToken(token) {
|
||||
return (token.type === "list_item_open");
|
||||
});
|
||||
if ((style === "consistent") && listItems.length) {
|
||||
style = unorderedListStyleFrom(listItems[0], params.lines);
|
||||
}
|
||||
listItems.forEach(function forToken(token) {
|
||||
if (unorderedListStyleFrom(token, params.lines) !== style) {
|
||||
errors.push(lineNumberFrom(token));
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"name": "MD031",
|
||||
"desc": "Fenced code blocks should be surrounded by blank lines",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue