mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Add regular expressions from vscode-markdownlint for error range in results.
This commit is contained in:
parent
09ae51fdaa
commit
dcf0462c22
12 changed files with 228 additions and 61 deletions
|
|
@ -245,13 +245,31 @@ function lintContent(content, config, frontMatter, resultVersion) {
|
|||
})
|
||||
.map(function formatResults(error) {
|
||||
if (resultVersion === 1) {
|
||||
var range = null;
|
||||
var regexp = rule.regexp;
|
||||
if (regexp) {
|
||||
if (typeof regexp === "function") {
|
||||
regexp = regexp(params.options);
|
||||
}
|
||||
var match = lines[error.lineNumber - 1].match(regexp);
|
||||
if (match) {
|
||||
var column = match.index + 1;
|
||||
var length = match[0].length;
|
||||
if (match[2]) {
|
||||
column += match[1].length;
|
||||
length -= match[1].length;
|
||||
}
|
||||
range = [ column, length ];
|
||||
}
|
||||
}
|
||||
return {
|
||||
"lineNumber": error.lineNumber,
|
||||
"ruleName": rule.name,
|
||||
"ruleAlias": rule.aliases[0],
|
||||
"ruleDescription": rule.desc,
|
||||
"errorDetail": error.detail,
|
||||
"errorContext": error.context
|
||||
"errorContext": error.context,
|
||||
"errorRange": range
|
||||
};
|
||||
}
|
||||
return error.lineNumber;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue