mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-16 22:10:13 +01:00
Update MD051/link-fragments to support GitHub-style line/column range syntax in URLs (refs #1117).
This commit is contained in:
parent
ece0ccf269
commit
242b35f98f
8 changed files with 329 additions and 26 deletions
|
|
@ -119,11 +119,13 @@ module.exports = {
|
|||
for (const definition of definitions) {
|
||||
const { endColumn, startColumn } = definition;
|
||||
const text = unescapeStringTokenText(definition);
|
||||
const encodedText = `#${encodeURIComponent(text.slice(1))}`;
|
||||
const lineFragmentRe = /^#L\d+(?:C\d+)?(?:-L\d+(?:C\d+)?)?$/;
|
||||
if (
|
||||
(text.length > 1) &&
|
||||
text.startsWith("#") &&
|
||||
!fragments.has(text) &&
|
||||
!fragments.has(`#${encodeURIComponent(text.slice(1))}`)
|
||||
!fragments.has(encodedText) &&
|
||||
!lineFragmentRe.test(encodedText)
|
||||
) {
|
||||
// eslint-disable-next-line no-undef-init
|
||||
let context = undefined;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue