mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Update MD007/ul-indent to account for 4-space base indent within footnote definitions (fixes #1679).
This commit is contained in:
parent
55700da8a2
commit
442afe4466
5 changed files with 129 additions and 1 deletions
|
|
@ -298,6 +298,7 @@ const nonContentTokens = new Set([
|
||||||
"blockQuoteMarker",
|
"blockQuoteMarker",
|
||||||
"blockQuotePrefix",
|
"blockQuotePrefix",
|
||||||
"blockQuotePrefixWhitespace",
|
"blockQuotePrefixWhitespace",
|
||||||
|
"gfmFootnoteDefinitionIndent",
|
||||||
"lineEnding",
|
"lineEnding",
|
||||||
"lineEndingBlank",
|
"lineEndingBlank",
|
||||||
"linePrefix",
|
"linePrefix",
|
||||||
|
|
|
||||||
|
|
@ -53,8 +53,9 @@ export default {
|
||||||
const nesting = unorderedListNesting.get(parent);
|
const nesting = unorderedListNesting.get(parent);
|
||||||
if (nesting !== undefined) {
|
if (nesting !== undefined) {
|
||||||
// listItemPrefix for listUnordered
|
// listItemPrefix for listUnordered
|
||||||
|
const baseIndent = (getParentOfType(token, [ "gfmFootnoteDefinition" ])) ? 4 : 0;
|
||||||
const expectedIndent =
|
const expectedIndent =
|
||||||
(startIndented ? startIndent : 0) + (nesting * indent);
|
baseIndent + (startIndented ? startIndent : 0) + (nesting * indent);
|
||||||
const blockQuoteAdjustment =
|
const blockQuoteAdjustment =
|
||||||
(lastBlockQuotePrefix?.endLine === startLine) ?
|
(lastBlockQuotePrefix?.endLine === startLine) ?
|
||||||
(lastBlockQuotePrefix.endColumn - 1) :
|
(lastBlockQuotePrefix.endColumn - 1) :
|
||||||
|
|
|
||||||
22
test/lists-inside-footnote.md
Normal file
22
test/lists-inside-footnote.md
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
# Lists Inside Footnote
|
||||||
|
|
||||||
|
Text.[^ref]
|
||||||
|
|
||||||
|
[^ref]: Note and list:
|
||||||
|
|
||||||
|
* Item
|
||||||
|
* Item
|
||||||
|
* Item
|
||||||
|
|
||||||
|
1. Item
|
||||||
|
1. Item
|
||||||
|
1. Item
|
||||||
|
|
||||||
|
Text
|
||||||
|
|
||||||
|
* Item
|
||||||
|
* Item {MD005} {MD007}
|
||||||
|
* Item
|
||||||
|
* Item
|
||||||
|
* Item {MD005} {MD007}
|
||||||
|
* Item
|
||||||
|
|
@ -37588,6 +37588,110 @@ Generated by [AVA](https://avajs.dev).
|
||||||
`,
|
`,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
## lists-inside-footnote.md
|
||||||
|
|
||||||
|
> Snapshot 1
|
||||||
|
|
||||||
|
{
|
||||||
|
errors: [
|
||||||
|
{
|
||||||
|
errorContext: null,
|
||||||
|
errorDetail: 'Expected: 4; Actual: 5',
|
||||||
|
errorRange: [
|
||||||
|
1,
|
||||||
|
7,
|
||||||
|
],
|
||||||
|
fixInfo: null,
|
||||||
|
lineNumber: 18,
|
||||||
|
ruleDescription: 'Inconsistent indentation for list items at the same level',
|
||||||
|
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md005.md',
|
||||||
|
ruleNames: [
|
||||||
|
'MD005',
|
||||||
|
'list-indent',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
errorContext: null,
|
||||||
|
errorDetail: 'Expected: 6; Actual: 7',
|
||||||
|
errorRange: [
|
||||||
|
1,
|
||||||
|
9,
|
||||||
|
],
|
||||||
|
fixInfo: null,
|
||||||
|
lineNumber: 21,
|
||||||
|
ruleDescription: 'Inconsistent indentation for list items at the same level',
|
||||||
|
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md005.md',
|
||||||
|
ruleNames: [
|
||||||
|
'MD005',
|
||||||
|
'list-indent',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
errorContext: null,
|
||||||
|
errorDetail: 'Expected: 4; Actual: 5',
|
||||||
|
errorRange: [
|
||||||
|
1,
|
||||||
|
7,
|
||||||
|
],
|
||||||
|
fixInfo: {
|
||||||
|
deleteCount: 1,
|
||||||
|
editColumn: 1,
|
||||||
|
insertText: '',
|
||||||
|
},
|
||||||
|
lineNumber: 18,
|
||||||
|
ruleDescription: 'Unordered list indentation',
|
||||||
|
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md007.md',
|
||||||
|
ruleNames: [
|
||||||
|
'MD007',
|
||||||
|
'ul-indent',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
errorContext: null,
|
||||||
|
errorDetail: 'Expected: 6; Actual: 7',
|
||||||
|
errorRange: [
|
||||||
|
1,
|
||||||
|
9,
|
||||||
|
],
|
||||||
|
fixInfo: {
|
||||||
|
deleteCount: 1,
|
||||||
|
editColumn: 1,
|
||||||
|
insertText: '',
|
||||||
|
},
|
||||||
|
lineNumber: 21,
|
||||||
|
ruleDescription: 'Unordered list indentation',
|
||||||
|
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md007.md',
|
||||||
|
ruleNames: [
|
||||||
|
'MD007',
|
||||||
|
'ul-indent',
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
fixed: `# Lists Inside Footnote␊
|
||||||
|
␊
|
||||||
|
Text.[^ref]␊
|
||||||
|
␊
|
||||||
|
[^ref]: Note and list:␊
|
||||||
|
␊
|
||||||
|
* Item␊
|
||||||
|
* Item␊
|
||||||
|
* Item␊
|
||||||
|
␊
|
||||||
|
1. Item␊
|
||||||
|
1. Item␊
|
||||||
|
1. Item␊
|
||||||
|
␊
|
||||||
|
Text␊
|
||||||
|
␊
|
||||||
|
* Item␊
|
||||||
|
* Item {MD005} {MD007}␊
|
||||||
|
* Item␊
|
||||||
|
* Item␊
|
||||||
|
* Item {MD005} {MD007}␊
|
||||||
|
* Item␊
|
||||||
|
`,
|
||||||
|
}
|
||||||
|
|
||||||
## lists-on-a-line.md
|
## lists-on-a-line.md
|
||||||
|
|
||||||
> Snapshot 1
|
> Snapshot 1
|
||||||
|
|
|
||||||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue