Refine previous commit for MD051/link-fragments to tweak behavior, tests, and documentation.

This commit is contained in:
David Anson 2024-02-10 15:36:12 -08:00
parent 242b35f98f
commit 45c8766eda
8 changed files with 259 additions and 148 deletions

View file

@ -11,6 +11,7 @@ const { filterByPredicate, filterByTypes, getHtmlTagInfo } =
const idRe = getHtmlAttributeRe("id");
const nameRe = getHtmlAttributeRe("name");
const anchorRe = /\{(#[a-z\d]+(?:[-_][a-z\d]+)*)\}/gu;
const lineFragmentRe = /^#(?:L\d+(?:C\d+)?-L\d+(?:C\d+)?|L\d+)$/;
// Sets for filtering heading tokens during conversion
const childrenExclude = new Set([ "image", "reference", "resource" ]);
@ -120,7 +121,6 @@ module.exports = {
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("#") &&