mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Merge two pull requests from @ohtake.
This commit is contained in:
commit
2d8122a3be
3 changed files with 132 additions and 8 deletions
17
lib/rules.js
17
lib/rules.js
|
|
@ -4,7 +4,8 @@ var shared = require("./shared");
|
||||||
|
|
||||||
// Returns the indent for a token
|
// Returns the indent for a token
|
||||||
function indentFor(token) {
|
function indentFor(token) {
|
||||||
return token.line.length - token.line.trimLeft().length;
|
var line = token.line.replace(/^[\s>]*(> |>)/, "");
|
||||||
|
return line.length - line.trimLeft().length;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the heading style for a heading token
|
// Returns the heading style for a heading token
|
||||||
|
|
@ -575,17 +576,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);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -622,7 +623,7 @@ module.exports = [
|
||||||
if (!list.unordered) {
|
if (!list.unordered) {
|
||||||
var number = 1;
|
var number = 1;
|
||||||
list.items.forEach(function forItem(item) {
|
list.items.forEach(function forItem(item) {
|
||||||
var re = new RegExp("^\\s*" + String(number) + "\\.");
|
var re = new RegExp("^[\\s>]*" + String(number) + "\\.");
|
||||||
if (!re.test(item.line)) {
|
if (!re.test(item.line)) {
|
||||||
errors.push(item.lineNumber);
|
errors.push(item.lineNumber);
|
||||||
}
|
}
|
||||||
|
|
@ -652,7 +653,7 @@ module.exports = [
|
||||||
(allSingle ? ulSingle : ulMulti) :
|
(allSingle ? ulSingle : ulMulti) :
|
||||||
(allSingle ? olSingle : olMulti);
|
(allSingle ? olSingle : olMulti);
|
||||||
list.items.forEach(function forItem(item) {
|
list.items.forEach(function forItem(item) {
|
||||||
var match = /^\s*\S+(\s+)/.exec(item.line);
|
var match = /^[\s>]*\S+(\s+)/.exec(item.line);
|
||||||
if (!match || (match[1].length !== expectedSpaces)) {
|
if (!match || (match[1].length !== expectedSpaces)) {
|
||||||
errors.push(item.lineNumber);
|
errors.push(item.lineNumber);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
59
test/blockquote-spaces-nested.md
Normal file
59
test/blockquote-spaces-nested.md
Normal file
|
|
@ -0,0 +1,59 @@
|
||||||
|
# Nested blockquote
|
||||||
|
|
||||||
|
> A {MD027}
|
||||||
|
>
|
||||||
|
> > B {MD027}
|
||||||
|
>
|
||||||
|
> C {MD027}
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
> A {MD027}
|
||||||
|
>
|
||||||
|
> > B {MD027}
|
||||||
|
> >
|
||||||
|
> > > C {MD027}
|
||||||
|
> >
|
||||||
|
> > D {MD027}
|
||||||
|
>
|
||||||
|
> E {MD027}
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
> A {MD027}
|
||||||
|
>
|
||||||
|
>> B {MD027}
|
||||||
|
>>
|
||||||
|
>>> C {MD027}
|
||||||
|
>>
|
||||||
|
>> D {MD027}
|
||||||
|
>
|
||||||
|
> E {MD027}
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
> > Text {MD027}
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
> > Text {MD027}
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
> > Text {MD027}
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
> > Text {MD027}
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
> > > Text {MD027}
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
> > > > Text {MD027}
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
>> >> Text {MD027}
|
||||||
64
test/lists-in-blockquote.md
Normal file
64
test/lists-in-blockquote.md
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
# Lists in blockquote
|
||||||
|
|
||||||
|
> 1. The simplest ordered list in blockquote
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
> + The simplest unordered list in blockquote
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
>1. Item
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
>+ Item
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
>1. Item {MD030}
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
>+ Item {MD030}
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
> 1. Item
|
||||||
|
> 1. Item {MD027}
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
> - Item
|
||||||
|
> - Item {MD027}
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
> 1. Item
|
||||||
|
> 1. Item {MD027}
|
||||||
|
> 1. Item {MD027} {MD030}
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
> * Item
|
||||||
|
> * Item {MD027}
|
||||||
|
> * Item {MD027} {MD030}
|
||||||
|
> * Item {MD027} {MD005}
|
||||||
|
> * Item {MD027} {MD005}
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
> Text
|
||||||
|
> > - Item
|
||||||
|
> > - Item {MD027}
|
||||||
|
> > - Item
|
||||||
|
> > > - Item
|
||||||
|
> > > - Item {MD027}
|
||||||
|
> > > - Item {MD027}
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
>* Item
|
||||||
|
> * Item
|
||||||
|
>>* Item
|
||||||
|
>> * Item
|
||||||
Loading…
Add table
Add a link
Reference in a new issue