diff --git a/lib/md031.js b/lib/md031.js index 5cfcfb4f..bfc4351c 100644 --- a/lib/md031.js +++ b/lib/md031.js @@ -21,7 +21,11 @@ module.exports = { if ((includeListItems || !inItem) && ((onTopFence && !isBlankLine(lines[i - 1])) || (onBottomFence && !isBlankLine(lines[i + 1])))) { - const [ , prefix ] = line.match(codeFencePrefixRe); + const [ , prefix ] = line.match(codeFencePrefixRe) || []; + const fixInfo = (prefix === undefined) ? null : { + "lineNumber": i + (onTopFence ? 1 : 2), + "insertText": `${prefix}\n` + }; addErrorContext( onError, i + 1, @@ -29,10 +33,7 @@ module.exports = { null, null, null, - { - "lineNumber": i + (onTopFence ? 1 : 2), - "insertText": `${prefix}\n` - }); + fixInfo); } }); } diff --git a/test/lists-with-fenced-code.md b/test/lists-with-fenced-code.md index 8e803be2..8c9aca86 100644 --- a/test/lists-with-fenced-code.md +++ b/test/lists-with-fenced-code.md @@ -57,3 +57,10 @@ Text fence {MD031:56} {MD031:58} ``` 1. Item + +Text + +1. Text + ```shell + fence {MD031:64} {MD031:65} {MD032:65} {MD040:66} + ```