mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Update MD031/blanks-around-fences to add blockquote characters when fixing issues in that context.
This commit is contained in:
parent
65b19b703b
commit
e319f9501c
4 changed files with 120 additions and 1 deletions
|
|
@ -5,6 +5,8 @@
|
|||
const { addErrorContext, forEachLine, isBlankLine } = require("../helpers");
|
||||
const { lineMetadata } = require("./cache");
|
||||
|
||||
const codeFencePrefixRe = /^(.*?)\s*[`~]/;
|
||||
|
||||
module.exports = {
|
||||
"names": [ "MD031", "blanks-around-fences" ],
|
||||
"description": "Fenced code blocks should be surrounded by blank lines",
|
||||
|
|
@ -19,6 +21,7 @@ module.exports = {
|
|||
if ((includeListItems || !inItem) &&
|
||||
((onTopFence && !isBlankLine(lines[i - 1])) ||
|
||||
(onBottomFence && !isBlankLine(lines[i + 1])))) {
|
||||
const [ , prefix ] = line.match(codeFencePrefixRe);
|
||||
addErrorContext(
|
||||
onError,
|
||||
i + 1,
|
||||
|
|
@ -28,7 +31,7 @@ module.exports = {
|
|||
null,
|
||||
{
|
||||
"lineNumber": i + (onTopFence ? 1 : 2),
|
||||
"insertText": "\n"
|
||||
"insertText": `${prefix}\n`
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue