Fix two bugs with bare list marker handling.

This commit is contained in:
David Anson 2015-05-03 20:48:07 -07:00
parent dab36c5afa
commit 6a8f31ddad
2 changed files with 13 additions and 3 deletions

View file

@ -90,7 +90,7 @@ function flattenLists(tokens, filterBy) {
var lists = [];
var stack = [];
var current = null;
var lastWithMap = null;
var lastWithMap = { "map": [ 0, 1 ] };
tokens.forEach(function forToken(token) {
if ((token.type === "bullet_list_open") ||
(token.type === "ordered_list_open")) {
@ -542,7 +542,7 @@ module.exports = [
flattenLists(params.tokens, true).forEach(function forList(list) {
var number = 1;
list.items.forEach(function forItem(item) {
var re = new RegExp("^\\s*" + String(number) + "\\. ");
var re = new RegExp("^\\s*" + String(number) + "\\.");
if (!re.test(item.line)) {
errors.push(item.lineNumber);
}
@ -571,7 +571,7 @@ module.exports = [
(allSingle ? ulSingle : ulMulti);
list.items.forEach(function forItem(item) {
var match = /^\s*\S+(\s+)/.exec(item.line);
if (match[1].length !== expectedSpaces) {
if (!match || (match[1].length !== expectedSpaces)) {
errors.push(item.lineNumber);
}
});

10
test/bare-list-markers.md Normal file
View file

@ -0,0 +1,10 @@
*
+
-
1.
{MD004:3}{MD004:5}
{MD030:1}{MD030:3}{MD030:5}{MD030:7}