Add regular expressions from vscode-markdownlint for error range in results.

This commit is contained in:
David Anson 2016-10-31 22:53:46 -07:00
parent 09ae51fdaa
commit dcf0462c22
12 changed files with 228 additions and 61 deletions

View file

@ -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;