mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Improve reporting of MD027 for lists in blockquotes.
This commit is contained in:
parent
d40a3a55fd
commit
09ae51fdaa
2 changed files with 17 additions and 9 deletions
10
lib/rules.js
10
lib/rules.js
|
|
@ -599,13 +599,21 @@ module.exports = [
|
||||||
"aliases": [ "no-multiple-space-blockquote" ],
|
"aliases": [ "no-multiple-space-blockquote" ],
|
||||||
"func": function MD027(params, errors) {
|
"func": function MD027(params, errors) {
|
||||||
var blockquoteNesting = 0;
|
var blockquoteNesting = 0;
|
||||||
|
var listItemNesting = 0;
|
||||||
params.tokens.forEach(function forToken(token) {
|
params.tokens.forEach(function forToken(token) {
|
||||||
if (token.type === "blockquote_open") {
|
if (token.type === "blockquote_open") {
|
||||||
blockquoteNesting++;
|
blockquoteNesting++;
|
||||||
} else if (token.type === "blockquote_close") {
|
} else if (token.type === "blockquote_close") {
|
||||||
blockquoteNesting--;
|
blockquoteNesting--;
|
||||||
|
} else if (token.type === "list_item_open") {
|
||||||
|
listItemNesting++;
|
||||||
|
} else if (token.type === "list_item_close") {
|
||||||
|
listItemNesting--;
|
||||||
} else if ((token.type === "inline") && (blockquoteNesting > 0)) {
|
} else if ((token.type === "inline") && (blockquoteNesting > 0)) {
|
||||||
if (/^(\s*>)+\s\s/.test(token.line)) {
|
var multipleSpaces = listItemNesting ?
|
||||||
|
/^(\s*>)+\s\s+>/.test(token.line) :
|
||||||
|
/^(\s*>)+\s\s/.test(token.line);
|
||||||
|
if (multipleSpaces) {
|
||||||
errors.addContext(token.lineNumber, token.line);
|
errors.addContext(token.lineNumber, token.line);
|
||||||
}
|
}
|
||||||
token.content.split(shared.newLineRe)
|
token.content.split(shared.newLineRe)
|
||||||
|
|
|
||||||
|
|
@ -25,26 +25,26 @@ Text
|
||||||
Text
|
Text
|
||||||
|
|
||||||
> 1. Item
|
> 1. Item
|
||||||
> 1. Item {MD027}
|
> 1. Item
|
||||||
|
|
||||||
Text
|
Text
|
||||||
|
|
||||||
> - Item
|
> - Item
|
||||||
> - Item {MD027}
|
> - Item
|
||||||
|
|
||||||
Text
|
Text
|
||||||
|
|
||||||
> 1. Item
|
> 1. Item
|
||||||
> 1. Item {MD027}
|
> 1. Item
|
||||||
> 1. Item {MD027} {MD030}
|
> 1. Item {MD030}
|
||||||
|
|
||||||
Text
|
Text
|
||||||
|
|
||||||
> * Item
|
> * Item
|
||||||
> * Item {MD027}
|
> * Item
|
||||||
> * Item {MD027} {MD030}
|
> * Item {MD030}
|
||||||
> * Item {MD027} {MD005}
|
> * Item {MD005}
|
||||||
> * Item {MD027} {MD005}
|
> * Item {MD005}
|
||||||
|
|
||||||
Text
|
Text
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue