From 212d7abaaebf5985c16b195d761f433a90881cd2 Mon Sep 17 00:00:00 2001 From: OHTAKE Tomohiro Date: Fri, 9 Sep 2016 10:30:22 +0900 Subject: [PATCH] MD027 should support blockquote nesting --- lib/rules.js | 10 +++++----- test/blockquote_spaces.md | 8 ++++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/lib/rules.js b/lib/rules.js index 7c59e0d1..b9313ba9 100644 --- a/lib/rules.js +++ b/lib/rules.js @@ -575,17 +575,17 @@ module.exports = [ "tags": [ "blockquote", "whitespace", "indentation" ], "aliases": [ "no-multiple-space-blockquote" ], "func": function MD027(params, errors) { - var inBlockquote = false; + var blockquoteNesting = 0; params.tokens.forEach(function forToken(token) { if (token.type === "blockquote_open") { - inBlockquote = true; + blockquoteNesting++; } else if (token.type === "blockquote_close") { - inBlockquote = false; - } else if ((token.type === "inline") && inBlockquote) { + blockquoteNesting--; + } else if ((token.type === "inline") && blockquoteNesting > 0) { token.content.split(shared.newLineRe) .forEach(function forLine(line, offset) { if (/^\s/.test(line) || - (!offset && /^\s*>\s\s/.test(token.line))) { + (!offset && /^(\s*>)+\s\s/.test(token.line))) { errors.push(token.lineNumber + offset); } }); diff --git a/test/blockquote_spaces.md b/test/blockquote_spaces.md index 084c27ad..a17bd054 100644 --- a/test/blockquote_spaces.md +++ b/test/blockquote_spaces.md @@ -21,3 +21,11 @@ Test the first line being indented too much: > Foo {MD027} > Bar {MD027} > Baz + +Nested blockquote + +> A {MD027} +> +> > B {MD027} +> +> C {MD027}