mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-23 17:30:12 +01:00
Update MD051/link-fragments to add the ignored_pattern configuration parameter (fixes #547).
This commit is contained in:
parent
45932c7837
commit
02478d24cf
17 changed files with 297 additions and 4 deletions
|
|
@ -66,6 +66,8 @@ export default {
|
|||
"parser": "micromark",
|
||||
"function": function MD051(params, onError) {
|
||||
const ignoreCase = params.config.ignore_case || false;
|
||||
const ignoredPattern = params.config.ignored_pattern || "";
|
||||
const ignoredPatternRe = new RegExp(ignoredPattern || "^$");
|
||||
/** @type {Map<string, number>} */
|
||||
const fragments = new Map([ [ "#top", 0 ] ]);
|
||||
|
||||
|
|
@ -114,12 +116,14 @@ export default {
|
|||
for (const definition of definitions) {
|
||||
const { endColumn, startColumn } = definition;
|
||||
const text = unescapeStringTokenText(definition);
|
||||
const encodedText = `#${encodeURIComponent(text.slice(1))}`;
|
||||
const textSliceOne = text.slice(1);
|
||||
const encodedText = `#${encodeURIComponent(textSliceOne)}`;
|
||||
if (
|
||||
(text.length > 1) &&
|
||||
text.startsWith("#") &&
|
||||
!fragments.has(encodedText) &&
|
||||
!lineFragmentRe.test(encodedText)
|
||||
!lineFragmentRe.test(encodedText) &&
|
||||
!ignoredPatternRe.test(textSliceOne)
|
||||
) {
|
||||
let context = undefined;
|
||||
let range = undefined;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue