diff --git a/lib/md004.js b/lib/md004.js index 7992a0e3..840599b2 100644 --- a/lib/md004.js +++ b/lib/md004.js @@ -4,6 +4,19 @@ var shared = require("./shared"); +// Returns the unordered list style for a list item token +function unorderedListStyleFor(token) { + switch (token.markup) { + case "-": + return "dash"; + case "+": + return "plus"; + // case "*": + default: + return "asterisk"; + } +} + module.exports = { "names": [ "MD004", "ul-style" ], "description": "Unordered list style", @@ -15,10 +28,10 @@ module.exports = { shared.flattenLists(params).forEach(function forList(list) { if (list.unordered) { if (expectedStyle === "consistent") { - expectedStyle = shared.unorderedListStyleFor(list.items[0]); + expectedStyle = unorderedListStyleFor(list.items[0]); } list.items.forEach(function forItem(item) { - var itemStyle = shared.unorderedListStyleFor(item); + var itemStyle = unorderedListStyleFor(item); if (style === "sublist") { var nesting = list.nesting; if (!nestingStyles[nesting] && diff --git a/lib/shared.js b/lib/shared.js index 43f80ba6..ffee555e 100644 --- a/lib/shared.js +++ b/lib/shared.js @@ -100,19 +100,6 @@ module.exports.headingStyleFor = function headingStyleFor(token) { return "setext"; }; -// Returns the unordered list style for a list item token -module.exports.unorderedListStyleFor = function unorderedListStyleFor(token) { - switch (trimLeft(token.line).substr(0, 1)) { - case "-": - return "dash"; - case "+": - return "plus"; - // case "*": - default: - return "asterisk"; - } -}; - // Calls the provided function for each matching token function filterTokens(params, type, callback) { (params.tokenLists[type] || []).forEach(callback); diff --git a/test/lists-in-blockquote.md b/test/lists-in-blockquote.md index 8982ac27..4c6e1c11 100644 --- a/test/lists-in-blockquote.md +++ b/test/lists-in-blockquote.md @@ -29,8 +29,8 @@ Text Text -> - Item -> - Item +> - Item {MD004} +> - Item {MD004} Text @@ -40,35 +40,35 @@ Text Text - > * Item - > * Item - > * Item {MD030} - > * Item {MD005} - > * Item {MD005} + > * Item {MD004} + > * Item {MD004} + > * Item {MD004} {MD030} + > * Item {MD004} {MD005} + > * Item {MD004} {MD005} Text > Text - > > - Item - > > - Item {MD027} - > > - Item - > > > - Item - > > > - Item {MD027} - > > > - Item {MD027} + > > - Item {MD004} + > > - Item {MD004} {MD027} + > > - Item {MD004} + > > > - Item {MD004} + > > > - Item {MD004} {MD027} + > > > - Item {MD004} {MD027} Text ->* Item -> * Item ->>* Item ->> * Item +>+ Item +> + Item +>>+ Item +>> + Item Text > Quoted text > -> * A list -> * of items +> * A list {MD004} +> * of items {MD004} > > More quoted text @@ -76,8 +76,8 @@ Text > Quoted text > -> > * A list -> > * of items +> > + A list +> > + of items > > More quoted text @@ -85,7 +85,7 @@ Text > Quoted text > -> > * A list -> > * of items +> > - A list {MD004} +> > - of items {MD004} > > > > More quoted text diff --git a/test/md004-list-items-in-blockquote.md b/test/md004-list-items-in-blockquote.md new file mode 100644 index 00000000..fc182ceb --- /dev/null +++ b/test/md004-list-items-in-blockquote.md @@ -0,0 +1,23 @@ +# Header + +Text + +- Item +- Item + +Text + +>- Item +>- Item + +Text + +> - Item +> - Item + +Text + +> > - Item +> > - Item + +Text