Fix MD007/ul-indent to use parent indent instead of previous indent (fixes #106).

This commit is contained in:
David Anson 2018-03-05 20:56:12 -08:00
parent 748c8cac17
commit 40ace5bb5e
6 changed files with 58 additions and 15 deletions

View file

@ -10,16 +10,11 @@ module.exports = {
"tags": [ "bullet", "ul", "indentation" ],
"function": function MD007(params, onError) {
var optionsIndent = params.config.indent || 2;
var prevIndent = 0;
shared.flattenLists().forEach(function forList(list) {
if (list.unordered && list.parentsUnordered) {
var indent = shared.indentFor(list.open);
if (indent > prevIndent) {
shared.addErrorDetailIf(onError, list.open.lineNumber,
prevIndent + optionsIndent, indent, null,
shared.rangeFromRegExp(list.open.line, shared.listItemMarkerRe));
}
prevIndent = indent;
if (list.unordered && list.parentsUnordered && list.indent) {
shared.addErrorDetailIf(onError, list.open.lineNumber,
list.parentIndent + optionsIndent, list.indent, null,
shared.rangeFromRegExp(list.open.line, shared.listItemMarkerRe));
}
});
}