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

@ -99,10 +99,11 @@ module.exports.escapeForRegExp = function escapeForRegExp(str) {
};
// Returns the indent for a token
module.exports.indentFor = function indentFor(token) {
function indentFor(token) {
var line = token.line.replace(/^[\s>]*(> |>)/, "");
return line.length - trimLeft(line).length;
};
}
module.exports.indentFor = indentFor;
// Returns the heading style for a heading token
module.exports.headingStyleFor = function headingStyleFor(token) {
@ -180,6 +181,8 @@ function makeTokenCache(params) {
"parentsUnordered": !current ||
(current.unordered && current.parentsUnordered),
"open": token,
"indent": indentFor(token),
"parentIndent": (current && current.indent) || 0,
"items": [],
"nesting": stack.length - 1,
"lastLineIndex": -1,