mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 22:40:13 +01:00
Fix applyFix handling of multiple line endings; MD022 handling of multiple lines.
This commit is contained in:
parent
52939a6d7e
commit
677255a484
5 changed files with 46 additions and 27 deletions
54
lib/md022.js
54
lib/md022.js
|
|
@ -20,37 +20,41 @@ module.exports = {
|
|||
const { lines } = params;
|
||||
filterTokens(params, "heading_open", (token) => {
|
||||
const [ topIndex, nextIndex ] = token.map;
|
||||
let actualAbove = 0;
|
||||
for (let i = 0; i < linesAbove; i++) {
|
||||
if (!isBlankLine(lines[topIndex - i - 1])) {
|
||||
addErrorDetailIf(
|
||||
onError,
|
||||
topIndex + 1,
|
||||
linesAbove,
|
||||
i,
|
||||
"Above",
|
||||
lines[topIndex].trim(),
|
||||
null,
|
||||
{
|
||||
"insertText": "\n"
|
||||
});
|
||||
if (isBlankLine(lines[topIndex - i - 1])) {
|
||||
actualAbove++;
|
||||
}
|
||||
}
|
||||
addErrorDetailIf(
|
||||
onError,
|
||||
topIndex + 1,
|
||||
linesAbove,
|
||||
actualAbove,
|
||||
"Above",
|
||||
lines[topIndex].trim(),
|
||||
null,
|
||||
{
|
||||
"insertText": "".padEnd(linesAbove - actualAbove, "\n")
|
||||
});
|
||||
let actualBelow = 0;
|
||||
for (let i = 0; i < linesBelow; i++) {
|
||||
if (!isBlankLine(lines[nextIndex + i])) {
|
||||
addErrorDetailIf(
|
||||
onError,
|
||||
topIndex + 1,
|
||||
linesBelow,
|
||||
i,
|
||||
"Below",
|
||||
lines[topIndex].trim(),
|
||||
null,
|
||||
{
|
||||
"lineNumber": nextIndex + 1,
|
||||
"insertText": "\n"
|
||||
});
|
||||
if (isBlankLine(lines[nextIndex + i])) {
|
||||
actualBelow++;
|
||||
}
|
||||
}
|
||||
addErrorDetailIf(
|
||||
onError,
|
||||
topIndex + 1,
|
||||
linesBelow,
|
||||
actualBelow,
|
||||
"Below",
|
||||
lines[topIndex].trim(),
|
||||
null,
|
||||
{
|
||||
"lineNumber": nextIndex + 1,
|
||||
"insertText": "".padEnd(linesBelow - actualBelow, "\n")
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue