mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-09-22 05:40:48 +02:00
Update MD027/MD044 to report fixInfo for violations.
This commit is contained in:
parent
316bfeadaa
commit
00a7e765ec
3 changed files with 59 additions and 26 deletions
27
lib/md044.js
27
lib/md044.js
|
@ -29,9 +29,30 @@ module.exports = {
|
|||
.replace(/^\W*/, "").replace(/\W*$/, "");
|
||||
if (!names.includes(wordMatch)) {
|
||||
const lineNumber = token.lineNumber + index + fenceOffset;
|
||||
const range = [ match.index + 1, wordMatch.length ];
|
||||
addErrorDetailIf(onError, lineNumber,
|
||||
name, match[1], null, null, range);
|
||||
const fullLine = params.lines[lineNumber - 1];
|
||||
let matchIndex = match.index;
|
||||
const matchLength = wordMatch.length;
|
||||
const fullLineWord =
|
||||
fullLine.slice(matchIndex, matchIndex + matchLength);
|
||||
if (fullLineWord !== wordMatch) {
|
||||
// Attempt to fix bad offset due to inline content
|
||||
matchIndex = fullLine.indexOf(wordMatch);
|
||||
}
|
||||
const range = [ matchIndex + 1, matchLength ];
|
||||
addErrorDetailIf(
|
||||
onError,
|
||||
lineNumber,
|
||||
name,
|
||||
match[1],
|
||||
null,
|
||||
null,
|
||||
range,
|
||||
{
|
||||
"editColumn": matchIndex + 1,
|
||||
"deleteCount": matchLength,
|
||||
"insertText": name
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue