Account for front matter when calculating range for resultVersion 1 (fixes #48).

This commit is contained in:
David Anson 2017-03-14 21:58:39 -07:00
parent 5a1fb40871
commit 1b44ed54e4
4 changed files with 32 additions and 1 deletions

View file

@ -255,7 +255,8 @@ function lintContent(content, config, frontMatter, resultVersion) {
if (typeof regexp === "function") {
regexp = regexp(params.options);
}
var match = lines[error.lineNumber - 1].match(regexp);
var lineIndex = error.lineNumber - frontMatterLines - 1;
var match = lines[lineIndex].match(regexp);
if (match) {
var column = match.index + 1;
var length = match[0].length;

View file

@ -0,0 +1,4 @@
{
"default": true,
"MD041": true
}

View file

@ -0,0 +1,6 @@
---
front: matter
---
Text
Text

View file

@ -0,0 +1,20 @@
[
{
"lineNumber": 6,
"ruleName": "MD009",
"ruleAlias": "no-trailing-spaces",
"ruleDescription": "Trailing spaces",
"errorDetail": "Expected: 0; Actual: 1",
"errorContext": null,
"errorRange": [5, 1]
},
{
"lineNumber": 4,
"ruleName": "MD041",
"ruleAlias": "first-line-h1",
"ruleDescription": "First line in file should be a top level header",
"errorDetail": null,
"errorContext": "Text",
"errorRange": null
}
]