mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
MD027 should support blockquote nesting
This commit is contained in:
parent
84ff8bb616
commit
cbfdff227e
2 changed files with 13 additions and 5 deletions
10
lib/rules.js
10
lib/rules.js
|
|
@ -575,17 +575,17 @@ module.exports = [
|
||||||
"tags": [ "blockquote", "whitespace", "indentation" ],
|
"tags": [ "blockquote", "whitespace", "indentation" ],
|
||||||
"aliases": [ "no-multiple-space-blockquote" ],
|
"aliases": [ "no-multiple-space-blockquote" ],
|
||||||
"func": function MD027(params, errors) {
|
"func": function MD027(params, errors) {
|
||||||
var inBlockquote = false;
|
var blockquoteNesting = 0;
|
||||||
params.tokens.forEach(function forToken(token) {
|
params.tokens.forEach(function forToken(token) {
|
||||||
if (token.type === "blockquote_open") {
|
if (token.type === "blockquote_open") {
|
||||||
inBlockquote = true;
|
blockquoteNesting++;
|
||||||
} else if (token.type === "blockquote_close") {
|
} else if (token.type === "blockquote_close") {
|
||||||
inBlockquote = false;
|
blockquoteNesting--;
|
||||||
} else if ((token.type === "inline") && inBlockquote) {
|
} else if ((token.type === "inline") && blockquoteNesting > 0) {
|
||||||
token.content.split(shared.newLineRe)
|
token.content.split(shared.newLineRe)
|
||||||
.forEach(function forLine(line, offset) {
|
.forEach(function forLine(line, offset) {
|
||||||
if (/^\s/.test(line) ||
|
if (/^\s/.test(line) ||
|
||||||
(!offset && /^\s*>\s\s/.test(token.line))) {
|
(!offset && /^(\s*>)+\s\s/.test(token.line))) {
|
||||||
errors.push(token.lineNumber + offset);
|
errors.push(token.lineNumber + offset);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -21,3 +21,11 @@ Test the first line being indented too much:
|
||||||
> Foo {MD027}
|
> Foo {MD027}
|
||||||
> Bar {MD027}
|
> Bar {MD027}
|
||||||
> Baz
|
> Baz
|
||||||
|
|
||||||
|
Nested blockquote
|
||||||
|
|
||||||
|
> A {MD027}
|
||||||
|
>
|
||||||
|
> > B {MD027}
|
||||||
|
>
|
||||||
|
> C {MD027}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue