mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-17 06:20:12 +01:00
Improve highlighting for MD044/proper-names, add more tests.
This commit is contained in:
parent
1668207213
commit
7acb3d72fd
4 changed files with 38 additions and 8 deletions
|
|
@ -234,11 +234,16 @@ function lintContent(
|
||||||
errors.addDetail = function addDetail(lineNumber, detail) {
|
errors.addDetail = function addDetail(lineNumber, detail) {
|
||||||
addError(lineNumber, detail);
|
addError(lineNumber, detail);
|
||||||
};
|
};
|
||||||
errors.addDetailIf = function addDetailIf(lineNumber, expected, actual) {
|
errors.addDetailIf =
|
||||||
if (expected !== actual) {
|
function addDetailIf(lineNumber, expected, actual, range) {
|
||||||
addError(lineNumber, "Expected: " + expected + "; Actual: " + actual);
|
if (expected !== actual) {
|
||||||
}
|
addError(
|
||||||
};
|
lineNumber,
|
||||||
|
"Expected: " + expected + "; Actual: " + actual,
|
||||||
|
null,
|
||||||
|
range);
|
||||||
|
}
|
||||||
|
};
|
||||||
errors.addContext =
|
errors.addContext =
|
||||||
function addContext(lineNumber, context, left, right, range) {
|
function addContext(lineNumber, context, left, right, range) {
|
||||||
if (context.length <= 30) {
|
if (context.length <= 30) {
|
||||||
|
|
|
||||||
|
|
@ -1186,7 +1186,8 @@ module.exports = [
|
||||||
.replace(/^\W*/, "").replace(/\W*$/, "");
|
.replace(/^\W*/, "").replace(/\W*$/, "");
|
||||||
if (names.indexOf(wordMatch) === -1) {
|
if (names.indexOf(wordMatch) === -1) {
|
||||||
var lineNumber = token.lineNumber + index + fenceOffset;
|
var lineNumber = token.lineNumber + index + fenceOffset;
|
||||||
errors.addDetailIf(lineNumber, name, match[1]);
|
var range = [ match.index + 1, wordMatch.length ];
|
||||||
|
errors.addDetailIf(lineNumber, name, match[1], range);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,3 +5,9 @@ An [empty]() link
|
||||||
An [empty](#) link with fragment
|
An [empty](#) link with fragment
|
||||||
|
|
||||||
This is a test file for the MARKDOWNLINT package.
|
This is a test file for the MARKDOWNLINT package.
|
||||||
|
|
||||||
|
This is a paragraph
|
||||||
|
about Markdownlint
|
||||||
|
that capitalizes the
|
||||||
|
name wrong twice:
|
||||||
|
MarkDownLint.
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
"errorRange": [4, 10]
|
"errorRange": [4, 10]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"lineNumber": 8,
|
"lineNumber": 14,
|
||||||
"ruleName": "MD043",
|
"ruleName": "MD043",
|
||||||
"ruleAlias": "required-headers",
|
"ruleAlias": "required-headers",
|
||||||
"ruleDescription": "Required header structure",
|
"ruleDescription": "Required header structure",
|
||||||
|
|
@ -42,6 +42,24 @@
|
||||||
"ruleDescription": "Proper names should have the correct capitalization",
|
"ruleDescription": "Proper names should have the correct capitalization",
|
||||||
"errorDetail": "Expected: markdownlint; Actual: MARKDOWNLINT",
|
"errorDetail": "Expected: markdownlint; Actual: MARKDOWNLINT",
|
||||||
"errorContext": null,
|
"errorContext": null,
|
||||||
"errorRange": null
|
"errorRange": [29, 12]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"lineNumber": 10,
|
||||||
|
"ruleName": "MD044",
|
||||||
|
"ruleAlias": "proper-names",
|
||||||
|
"ruleDescription": "Proper names should have the correct capitalization",
|
||||||
|
"errorDetail": "Expected: markdownlint; Actual: Markdownlint",
|
||||||
|
"errorContext": null,
|
||||||
|
"errorRange": [7, 12]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"lineNumber": 13,
|
||||||
|
"ruleName": "MD044",
|
||||||
|
"ruleAlias": "proper-names",
|
||||||
|
"ruleDescription": "Proper names should have the correct capitalization",
|
||||||
|
"errorDetail": "Expected: markdownlint; Actual: MarkDownLint",
|
||||||
|
"errorContext": null,
|
||||||
|
"errorRange": [1, 12]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
Loading…
Add table
Add a link
Reference in a new issue