Fix possible crash in MD005/list-indent, reporting issue with MD029/ol-prefix.

This commit is contained in:
David Anson 2020-04-09 20:14:36 -07:00
parent 320acfd7cc
commit 678597485b
3 changed files with 14 additions and 8 deletions

View file

@ -19,6 +19,7 @@ module.exports = {
list.items.forEach((item) => { list.items.forEach((item) => {
const { line, lineNumber } = item; const { line, lineNumber } = item;
const actualIndent = indentFor(item); const actualIndent = indentFor(item);
let match = null;
if (list.unordered) { if (list.unordered) {
addErrorDetailIf( addErrorDetailIf(
onError, onError,
@ -30,8 +31,7 @@ module.exports = {
rangeFromRegExp(line, listItemMarkerRe) rangeFromRegExp(line, listItemMarkerRe)
// No fixInfo; MD007 handles this scenario better // No fixInfo; MD007 handles this scenario better
); );
} else { } else if ((match = orderedListItemMarkerRe.exec(line))) {
const match = orderedListItemMarkerRe.exec(line);
actualEnd = match[0].length; actualEnd = match[0].length;
expectedEnd = expectedEnd || actualEnd; expectedEnd = expectedEnd || actualEnd;
const markerLength = match[1].length + 1; const markerLength = match[1].length + 1;

View file

@ -51,13 +51,15 @@ module.exports = {
// Validate each list item marker // Validate each list item marker
items.forEach((item) => { items.forEach((item) => {
const match = orderedListItemMarkerRe.exec(item.line); const match = orderedListItemMarkerRe.exec(item.line);
if (match) {
addErrorDetailIf(onError, item.lineNumber, addErrorDetailIf(onError, item.lineNumber,
String(current), !match || match[1], String(current), match[1],
"Style: " + listStyleExamples[listStyle], null, "Style: " + listStyleExamples[listStyle], null,
rangeFromRegExp(item.line, listItemMarkerRe)); rangeFromRegExp(item.line, listItemMarkerRe));
if (listStyle === "ordered") { if (listStyle === "ordered") {
current++; current++;
} }
}
}); });
}); });
} }

View file

@ -93,3 +93,7 @@
- six - six
1. seven 1. seven
- eight - eight
* 1. Item {MD004} {MD006} {MD007}
* 2. Item {MD004} {MD006} {MD007}
* 3. Item {MD004} {MD006} {MD007}