mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 22:40:13 +01:00
Improve code to determine unordered list style for MD004/ul-style (fixes #104).
This commit is contained in:
parent
c0ea22e55e
commit
056608a680
4 changed files with 61 additions and 38 deletions
17
lib/md004.js
17
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] &&
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue