mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Update MD022/blanks-around-headings to include blockquote prefix if fixing inside a blockquote (fixes #654).
This commit is contained in:
parent
82ea22d31a
commit
5eef37751b
5 changed files with 285 additions and 6 deletions
18
lib/md022.js
18
lib/md022.js
|
@ -2,7 +2,17 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { addErrorDetailIf, filterTokens, isBlankLine } = require("../helpers");
|
||||
const { addErrorDetailIf, blockquotePrefixRe, filterTokens, isBlankLine } =
|
||||
require("../helpers");
|
||||
|
||||
const getBlockQuote = (str, count) => (
|
||||
(str || "")
|
||||
.match(blockquotePrefixRe)[0]
|
||||
.trimEnd()
|
||||
// eslint-disable-next-line unicorn/prefer-spread
|
||||
.concat("\n")
|
||||
.repeat(count)
|
||||
);
|
||||
|
||||
module.exports = {
|
||||
"names": [ "MD022", "blanks-around-headings", "blanks-around-headers" ],
|
||||
|
@ -31,7 +41,8 @@ module.exports = {
|
|||
lines[topIndex].trim(),
|
||||
null,
|
||||
{
|
||||
"insertText": "".padEnd(linesAbove - actualAbove, "\n")
|
||||
"insertText":
|
||||
getBlockQuote(lines[topIndex - 1], linesAbove - actualAbove)
|
||||
});
|
||||
let actualBelow = 0;
|
||||
for (let i = 0; i < linesBelow; i++) {
|
||||
|
@ -49,7 +60,8 @@ module.exports = {
|
|||
null,
|
||||
{
|
||||
"lineNumber": nextIndex + 1,
|
||||
"insertText": "".padEnd(linesBelow - actualBelow, "\n")
|
||||
"insertText":
|
||||
getBlockQuote(lines[nextIndex], linesBelow - actualBelow)
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue