mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Account for front matter when calculating range for resultVersion 1 (fixes #48).
This commit is contained in:
parent
5a1fb40871
commit
1b44ed54e4
4 changed files with 32 additions and 1 deletions
|
|
@ -255,7 +255,8 @@ function lintContent(content, config, frontMatter, resultVersion) {
|
||||||
if (typeof regexp === "function") {
|
if (typeof regexp === "function") {
|
||||||
regexp = regexp(params.options);
|
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) {
|
if (match) {
|
||||||
var column = match.index + 1;
|
var column = match.index + 1;
|
||||||
var length = match[0].length;
|
var length = match[0].length;
|
||||||
|
|
|
||||||
4
test/detailed-results-front-matter.json
Normal file
4
test/detailed-results-front-matter.json
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"default": true,
|
||||||
|
"MD041": true
|
||||||
|
}
|
||||||
6
test/detailed-results-front-matter.md
Normal file
6
test/detailed-results-front-matter.md
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
front: matter
|
||||||
|
---
|
||||||
|
Text
|
||||||
|
|
||||||
|
Text
|
||||||
20
test/detailed-results-front-matter.results.json
Normal file
20
test/detailed-results-front-matter.results.json
Normal 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
|
||||||
|
}
|
||||||
|
]
|
||||||
Loading…
Add table
Add a link
Reference in a new issue