mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Add "sublist" style to MD004 (fixes #21).
This commit is contained in:
parent
c8ecec1953
commit
7a1773ea77
4 changed files with 91 additions and 7 deletions
17
lib/rules.js
17
lib/rules.js
|
|
@ -224,13 +224,24 @@ module.exports = [
|
|||
"aliases": [ "ul-style" ],
|
||||
"func": function MD004(params, errors) {
|
||||
var style = params.options.style || "consistent";
|
||||
var expectedStyle = style;
|
||||
var nestingStyles = [];
|
||||
flattenLists(params).forEach(function forList(list) {
|
||||
if (list.unordered) {
|
||||
if (style === "consistent") {
|
||||
style = unorderedListStyleFor(list.items[0]);
|
||||
if (expectedStyle === "consistent") {
|
||||
expectedStyle = unorderedListStyleFor(list.items[0]);
|
||||
}
|
||||
list.items.forEach(function forItem(item) {
|
||||
if (unorderedListStyleFor(item) !== style) {
|
||||
var itemStyle = unorderedListStyleFor(item);
|
||||
if (style === "sublist") {
|
||||
var nesting = list.nesting;
|
||||
if (!nestingStyles[nesting] &&
|
||||
(itemStyle !== nestingStyles[nesting - 1])) {
|
||||
nestingStyles[nesting] = itemStyle;
|
||||
} else if (itemStyle !== nestingStyles[nesting]) {
|
||||
errors.push(item.lineNumber);
|
||||
}
|
||||
} else if (itemStyle !== expectedStyle) {
|
||||
errors.push(item.lineNumber);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue