mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Add MD012, MD028 with tests, support multiple markers by line.
This commit is contained in:
parent
f35d690fb1
commit
c864ac1b96
4 changed files with 85 additions and 3 deletions
39
lib/rules.js
39
lib/rules.js
|
|
@ -212,6 +212,45 @@ module.exports = [
|
|||
}
|
||||
},
|
||||
|
||||
{
|
||||
"name": "MD012",
|
||||
"desc": "Multiple consecutive blank lines",
|
||||
"func": function MD012(params, errors) {
|
||||
var exclusions = [];
|
||||
params.tokens.filter(function filterToken(token) {
|
||||
return ((token.type === "code_block") || (token.type === "fence"));
|
||||
}).forEach(function forToken(token) {
|
||||
for (var i = token.lines[0] ; i < token.lines[1] ; i++) {
|
||||
exclusions.push(i);
|
||||
}
|
||||
});
|
||||
var prevLine = "-";
|
||||
params.lines.forEach(function forLine(line, lineIndex) {
|
||||
line = line.trim();
|
||||
if (!line.length && !prevLine.length &&
|
||||
(exclusions.indexOf(lineIndex) === -1)) {
|
||||
errors.push(lineIndex + 1);
|
||||
}
|
||||
prevLine = line;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"name": "MD028",
|
||||
"desc": "Blank line inside blockquote",
|
||||
"func": function MD028(params, errors) {
|
||||
var prevToken = {};
|
||||
params.tokens.forEach(function forToken(token) {
|
||||
if ((token.type === "blockquote_open") &&
|
||||
(prevToken.type === "blockquote_close")) {
|
||||
errors.push(token.lineNumber - 1);
|
||||
}
|
||||
prevToken = token;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"name": "MD031",
|
||||
"desc": "Fenced code blocks should be surrounded by blank lines",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue