mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Update helpers.flattenLists to provide correct lastLineIndex for lists with an empty last item (fixes #529).
This commit is contained in:
parent
4560ccc1cd
commit
85d720cefc
6 changed files with 175 additions and 10 deletions
|
|
@ -395,7 +395,7 @@ module.exports.flattenLists = function flattenLists(tokens) {
|
||||||
else if (token.type === "blockquote_close") {
|
else if (token.type === "blockquote_close") {
|
||||||
nesting = nestingStack.pop();
|
nesting = nestingStack.pop();
|
||||||
}
|
}
|
||||||
else if (token.map) {
|
if (token.map) {
|
||||||
// Track last token with map
|
// Track last token with map
|
||||||
lastWithMap = token;
|
lastWithMap = token;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -393,7 +393,8 @@ module.exports.flattenLists = function flattenLists(tokens) {
|
||||||
nesting = 0;
|
nesting = 0;
|
||||||
} else if (token.type === "blockquote_close") {
|
} else if (token.type === "blockquote_close") {
|
||||||
nesting = nestingStack.pop();
|
nesting = nestingStack.pop();
|
||||||
} else if (token.map) {
|
}
|
||||||
|
if (token.map) {
|
||||||
// Track last token with map
|
// Track last token with map
|
||||||
lastWithMap = token;
|
lastWithMap = token;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
-
|
-
|
||||||
(bare list item marker)
|
(bare list item marker {MD032:3})
|
||||||
|
|
||||||
1.
|
1.
|
||||||
(bare list item marker)
|
(bare list item marker {MD032:6})
|
||||||
|
|
||||||
-a
|
-a
|
||||||
(not a list item)
|
(not a list item)
|
||||||
|
|
@ -16,6 +16,6 @@
|
||||||
|
|
||||||
1. a
|
1. a
|
||||||
|
|
||||||
- a
|
- a {MD030}
|
||||||
|
|
||||||
1. a
|
1. a {MD030}
|
||||||
|
|
|
||||||
49
test/lists-incomplete.md
Normal file
49
test/lists-incomplete.md
Normal file
|
|
@ -0,0 +1,49 @@
|
||||||
|
# Lists Incomplete
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
- Item
|
||||||
|
-
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
-
|
||||||
|
- Item
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
- Item
|
||||||
|
-
|
||||||
|
- Item
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
- Item
|
||||||
|
-
|
||||||
|
-
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
1. Item
|
||||||
|
1.
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
1.
|
||||||
|
1. Item
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
1. Item
|
||||||
|
1.
|
||||||
|
1. Item
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
1. Item
|
||||||
|
1.
|
||||||
|
1.
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
{MD047}
|
||||||
|
|
@ -915,14 +915,50 @@ Generated by [AVA](https://avajs.dev).
|
||||||
'list-marker-space',
|
'list-marker-space',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
errorContext: '-',
|
||||||
|
errorDetail: null,
|
||||||
|
errorRange: null,
|
||||||
|
fixInfo: {
|
||||||
|
insertText: `␊
|
||||||
|
`,
|
||||||
|
lineNumber: 4,
|
||||||
|
},
|
||||||
|
lineNumber: 3,
|
||||||
|
ruleDescription: 'Lists should be surrounded by blank lines',
|
||||||
|
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md032',
|
||||||
|
ruleNames: [
|
||||||
|
'MD032',
|
||||||
|
'blanks-around-lists',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
errorContext: '1.',
|
||||||
|
errorDetail: null,
|
||||||
|
errorRange: null,
|
||||||
|
fixInfo: {
|
||||||
|
insertText: `␊
|
||||||
|
`,
|
||||||
|
lineNumber: 7,
|
||||||
|
},
|
||||||
|
lineNumber: 6,
|
||||||
|
ruleDescription: 'Lists should be surrounded by blank lines',
|
||||||
|
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md032',
|
||||||
|
ruleNames: [
|
||||||
|
'MD032',
|
||||||
|
'blanks-around-lists',
|
||||||
|
],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
fixed: `#␊
|
fixed: `#␊
|
||||||
␊
|
␊
|
||||||
-␊
|
-␊
|
||||||
(bare list item marker)␊
|
␊
|
||||||
|
(bare list item marker {MD032:3})␊
|
||||||
␊
|
␊
|
||||||
1.␊
|
1.␊
|
||||||
(bare list item marker)␊
|
␊
|
||||||
|
(bare list item marker {MD032:6})␊
|
||||||
␊
|
␊
|
||||||
-a␊
|
-a␊
|
||||||
(not a list item)␊
|
(not a list item)␊
|
||||||
|
|
@ -934,9 +970,9 @@ Generated by [AVA](https://avajs.dev).
|
||||||
␊
|
␊
|
||||||
1. a␊
|
1. a␊
|
||||||
␊
|
␊
|
||||||
- a␊
|
- a {MD030}␊
|
||||||
␊
|
␊
|
||||||
1. a␊
|
1. a {MD030}␊
|
||||||
`,
|
`,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -25582,6 +25618,85 @@ Generated by [AVA](https://avajs.dev).
|
||||||
`,
|
`,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
## lists-incomplete.md
|
||||||
|
|
||||||
|
> Snapshot 1
|
||||||
|
|
||||||
|
{
|
||||||
|
errors: [
|
||||||
|
{
|
||||||
|
errorContext: null,
|
||||||
|
errorDetail: null,
|
||||||
|
errorRange: [
|
||||||
|
7,
|
||||||
|
1,
|
||||||
|
],
|
||||||
|
fixInfo: {
|
||||||
|
editColumn: 8,
|
||||||
|
insertText: `␊
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
lineNumber: 49,
|
||||||
|
ruleDescription: 'Files should end with a single newline character',
|
||||||
|
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/Rules.md#md047',
|
||||||
|
ruleNames: [
|
||||||
|
'MD047',
|
||||||
|
'single-trailing-newline',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
fixed: `# Lists Incomplete␊
|
||||||
|
␊
|
||||||
|
Text␊
|
||||||
|
␊
|
||||||
|
- Item␊
|
||||||
|
-␊
|
||||||
|
␊
|
||||||
|
Text␊
|
||||||
|
␊
|
||||||
|
-␊
|
||||||
|
- Item␊
|
||||||
|
␊
|
||||||
|
Text␊
|
||||||
|
␊
|
||||||
|
- Item␊
|
||||||
|
-␊
|
||||||
|
- Item␊
|
||||||
|
␊
|
||||||
|
Text␊
|
||||||
|
␊
|
||||||
|
- Item␊
|
||||||
|
-␊
|
||||||
|
-␊
|
||||||
|
␊
|
||||||
|
Text␊
|
||||||
|
␊
|
||||||
|
1. Item␊
|
||||||
|
1.␊
|
||||||
|
␊
|
||||||
|
Text␊
|
||||||
|
␊
|
||||||
|
1.␊
|
||||||
|
1. Item␊
|
||||||
|
␊
|
||||||
|
Text␊
|
||||||
|
␊
|
||||||
|
1. Item␊
|
||||||
|
1.␊
|
||||||
|
1. Item␊
|
||||||
|
␊
|
||||||
|
Text␊
|
||||||
|
␊
|
||||||
|
1. Item␊
|
||||||
|
1.␊
|
||||||
|
1.␊
|
||||||
|
␊
|
||||||
|
Text␊
|
||||||
|
␊
|
||||||
|
{MD047}␊
|
||||||
|
`,
|
||||||
|
}
|
||||||
|
|
||||||
## lists-with-commented-items.md
|
## lists-with-commented-items.md
|
||||||
|
|
||||||
> Snapshot 1
|
> Snapshot 1
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue