mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 22:40:13 +01:00
Allow '0'- and ' '-prefixed ordered list markers in MD005/MD029 (fixes #126).
This commit is contained in:
parent
2710c375b3
commit
4a1e42d942
7 changed files with 190 additions and 8 deletions
28
lib/md005.js
28
lib/md005.js
|
|
@ -10,10 +10,32 @@ module.exports = {
|
|||
"tags": [ "bullet", "ul", "indentation" ],
|
||||
"function": function MD005(params, onError) {
|
||||
shared.flattenLists().forEach(function forList(list) {
|
||||
const expectedIndent = list.indent;
|
||||
let expectedEnd = 0;
|
||||
let actualEnd = -1;
|
||||
let endMatching = false;
|
||||
list.items.forEach(function forItem(item) {
|
||||
shared.addErrorDetailIf(onError, item.lineNumber, list.indent,
|
||||
shared.indentFor(item), null,
|
||||
shared.rangeFromRegExp(item.line, shared.listItemMarkerRe));
|
||||
const actualIndent = shared.indentFor(item);
|
||||
if (list.unordered) {
|
||||
shared.addErrorDetailIf(onError, item.lineNumber,
|
||||
expectedIndent, actualIndent, null,
|
||||
shared.rangeFromRegExp(item.line, shared.listItemMarkerRe));
|
||||
} else {
|
||||
const match = shared.orderedListItemMarkerRe.exec(item.line);
|
||||
actualEnd = match && match[0].length;
|
||||
expectedEnd = expectedEnd || actualEnd;
|
||||
if ((expectedIndent !== actualIndent) || endMatching) {
|
||||
if (expectedEnd === actualEnd) {
|
||||
endMatching = true;
|
||||
} else {
|
||||
const detail = endMatching ?
|
||||
`Expected: (${expectedEnd}); Actual: (${actualEnd})` :
|
||||
`Expected: ${expectedIndent}; Actual: ${actualIndent}`;
|
||||
shared.addError(onError, item.lineNumber, detail, null,
|
||||
shared.rangeFromRegExp(item.line, shared.listItemMarkerRe));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue