mirror of
https://github.com/theoludwig/markdownlint-rule-relative-links.git
synced 2025-05-27 11:37:24 +02:00
feat: support columns numbers (and line range) in links fragments
Fixes #7
This commit is contained in:
@ -11,6 +11,7 @@ const {
|
||||
isValidIntegerString,
|
||||
getNumberOfLines,
|
||||
getLineNumberStringFromFragment,
|
||||
lineFragmentRe,
|
||||
} = require("./utils.js")
|
||||
|
||||
/** @typedef {import('markdownlint').Rule} MarkdownLintRule */
|
||||
@ -133,6 +134,10 @@ const customRule = {
|
||||
|
||||
const hasOnlyDigits = isValidIntegerString(lineNumberFragmentString)
|
||||
if (!hasOnlyDigits) {
|
||||
if (lineFragmentRe.test(url.hash)) {
|
||||
continue
|
||||
}
|
||||
|
||||
onError({
|
||||
lineNumber,
|
||||
detail: `${detail} should have a valid fragment identifier`,
|
||||
|
@ -4,6 +4,8 @@ const { getHtmlAttributeRe } = require("./markdownlint-rule-helpers/helpers.js")
|
||||
|
||||
const markdownIt = new MarkdownIt({ html: true })
|
||||
|
||||
const lineFragmentRe = /^#(?:L\d+(?:C\d+)?-L\d+(?:C\d+)?|L\d+)$/
|
||||
|
||||
/**
|
||||
* Converts a Markdown heading into an HTML fragment according to the rules
|
||||
* used by GitHub.
|
||||
@ -151,6 +153,7 @@ const getLineNumberStringFromFragment = (fragment) => {
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
lineFragmentRe,
|
||||
convertHeadingToHTMLFragment,
|
||||
getMarkdownHeadings,
|
||||
getMarkdownIdOrAnchorNameFragments,
|
||||
|
Reference in New Issue
Block a user