diff --git a/demo/markdownlint-browser.js b/demo/markdownlint-browser.js index cc62c64a..0c668519 100644 --- a/demo/markdownlint-browser.js +++ b/demo/markdownlint-browser.js @@ -5017,7 +5017,7 @@ module.exports = { if (!isBlankLine(lines[codeBlock.startLine - 2])) { 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); } } diff --git a/lib/md031.js b/lib/md031.js index 0e61bed4..4cdd26d1 100644 --- a/lib/md031.js +++ b/lib/md031.js @@ -53,7 +53,7 @@ module.exports = { if (!isBlankLine(lines[codeBlock.startLine - 2])) { 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); } } diff --git a/test/lists-with-fenced-code.md b/test/lists-with-fenced-code.md index 552bff58..f94c6a02 100644 --- a/test/lists-with-fenced-code.md +++ b/test/lists-with-fenced-code.md @@ -19,12 +19,12 @@ Text - Item ```text - fence {MD031:21} {MD031:23} + fence {MD031:-1} {MD031:+1} ``` - Item - Item ```text - fence {MD031:26} {MD031:28} + fence {MD031:-1} {MD031:+1} ``` - Item @@ -49,18 +49,25 @@ Text 1. Item ```text - fence {MD031:51} {MD031:53} + fence {MD031:-1} {MD031:+1} ``` 1. Item 1. Item ```text - fence {MD031:56} {MD031:58} + fence {MD031:-1} {MD031:+1} ``` 1. Item Text +1. Text + + ```text + code + +Text + 1. Text ```shell - fence {MD031:64} {MD031:65} {MD031:66} {MD032:65} {MD040:66} + fence {MD031:-1} {MD031} {MD031:+1} {MD032} {MD040:+1} ``` diff --git a/test/snapshots/markdownlint-test-scenarios.js.md b/test/snapshots/markdownlint-test-scenarios.js.md index e01ae498..c274bfba 100644 --- a/test/snapshots/markdownlint-test-scenarios.js.md +++ b/test/snapshots/markdownlint-test-scenarios.js.md @@ -35671,9 +35671,9 @@ Generated by [AVA](https://avajs.dev). fixInfo: { insertText: `␊ `, - lineNumber: 64, + lineNumber: 71, }, - lineNumber: 64, + lineNumber: 71, ruleDescription: 'Fenced code blocks should be surrounded by blank lines', ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md031.md', 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, errorRange: null, fixInfo: null, - lineNumber: 65, + lineNumber: 72, ruleDescription: 'Fenced code blocks should be surrounded by blank lines', ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md031.md', ruleNames: [ @@ -35701,9 +35701,9 @@ Generated by [AVA](https://avajs.dev). fixInfo: { insertText: `␊ `, - lineNumber: 66, + lineNumber: 73, }, - lineNumber: 66, + lineNumber: 73, ruleDescription: 'Fenced code blocks should be surrounded by blank lines', ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md031.md', 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, errorRange: null, fixInfo: { insertText: `␊ `, - lineNumber: 66, + lineNumber: 73, }, - lineNumber: 65, + lineNumber: 72, ruleDescription: 'Lists should be surrounded by blank lines', ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md032.md', ruleNames: [ @@ -35733,7 +35733,7 @@ Generated by [AVA](https://avajs.dev). errorDetail: null, errorRange: null, fixInfo: null, - lineNumber: 66, + lineNumber: 73, ruleDescription: 'Fenced code blocks should have a language specified', ruleInformation: 'https://github.com/DavidAnson/markdownlint/blob/v0.0.0/doc/md040.md', ruleNames: [ @@ -35764,14 +35764,14 @@ Generated by [AVA](https://avajs.dev). - Item␊ ␊ \`\`\`text␊ - fence {MD031:21} {MD031:23}␊ + fence {MD031:-1} {MD031:+1}␊ \`\`\`␊ ␊ - Item␊ - Item␊ ␊ \`\`\`text␊ - fence {MD031:26} {MD031:28}␊ + fence {MD031:-1} {MD031:+1}␊ \`\`\`␊ ␊ - Item␊ @@ -35798,14 +35798,14 @@ Generated by [AVA](https://avajs.dev). 1. Item␊ ␊ \`\`\`text␊ - fence {MD031:51} {MD031:53}␊ + fence {MD031:-1} {MD031:+1}␊ \`\`\`␊ ␊ 1. Item␊ 1. Item␊ ␊ \`\`\`text␊ - fence {MD031:56} {MD031:58}␊ + fence {MD031:-1} {MD031:+1}␊ \`\`\`␊ ␊ 1. Item␊ @@ -35813,9 +35813,16 @@ Generated by [AVA](https://avajs.dev). Text␊ ␊ 1. Text␊ + ␊ + \`\`\`text␊ + code␊ + ␊ + Text␊ + ␊ + 1. Text␊ ␊ \`\`\`shell␊ - fence {MD031:64} {MD031:65} {MD031:66} {MD032:65} {MD040:66}␊ + fence {MD031:-1} {MD031} {MD031:+1} {MD032} {MD040:+1}␊ ␊ \`\`\`␊ `, diff --git a/test/snapshots/markdownlint-test-scenarios.js.snap b/test/snapshots/markdownlint-test-scenarios.js.snap index f76c662b..1e2ce49e 100644 Binary files a/test/snapshots/markdownlint-test-scenarios.js.snap and b/test/snapshots/markdownlint-test-scenarios.js.snap differ