mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Add MD032 with tests, improve infrastructure.
This commit is contained in:
parent
160146ac3a
commit
aef1524308
3 changed files with 111 additions and 1 deletions
26
lib/rules.js
26
lib/rules.js
|
|
@ -26,5 +26,31 @@ module.exports = {
|
|||
}
|
||||
});
|
||||
return errors;
|
||||
},
|
||||
|
||||
"MD032": function MD032(lines) {
|
||||
// Some parsers have trouble detecting lists without surrounding
|
||||
// whitespace, so examine the lines directly.
|
||||
var errors = [];
|
||||
var inList = false;
|
||||
var inCode = false;
|
||||
var prevLine = "";
|
||||
lines.forEach(function forLine(line, lineNum) {
|
||||
if (!inCode) {
|
||||
var listMarker = line.trim().match(/^([\*\+\-]|(\d+\.))\s/);
|
||||
if (listMarker && !inList && !prevLine.match(/^($|\s)/)) {
|
||||
errors.push(lineNum + 1);
|
||||
} else if (!listMarker && inList && !line.match(/^($|\s)/)) {
|
||||
errors.push(lineNum);
|
||||
}
|
||||
inList = listMarker;
|
||||
}
|
||||
if (line.trim().match(/^(```|~~~)/)) {
|
||||
inCode = !inCode;
|
||||
inList = false;
|
||||
}
|
||||
prevLine = line;
|
||||
});
|
||||
return errors;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue