mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Add more tests for recent changes, handle additional edge cases.
This commit is contained in:
parent
0c68509266
commit
256e5a7e73
4 changed files with 122 additions and 16 deletions
11
lib/rules.js
11
lib/rules.js
|
@ -4,7 +4,8 @@ var shared = require("./shared");
|
|||
|
||||
// Returns the indent for a 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
|
||||
|
@ -581,7 +582,7 @@ module.exports = [
|
|||
blockquoteNesting++;
|
||||
} else if (token.type === "blockquote_close") {
|
||||
blockquoteNesting--;
|
||||
} else if ((token.type === "inline") && blockquoteNesting > 0) {
|
||||
} else if ((token.type === "inline") && (blockquoteNesting > 0)) {
|
||||
token.content.split(shared.newLineRe)
|
||||
.forEach(function forLine(line, offset) {
|
||||
if (/^\s/.test(line) ||
|
||||
|
@ -622,7 +623,7 @@ module.exports = [
|
|||
if (!list.unordered) {
|
||||
var number = 1;
|
||||
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)) {
|
||||
errors.push(item.lineNumber);
|
||||
}
|
||||
|
@ -652,8 +653,8 @@ module.exports = [
|
|||
(allSingle ? ulSingle : ulMulti) :
|
||||
(allSingle ? olSingle : olMulti);
|
||||
list.items.forEach(function forItem(item) {
|
||||
var match = /^(\s|> )*\S+(\s+)/.exec(item.line);
|
||||
if (!match || (match[2].length !== expectedSpaces)) {
|
||||
var match = /^[\s>]*\S+(\s+)/.exec(item.line);
|
||||
if (!match || (match[1].length !== expectedSpaces)) {
|
||||
errors.push(item.lineNumber);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -5,3 +5,55 @@
|
|||
> > 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
|
|
@ -1,11 +0,0 @@
|
|||
# Ordered list in blockquote
|
||||
|
||||
> 1. The simplest ordered list in blockquote
|
||||
|
||||
1. ol
|
||||
|
||||
> 1. ol-li-blockquote-ol-li
|
||||
> 1. ol-li-blockquote-ol-li-ol-li {MD027}
|
||||
|
||||
> 1. blockquote-ol-li
|
||||
> 1. blockquote-ol-li-ol-li {MD027}
|
Loading…
Add table
Add a link
Reference in a new issue