mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Handle implicit close fence in MD031/blanks-around-fences to avoid null-dereference.
This commit is contained in:
parent
9afd4e1ab5
commit
392cc287e6
2 changed files with 13 additions and 5 deletions
11
lib/md031.js
11
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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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}
|
||||
```
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue