Update MD031/blanks-around-fences to handle missing close fence.

This commit is contained in:
David Anson 2024-08-17 20:29:27 -07:00
parent c8fd9eb4b3
commit 2b8369ae39
5 changed files with 36 additions and 22 deletions

View file

@ -5017,7 +5017,7 @@ module.exports = {
if (!isBlankLine(lines[codeBlock.startLine - 2])) { if (!isBlankLine(lines[codeBlock.startLine - 2])) {
addError(onError, lines, codeBlock.startLine, true); addError(onError, lines, codeBlock.startLine, true);
} }
if (!isBlankLine(lines[codeBlock.endLine])) { if (!isBlankLine(lines[codeBlock.endLine]) && !isBlankLine(lines[codeBlock.endLine - 1])) {
addError(onError, lines, codeBlock.endLine, false); addError(onError, lines, codeBlock.endLine, false);
} }
} }

View file

@ -53,7 +53,7 @@ module.exports = {
if (!isBlankLine(lines[codeBlock.startLine - 2])) { if (!isBlankLine(lines[codeBlock.startLine - 2])) {
addError(onError, lines, codeBlock.startLine, true); addError(onError, lines, codeBlock.startLine, true);
} }
if (!isBlankLine(lines[codeBlock.endLine])) { if (!isBlankLine(lines[codeBlock.endLine]) && !isBlankLine(lines[codeBlock.endLine - 1])) {
addError(onError, lines, codeBlock.endLine, false); addError(onError, lines, codeBlock.endLine, false);
} }
} }

View file

@ -19,12 +19,12 @@ Text
- Item - Item
```text ```text
fence {MD031:21} {MD031:23} fence {MD031:-1} {MD031:+1}
``` ```
- Item - Item
- Item - Item
```text ```text
fence {MD031:26} {MD031:28} fence {MD031:-1} {MD031:+1}
``` ```
- Item - Item
@ -49,18 +49,25 @@ Text
1. Item 1. Item
```text ```text
fence {MD031:51} {MD031:53} fence {MD031:-1} {MD031:+1}
``` ```
1. Item 1. Item
1. Item 1. Item
```text ```text
fence {MD031:56} {MD031:58} fence {MD031:-1} {MD031:+1}
``` ```
1. Item 1. Item
Text Text
1. Text
```text
code
Text
1. Text 1. Text
```shell ```shell
fence {MD031:64} {MD031:65} {MD031:66} {MD032:65} {MD040:66} fence {MD031:-1} {MD031} {MD031:+1} {MD032} {MD040:+1}
``` ```

View file

@ -35671,9 +35671,9 @@ Generated by [AVA](https://avajs.dev).
fixInfo: { fixInfo: {
insertText: `␊ insertText: `␊
`, `,
lineNumber: 64, lineNumber: 71,
}, },
lineNumber: 64, lineNumber: 71,
ruleDescription: 'Fenced code blocks should be surrounded by blank lines', ruleDescription: 'Fenced code blocks should be surrounded by blank lines',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md031.md', ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md031.md',
ruleNames: [ ruleNames: [
@ -35682,11 +35682,11 @@ Generated by [AVA](https://avajs.dev).
], ],
}, },
{ {
errorContext: 'fence {MD031:64} {MD031:65} {M...', errorContext: 'fence {MD031:-1} {MD031} {MD03...',
errorDetail: null, errorDetail: null,
errorRange: null, errorRange: null,
fixInfo: null, fixInfo: null,
lineNumber: 65, lineNumber: 72,
ruleDescription: 'Fenced code blocks should be surrounded by blank lines', ruleDescription: 'Fenced code blocks should be surrounded by blank lines',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md031.md', ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md031.md',
ruleNames: [ ruleNames: [
@ -35701,9 +35701,9 @@ Generated by [AVA](https://avajs.dev).
fixInfo: { fixInfo: {
insertText: `␊ insertText: `␊
`, `,
lineNumber: 66, lineNumber: 73,
}, },
lineNumber: 66, lineNumber: 73,
ruleDescription: 'Fenced code blocks should be surrounded by blank lines', ruleDescription: 'Fenced code blocks should be surrounded by blank lines',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md031.md', ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md031.md',
ruleNames: [ ruleNames: [
@ -35712,15 +35712,15 @@ Generated by [AVA](https://avajs.dev).
], ],
}, },
{ {
errorContext: 'fence {MD031:64} {MD031:65} {M...', errorContext: 'fence {MD031:-1} {MD031} {MD03...',
errorDetail: null, errorDetail: null,
errorRange: null, errorRange: null,
fixInfo: { fixInfo: {
insertText: `␊ insertText: `␊
`, `,
lineNumber: 66, lineNumber: 73,
}, },
lineNumber: 65, lineNumber: 72,
ruleDescription: 'Lists should be surrounded by blank lines', ruleDescription: 'Lists should be surrounded by blank lines',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md032.md', ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md032.md',
ruleNames: [ ruleNames: [
@ -35733,7 +35733,7 @@ Generated by [AVA](https://avajs.dev).
errorDetail: null, errorDetail: null,
errorRange: null, errorRange: null,
fixInfo: null, fixInfo: null,
lineNumber: 66, lineNumber: 73,
ruleDescription: 'Fenced code blocks should have a language specified', ruleDescription: 'Fenced code blocks should have a language specified',
ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md040.md', ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md040.md',
ruleNames: [ ruleNames: [
@ -35764,14 +35764,14 @@ Generated by [AVA](https://avajs.dev).
- Item␊ - Item␊
\`\`\`text␊ \`\`\`text␊
fence {MD031:21} {MD031:23}␊ fence {MD031:-1} {MD031:+1}␊
\`\`\`␊ \`\`\`␊
- Item␊ - Item␊
- Item␊ - Item␊
\`\`\`text␊ \`\`\`text␊
fence {MD031:26} {MD031:28}␊ fence {MD031:-1} {MD031:+1}␊
\`\`\`␊ \`\`\`␊
- Item␊ - Item␊
@ -35798,14 +35798,14 @@ Generated by [AVA](https://avajs.dev).
1. Item␊ 1. Item␊
\`\`\`text␊ \`\`\`text␊
fence {MD031:51} {MD031:53}␊ fence {MD031:-1} {MD031:+1}␊
\`\`\`␊ \`\`\`␊
1. Item␊ 1. Item␊
1. Item␊ 1. Item␊
\`\`\`text␊ \`\`\`text␊
fence {MD031:56} {MD031:58}␊ fence {MD031:-1} {MD031:+1}␊
\`\`\`␊ \`\`\`␊
1. Item␊ 1. Item␊
@ -35813,9 +35813,16 @@ Generated by [AVA](https://avajs.dev).
Text␊ Text␊
1. Text␊ 1. Text␊
\`\`\`text␊
code␊
Text␊
1. Text␊
\`\`\`shell␊ \`\`\`shell␊
fence {MD031:64} {MD031:65} {MD031:66} {MD032:65} {MD040:66}␊ fence {MD031:-1} {MD031} {MD031:+1} {MD032} {MD040:+1}␊
\`\`\`␊ \`\`\`␊
`, `,