mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +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) {
|
||||
addError(lineNumber, detail);
|
||||
};
|
||||
errors.addDetailIf = function addDetailIf(lineNumber, expected, actual) {
|
||||
if (expected !== actual) {
|
||||
addError(lineNumber, "Expected: " + expected + "; Actual: " + actual);
|
||||
}
|
||||
};
|
||||
errors.addDetailIf =
|
||||
function addDetailIf(lineNumber, expected, actual, range) {
|
||||
if (expected !== actual) {
|
||||
addError(
|
||||
lineNumber,
|
||||
"Expected: " + expected + "; Actual: " + actual,
|
||||
null,
|
||||
range);
|
||||
}
|
||||
};
|
||||
errors.addContext =
|
||||
function addContext(lineNumber, context, left, right, range) {
|
||||
if (context.length <= 30) {
|
||||
|
|
|
|||
|
|
@ -1186,7 +1186,8 @@ module.exports = [
|
|||
.replace(/^\W*/, "").replace(/\W*$/, "");
|
||||
if (names.indexOf(wordMatch) === -1) {
|
||||
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
|
||||
|
||||
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]
|
||||
},
|
||||
{
|
||||
"lineNumber": 8,
|
||||
"lineNumber": 14,
|
||||
"ruleName": "MD043",
|
||||
"ruleAlias": "required-headers",
|
||||
"ruleDescription": "Required header structure",
|
||||
|
|
@ -42,6 +42,24 @@
|
|||
"ruleDescription": "Proper names should have the correct capitalization",
|
||||
"errorDetail": "Expected: markdownlint; Actual: MARKDOWNLINT",
|
||||
"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