mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 14:00:13 +01:00
Update MD051/link-fragments to add ignore_case parameter and improve documentation (fixes #1274).
This commit is contained in:
parent
74aa96d19d
commit
04c693b00b
16 changed files with 315 additions and 44 deletions
18
lib/configuration-strict.d.ts
vendored
18
lib/configuration-strict.d.ts
vendored
|
|
@ -937,11 +937,25 @@ export interface ConfigurationStrict {
|
|||
/**
|
||||
* MD051/link-fragments : Link fragments should be valid : https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md051.md
|
||||
*/
|
||||
MD051?: boolean;
|
||||
MD051?:
|
||||
| boolean
|
||||
| {
|
||||
/**
|
||||
* Ignore case of fragments
|
||||
*/
|
||||
ignore_case?: boolean;
|
||||
};
|
||||
/**
|
||||
* MD051/link-fragments : Link fragments should be valid : https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md051.md
|
||||
*/
|
||||
"link-fragments"?: boolean;
|
||||
"link-fragments"?:
|
||||
| boolean
|
||||
| {
|
||||
/**
|
||||
* Ignore case of fragments
|
||||
*/
|
||||
ignore_case?: boolean;
|
||||
};
|
||||
/**
|
||||
* MD052/reference-links-images : Reference links and images should use a label that is defined : https://github.com/DavidAnson/markdownlint/blob/v0.35.0/doc/md052.md
|
||||
*/
|
||||
|
|
|
|||
23
lib/md051.js
23
lib/md051.js
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
"use strict";
|
||||
|
||||
const { addError, addErrorDetailIf, getHtmlAttributeRe } = require("../helpers");
|
||||
const { addError, getHtmlAttributeRe } = require("../helpers");
|
||||
const { filterByPredicate, filterByTypes, getHtmlTagInfo } = require("../helpers/micromark-helpers.cjs");
|
||||
const { filterByTypesCached } = require("./cache");
|
||||
|
||||
|
|
@ -68,6 +68,7 @@ module.exports = {
|
|||
"tags": [ "links" ],
|
||||
"parser": "micromark",
|
||||
"function": function MD051(params, onError) {
|
||||
const ignoreCase = params.config.ignore_case || false;
|
||||
const fragments = new Map();
|
||||
|
||||
// Process headings
|
||||
|
|
@ -143,16 +144,16 @@ module.exports = {
|
|||
if (mixedCaseKey) {
|
||||
// @ts-ignore
|
||||
(fixInfo || {}).insertText = mixedCaseKey;
|
||||
addErrorDetailIf(
|
||||
onError,
|
||||
link.startLine,
|
||||
mixedCaseKey,
|
||||
text,
|
||||
undefined,
|
||||
context,
|
||||
range,
|
||||
fixInfo
|
||||
);
|
||||
if (!ignoreCase && (mixedCaseKey !== text)) {
|
||||
addError(
|
||||
onError,
|
||||
link.startLine,
|
||||
`Expected: ${mixedCaseKey}; Actual: ${text}`,
|
||||
context,
|
||||
range,
|
||||
fixInfo
|
||||
);
|
||||
}
|
||||
} else {
|
||||
addError(
|
||||
onError,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue