mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +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" ],
|
||||
"func": function MD027(params, errors) {
|
||||
var blockquoteNesting = 0;
|
||||
var listItemNesting = 0;
|
||||
params.tokens.forEach(function forToken(token) {
|
||||
if (token.type === "blockquote_open") {
|
||||
blockquoteNesting++;
|
||||
} else if (token.type === "blockquote_close") {
|
||||
blockquoteNesting--;
|
||||
} else if (token.type === "list_item_open") {
|
||||
listItemNesting++;
|
||||
} else if (token.type === "list_item_close") {
|
||||
listItemNesting--;
|
||||
} 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);
|
||||
}
|
||||
token.content.split(shared.newLineRe)
|
||||
|
|
|
|||
|
|
@ -25,26 +25,26 @@ Text
|
|||
Text
|
||||
|
||||
> 1. Item
|
||||
> 1. Item {MD027}
|
||||
> 1. Item
|
||||
|
||||
Text
|
||||
|
||||
> - Item
|
||||
> - Item {MD027}
|
||||
> - Item
|
||||
|
||||
Text
|
||||
|
||||
> 1. Item
|
||||
> 1. Item {MD027}
|
||||
> 1. Item {MD027} {MD030}
|
||||
> 1. Item
|
||||
> 1. Item {MD030}
|
||||
|
||||
Text
|
||||
|
||||
> * Item
|
||||
> * Item {MD027}
|
||||
> * Item {MD027} {MD030}
|
||||
> * Item {MD027} {MD005}
|
||||
> * Item {MD027} {MD005}
|
||||
> * Item
|
||||
> * Item {MD030}
|
||||
> * Item {MD005}
|
||||
> * Item {MD005}
|
||||
|
||||
Text
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue