mdrefine 0.2.1 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"links.js","sourceRoot":"","sources":["../../src/rules/links.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGzC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAExD;;;;GAIG;AACH,SAAS,gBAAgB,CAAC,WAAmB;IAC3C,OAAO,GAAG,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC;AAC3E,CAAC;AACD,SAAS,WAAW,CAAC,IAAW;IAC9B,IAAI,IAAI,CAAC,IAAI,KAAK,UAAU;QAAE,OAAO,IAAI,CAAC,MAAM,CAAC;IACjD,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,IAAI,CAAC,IAAI,KAAK,YAAY;QAAE,OAAO,IAAI,CAAC,GAAG,CAAC;IACjG,OAAO,SAAS,CAAC;AACnB,CAAC;AACD,+FAA+F;AAC/F,SAAS,gBAAgB,CAAC,GAAW;IACnC,IAAI,OAAO,GAAG,CAAC,CAAC;IAChB,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC;IACjB,KAAK,IAAI,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MA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C,CAAC,CAAC,EAAE,GAAG;iBACrG,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC;QAClB,CAAC;KACF;CACF,CAAC","sourcesContent":["import path from \"node:path\";\nimport { walk } from \"../syntax/walk.js\";\nimport type { Definition, FootnoteDefinition, Nodes } from \"mdast\";\nimport type { Document, Finding, Rule } from \"../core/types.js\";\nimport { range } from \"../syntax/parse.js\";\nimport { changesForgeHeading } from \"../workspace/heading-attributes.js\";\nimport { splitDestination } from \"../workspace/index.js\";\nimport { giteaPyLine, optionsSchema } from \"./style.js\";\n\n/**\n * What Gitea's `_.py` emphasis exception can see of a link destination: whether\n * it contains `_`, and whether its first `_` starts `_.py`. A delimiter earlier\n * on the line looks for the next `_` there.\n */\nfunction giteaUnderscores(destination: string): string {\n return `${destination.includes(\"_\")} ${/^[^_]*_\\.py/.test(destination)}`;\n}\nfunction destination(node: Nodes): string | undefined {\n if (node.type === \"wikiLink\") return node.target;\n if (node.type === \"link\" || node.type === \"image\" || node.type === \"definition\") return node.url;\n return undefined;\n}\n/** Locate an inline destination within a parsed link, retaining labels and optional titles. */\nfunction destinationRange(raw: string): [number, number] | undefined {\n let bracket = 0;\n let opening = -1;\n for (let i = raw.startsWith(\"!\") ? 1 : 0; i < raw.length; i++) {\n if (raw[i] === \"\\\\\") {\n i++;\n continue;\n }\n if (raw[i] === \"[\") bracket++;\n if (raw[i] === \"]\" && --bracket === 0 && raw[i + 1] === \"(\") {\n opening = i + 2;\n break;\n }\n }\n if (opening < 0) return undefined;\n while (/\\s/.test(raw[opening] ?? \"\")) opening++;\n if (raw[opening] === \"<\") {\n for (let i = opening + 1; i < raw.length; i++) {\n if (raw[i] === \"\\\\\") {\n i++;\n continue;\n }\n if (raw[i] === \">\") return [opening, i + 1];\n }\n return undefined;\n }\n let depth = 0;\n for (let i = opening; i < raw.length; i++) {\n const char = raw[i]!;\n if (char === \"\\\\\") {\n i++;\n continue;\n }\n if (char === \"(\") depth++;\n if ((char === \")\" && depth-- === 0) || /\\s/.test(char)) return [opening, i];\n }\n return undefined;\n}\n\n/**\n * A Markdown link's destination as a wikilink's target, or undefined when a\n * wikilink cannot hold it. Obsidian takes a wikilink's text as the note's\n * name, so percent escapes are decoded: `My%20Note.md` is the note `My\n * Note.md`, which is right whether or not Obsidian decodes escapes in\n * wikilinks. A destination that does not decode, or whose decoded name holds\n * a character that a wikilink cannot contain, or that would change its meaning\n * there, stays a Markdown link.\n */\nfunction wikiTarget(url: string): string | undefined {\n const hash = url.indexOf(\"#\");\n const [name, fragment] = hash < 0 ? [url, undefined] : [url.slice(0, hash), url.slice(hash + 1)];\n let decodedName: string;\n let decodedFragment: string | undefined;\n try {\n decodedName = decodeURIComponent(name);\n decodedFragment = fragment === undefined ? undefined : decodeURIComponent(fragment);\n } catch {\n return undefined;\n }\n if (/[[\\]|#^\\r\\n]/.test(decodedName) || decodedName.trim() !== decodedName) return undefined;\n if (decodedFragment !== undefined) {\n if (/[[\\]|\\r\\n]/.test(decodedFragment)) return undefined;\n // An escaped `#` or `^` would become a separator or a block reference.\n const marks = (text: string) => text.replace(/[^#^]/g, \"\");\n if (marks(decodedFragment) !== marks(fragment!)) return undefined;\n }\n return decodedFragment === undefined ? decodedName : `${decodedName}#${decodedFragment}`;\n}\n/**\n * A label as CommonMark matches it: case folded, with its blank space\n * collapsed and trimmed. This is how the parser computes the `identifier` of\n * definitions and references, so the two compare equal.\n */\nfunction normalizeLabel(label: string): string {\n return label\n .replace(/[\\t\\n\\r ]+/g, \" \")\n .replace(/^ | $/g, \"\")\n .toLowerCase()\n .toUpperCase()\n .toLowerCase();\n}\n/**\n * A label's text as the parser reads it, from its source: without the block\n * quote markers and indentation that continue its lines inside a container.\n */\nfunction labelText(source: string): string {\n return source.replace(/(\\r\\n|\\r|\\n)[ \\t>]*/g, \"$1\");\n}\n/**\n * The end, after its `]`, of the link label that starts with the `[` at `at`\n * and ends before `limit`: the first unescaped `]`, with no unescaped `[`\n * before it, at most 999 characters, and something besides blank space.\n */\nfunction labelEnd(source: string, at: number, limit: number): number | undefined {\n let blank = true;\n for (let i = at + 1; i < limit && i - at <= 1000; i++) {\n const char = source[i]!;\n if (char === \"\\\\\" && /[[\\]\\\\]/.test(source[i + 1] ?? \"\")) {\n blank = false;\n i++;\n } else if (char === \"[\") return undefined;\n else if (char === \"]\") return blank ? undefined : i + 1;\n else if (!/[ \\t\\r\\n]/.test(char)) blank = false;\n }\n return undefined;\n}\n/** A GFM footnote label after `^`: no blank space, and brackets only escaped. */\nconst footnoteLabel = /^\\^((?:\\\\[[\\]\\\\]|\\\\(?![[\\]\\\\])|[^\\s[\\]\\\\]){1,999})$/;\n/** Inline nodes whose text is read for brackets; any other node is syntax or a link of its own. */\nconst transparent = new Set([\"emphasis\", \"strong\", \"delete\"]);\n/**\n * What before a reference's text makes it no reference to report: an ASCII\n * letter, digit, `_`, or `)`, as in the indexes `matrix[i][j]` and `f(x)[0][1]`\n * in prose, or a `]`, which continues a run like `[a][b][c]` that is reported\n * once, at its start.\n */\nconst notAfter = /[\\w\\])]/;\n/** Characters that a backslash escapes. */\nconst asciiPunctuation = /[!-/:-@[-`{-~]/;\ninterface Reference {\n start: number;\n end: number;\n label: string;\n footnote: boolean;\n}\n/**\n * The full (`[text][label]`) and collapsed (`[label][]`) references, and with\n * `footnotes` the footnote references (`[^label]`), whose label has no\n * definition. The parser leaves these as plain text, so they are found in the\n * text of each paragraph, heading, and table cell, as CommonMark pairs its\n * brackets. Brackets in code, math, HTML, links, images, and other syntax, and\n * escaped ones, are not read.\n */\nfunction undefinedReferences(\n document: Document,\n definitions: Set<string>,\n footnotes: Set<string> | undefined,\n): Reference[] {\n const { source } = document;\n if (!source.includes(\"[\")) return [];\n const references: Reference[] = [];\n const forge = document.dialect === \"forgejo\" || document.dialect === \"gitea\";\n // 1 where a character is text that the parser reads brackets in.\n const readable = new Uint8Array(source.length);\n const collect = (node: Nodes) => {\n if (!(\"children\" in node)) return;\n for (const child of node.children)\n if (child.type === \"text\") {\n const [from, to] = range(child);\n for (let i = from; i < to; i++) {\n if (source[i] === \"\\\\\" && i + 1 < to && asciiPunctuation.test(source[i + 1]!)) i++;\n else readable[i] = 1;\n }\n } else if (transparent.has(child.type)) collect(child);\n };\n walk(document.tree, (node) => {\n if (node.type !== \"paragraph\" && node.type !== \"heading\" && node.type !== \"tableCell\") return;\n const [start, end] = range(node);\n // Searched in the block's own text, so that blocks without brackets cost no more than that.\n const text = source.slice(start, end);\n if (!text.includes(\"[\")) return;\n collect(node);\n // Forgejo and Gitea render `\\(...\\)` and `\\[...\\]` as math, which GFM reads as text.\n if (forge)\n for (const [open, close] of [\n [\"\\\\(\", \"\\\\)\"],\n [\"\\\\[\", \"\\\\]\"],\n ] as const)\n for (let from = 0; ;) {\n const opening = text.indexOf(open, from);\n const closing = opening < 0 ? -1 : text.indexOf(close, opening + 2);\n if (closing < 0) break;\n readable.fill(0, start + opening, start + closing + 2);\n from = closing + 2;\n }\n const openers: number[] = [];\n // The opening bracket of the last full reference's label, which is not read again.\n let label = -1;\n for (let i = start; i < end; i++) {\n if (!readable[i]) continue;\n if (source[i] === \"[\") {\n openers.push(i);\n continue;\n }\n if (source[i] !== \"]\") continue;\n const opener = openers.pop();\n if (opener === undefined || opener === label) continue;\n let reference: Reference | undefined;\n if (source[i + 1] === \"[\" && readable[i + 1]) {\n if (source[i + 2] === \"]\" && readable[i + 2]) {\n // Collapsed: the text is the label.\n if (labelEnd(source, opener, i + 1) === i + 1)\n reference = {\n start: opener,\n end: i + 3,\n label: source.slice(opener + 1, i),\n footnote: false,\n };\n } else {\n const after = labelEnd(source, i + 1, end);\n if (after !== undefined && readable[after - 1]) {\n reference = {\n start: opener,\n end: after,\n label: source.slice(i + 2, after - 1),\n footnote: false,\n };\n label = i + 1;\n }\n }\n if (reference) {\n if (\n !definitions.has(normalizeLabel(labelText(reference.label))) &&\n !(opener > 0 && readable[opener - 1] && notAfter.test(source[opener - 1]!))\n )\n references.push(reference);\n continue;\n }\n }\n // A footnote label has at most 999 characters after its `^`.\n if (!footnotes || source[opener + 1] !== \"^\" || i - opener > 1001) continue;\n const footnote = footnoteLabel.exec(source.slice(opener + 1, i));\n if (footnote && !footnotes.has(normalizeLabel(footnote[1]!)))\n references.push({ start: opener, end: i + 1, label: footnote[1]!, footnote: true });\n }\n });\n return references;\n}\n\n/** Names the first few of the paths that could not be read, and counts the rest. */\nfunction named(paths: string[]): string {\n return paths.length > 3\n ? `${paths.slice(0, 3).join(\", \")}, and ${paths.length - 3} more`\n : paths.join(\", \");\n}\n\nexport const linkRules: Record<string, Rule> = {\n \"links/valid\": {\n description: \"Check local link destinations and dialect-specific heading/block references.\",\n kind: \"problem\",\n schema: optionsSchema({}),\n check({ document, workspace }) {\n const findings: Finding[] = [];\n // The parser only produces reference nodes for labels that have a\n // definition; undefined references stay plain text.\n walk(document.tree, (node) => {\n const url = destination(node);\n if (url === undefined || !workspace) return;\n const result = workspace.resolve(\n document.path,\n url,\n document.dialect,\n node.type === \"wikiLink\",\n );\n if (result.status === \"missing\" && result.outside !== undefined && result.vault)\n // The file is there, so \"missing\" would mislead: Obsidian cannot reach it.\n findings.push({\n start: range(node)[0],\n message: `Local target is outside the vault: ${url} (${result.outside} is not in ${result.vault}, where Obsidian looks).`,\n });\n else if (result.status === \"missing\" || result.status === \"ambiguous\")\n findings.push({\n start: range(node)[0],\n message: `${result.status === \"missing\" ? \"Missing\" : \"Ambiguous\"} local target: ${url}.`,\n });\n else if (result.status === \"directory\" && document.dialect === \"obsidian\")\n findings.push({ start: range(node)[0], message: `Local target is a directory: ${url}.` });\n else if (result.status === \"unreadable\") {\n // Neither found nor known to be missing: say what stood in the way.\n const limits = result.unreadable ?? [];\n // The rest of a vault that the workspace root is only a folder of.\n const outsideRoot = (name: string) => name === \"..\" || name.startsWith(\"../\");\n const directories = limits.filter((name) => !outsideRoot(name));\n const reasons = [\n ...(directories.length ? [`cannot read ${named(directories)}`] : []),\n ...(limits.some(outsideRoot) ? [\"the workspace root is only a part of the vault\"] : []),\n ];\n findings.push({\n start: range(node)[0],\n message:\n result.leavesRoot !== undefined\n ? `Local target could not be checked: ${url} (${result.leavesRoot} leads outside the workspace root, which the tool does not read).`\n : result.target === undefined\n ? `Local target could not be checked: ${url} (no readable match; ${reasons.join(\"; \")}).`\n : `Fragment could not be checked: ${url} (cannot read ${result.target}).`,\n });\n } else if (result.status === \"resolved\" && !result.fragmentExists)\n findings.push({ start: range(node)[0], message: `Missing fragment in ${url}.` });\n });\n return findings;\n },\n },\n \"links/path\": {\n description: \"Rewrite verified local destinations using the configured path and bracket style.\",\n kind: \"style\",\n phase: \"inline\",\n schema: optionsSchema({\n style: { enum: [\"relative\", \"root\", \"shortest\", \"preserve\"] },\n brackets: { enum: [\"angle\", \"bare\", \"preserve\"] },\n extension: { enum: [\"include\", \"omit\", \"preserve\"] },\n leadingDot: { type: \"boolean\" },\n }),\n check({ document, options, workspace }) {\n const findings: Finding[] = [];\n walk(document.tree, (node) => {\n const url = destination(node);\n if (url === undefined || !workspace) return;\n const result = workspace.resolve(\n document.path,\n url,\n document.dialect,\n node.type === \"wikiLink\",\n );\n if (result.status !== \"resolved\" || !result.target || !result.fragmentExists) return;\n // Found by name among the readable files only: a directory that could not\n // be read may hold another match, and a rewrite would choose between them.\n if (result.unreadable) return;\n const parts = splitDestination(url);\n let target = parts.path;\n const style = options.style ?? \"preserve\";\n // Vault roots and extensionless Markdown are renderer-specific; don't change other dialects.\n if (\n document.dialect !== \"obsidian\" &&\n (style === \"root\" || style === \"shortest\" || options.extension === \"omit\")\n )\n return;\n if (parts.path) {\n // Obsidian counts a path from the note's vault, which need not be the root.\n const rooted = result.rooted ?? result.target;\n if (style === \"root\") target = rooted;\n else if (style === \"relative\")\n target = path.posix.relative(path.posix.dirname(document.path), result.target);\n else if (style === \"shortest\") {\n const basename = path.posix.basename(result.target);\n const resolved = workspace.resolve(document.path, basename, document.dialect, true);\n target =\n resolved.status === \"resolved\" &&\n resolved.target === result.target &&\n !resolved.unreadable\n ? basename\n : rooted;\n }\n if (document.dialect === \"obsidian\" && result.target.endsWith(\".md\")) {\n if (\n options.extension === \"omit\" ||\n ((options.extension ?? \"preserve\") === \"preserve\" && !parts.path.endsWith(\".md\"))\n )\n target = target.replace(/\\.md$/, \"\");\n else if (options.extension === \"include\" && !target.endsWith(\".md\")) target += \".md\";\n }\n if (style === \"relative\" && options.leadingDot === true && !target.startsWith(\".\"))\n target = `./${target}`;\n }\n // Encode reserved path characters before reattaching a separately parsed fragment.\n const hash = url.indexOf(\"#\");\n const encodedPath =\n target === parts.path\n ? hash < 0\n ? url\n : url.slice(0, hash)\n : target.replaceAll(\"%\", \"%25\").replaceAll(\"#\", \"%23\");\n let replacement =\n encodedPath +\n (hash < 0\n ? \"\"\n : target === parts.path\n ? url.slice(hash)\n : `#${parts.fragment.replaceAll(\"%\", \"%25\")}`);\n // A relative basename can collide with a vault-root path. Make the\n // relative spelling explicit before proposing an identity-changing edit.\n let verified = workspace.resolve(\n document.path,\n replacement,\n document.dialect,\n node.type === \"wikiLink\",\n );\n if (\n style === \"relative\" &&\n parts.path &&\n !replacement.startsWith(\".\") &&\n (verified.status !== \"resolved\" ||\n verified.target !== result.target ||\n verified.unreadable)\n ) {\n replacement = `./${replacement}`;\n verified = workspace.resolve(\n document.path,\n replacement,\n document.dialect,\n node.type === \"wikiLink\",\n );\n }\n if (\n verified.status !== \"resolved\" ||\n verified.target !== result.target ||\n verified.fragment !== result.fragment ||\n verified.unreadable\n )\n return;\n const [start, end] = range(node);\n if (node.type === \"wikiLink\") {\n if (/[[\\]|\\r\\n]/.test(replacement)) return;\n if (!node.embed && node.label === undefined && replacement !== node.target) return;\n replacement = `${node.embed ? \"!\" : \"\"}[[${replacement}${node.label === undefined ? \"\" : `|${node.label}`}]]`;\n if (replacement !== document.source.slice(start, end))\n findings.push({\n start,\n end,\n message: \"Normalize wikilink destination.\",\n edit: { start, end, text: replacement },\n });\n return;\n }\n if (node.type === \"definition\") return; // Definitions are validated; retain their exact layout in this release.\n const raw = document.source.slice(start, end);\n const span = destinationRange(raw);\n if (!span) return; // Autolinks have no parenthesized destination.\n const original = raw.slice(...span);\n const angle =\n options.brackets === \"angle\" ||\n ((options.brackets ?? \"preserve\") === \"preserve\" && original.startsWith(\"<\"));\n if (angle)\n replacement = `<${replacement.replaceAll(\"<\", \"%3C\").replaceAll(\">\", \"%3E\").replaceAll(\"\\\\\", \"%5C\")}>`;\n else\n replacement = replacement\n .replaceAll(\" \", \"%20\")\n .replaceAll(\"(\", \"%28\")\n .replaceAll(\")\", \"%29\")\n .replaceAll(\"<\", \"%3C\")\n .replaceAll(\">\", \"%3E\");\n if (\n document.dialect === \"gitea\" &&\n (giteaPyLine(document, start, end) || replacement.includes(\"_.py\")) &&\n giteaUnderscores(original) !== giteaUnderscores(replacement)\n )\n return;\n // On Forgejo, and Gitea before 1.26, the destination is part of the\n // heading's anchor, and text they read as attributes is no link there.\n if (changesForgeHeading(document, start, end)) return;\n if (original !== replacement)\n findings.push({\n start: start + span[0],\n end: start + span[1],\n message: \"Normalize link destination.\",\n edit: { start: start + span[0], end: start + span[1], text: replacement },\n });\n });\n return findings;\n },\n },\n \"links/notation\": {\n description: \"Convert plain-label Obsidian links between Markdown and wikilink notation.\",\n kind: \"style\",\n phase: \"inline\",\n schema: optionsSchema({ style: { enum: [\"markdown\", \"wiki\"] } }),\n check({ document, options, workspace }) {\n if (document.dialect !== \"obsidian\" || !workspace) return [];\n const findings: Finding[] = [];\n walk(document.tree, (node) => {\n const [start, end] = range(node);\n let replacement: string | undefined;\n if (\n options.style === \"markdown\" &&\n node.type === \"wikiLink\" &&\n !node.embed &&\n node.label !== undefined\n ) {\n if (/[[\\]<>\\\\\\r\\n]/.test(node.target ?? \"\") || /[*_`[\\]\\\\]/.test(node.label)) return;\n replacement = `[${node.label}](<${node.target}>)`;\n } else if (\n options.style === \"wiki\" &&\n node.type === \"link\" &&\n !node.title &&\n node.children.length === 1 &&\n node.children[0]?.type === \"text\"\n ) {\n const label = node.children[0].value;\n const target = wikiTarget(node.url);\n if (target === undefined || /[[\\]|\\r\\n]/.test(label)) return;\n replacement = `[[${target}|${label}]]`;\n }\n const url = destination(node);\n if (!replacement || url === undefined) return;\n const result = workspace.resolve(\n document.path,\n url,\n document.dialect,\n node.type === \"wikiLink\",\n );\n // A target that is uncertain, because a directory could not be read, is left as written.\n if (result.status !== \"resolved\" || result.unreadable) return;\n findings.push({\n start,\n end,\n message: `Use ${String(options.style)} link notation.`,\n edit: { start, end, text: replacement },\n });\n });\n return findings;\n },\n },\n \"links/undefined-reference\": {\n description:\n \"Report full, collapsed, and footnote references whose label has no definition, which show as plain text.\",\n kind: \"problem\",\n schema: optionsSchema({}),\n check({ document }) {\n const definitions = new Set<string>();\n const footnotes = new Set<string>();\n walk(document.tree, (node) => {\n if (node.type === \"definition\") definitions.add(node.identifier);\n if (node.type === \"footnoteDefinition\") footnotes.add(node.identifier);\n });\n // CommonMark has no footnotes: there `[^label]` is an ordinary shortcut reference.\n return undefinedReferences(\n document,\n definitions,\n document.dialect === \"commonmark\" ? undefined : footnotes,\n ).map(({ start, end, label, footnote }) => {\n const name = (footnote ? `^${label}` : labelText(label)).replace(/\\s+/g, \" \").trim();\n return {\n start,\n end,\n message: `${footnote ? \"Footnote\" : \"Reference\"} [${name}] has no definition and shows as plain text.`,\n };\n });\n },\n },\n \"links/unused-definition\": {\n description: \"Report link and footnote definitions that no reference uses.\",\n kind: \"problem\",\n schema: optionsSchema({}),\n check({ document }) {\n // Link and footnote labels are kept apart, as `link:` and `footnote:` keys.\n const used = new Set<string>();\n const definitions: (Definition | FootnoteDefinition)[] = [];\n walk(document.tree, (node) => {\n // A shortcut reference `[label]` that has a definition is a reference node too.\n if (node.type === \"linkReference\" || node.type === \"imageReference\")\n used.add(`link:${node.identifier}`);\n else if (node.type === \"footnoteReference\") used.add(`footnote:${node.identifier}`);\n else if (node.type === \"definition\" || node.type === \"footnoteDefinition\")\n definitions.push(node);\n });\n const findings: Finding[] = [];\n const seen = new Set<string>();\n for (const node of definitions) {\n const footnote = node.type === \"footnoteDefinition\";\n const key = `${footnote ? \"footnote\" : \"link\"}:${node.identifier}`;\n const label = (node.label ?? node.identifier).replace(/\\s+/g, \" \").trim();\n const name = `[${footnote ? \"^\" : \"\"}${label}]`;\n const [start] = range(node);\n // CommonMark uses the first definition of a label; a later one is never used.\n if (seen.has(key))\n findings.push({\n start,\n message: `${footnote ? \"Footnote\" : \"Definition\"} ${name} repeats an earlier one, which references use instead.`,\n });\n else if (!used.has(key))\n findings.push({\n start,\n message: footnote\n ? `Footnote ${name} is not referenced${document.dialect === \"github\" ? \", and GitHub does not show it\" : \"\"}.`\n : `Definition ${name} is not used by any reference.`,\n });\n seen.add(key);\n }\n return findings;\n },\n },\n \"links/empty\": {\n description: \"Report links and images whose destination is empty or only #.\",\n kind: \"problem\",\n schema: optionsSchema({}),\n check({ document }) {\n const findings: Finding[] = [];\n // A reference has its definition's destination, which is reported once, at the definition.\n walk(document.tree, (node) => {\n if (node.type !== \"link\" && node.type !== \"image\" && node.type !== \"definition\") return;\n if (node.url !== \"\" && node.url !== \"#\") return;\n const what =\n node.type === \"image\"\n ? \"Image source\"\n : node.type === \"definition\"\n ? `Destination of definition [${(node.label ?? node.identifier).replace(/\\s+/g, \" \").trim()}]`\n : \"Link destination\";\n findings.push({\n start: range(node)[0],\n message:\n node.url === \"\"\n ? `${what} is empty.`\n : `${what} is only #${node.type === \"link\" ? \", which only leads to the top of the page\" : \"\"}.`,\n });\n });\n return findings;\n },\n },\n};\n"]}
1
+ {"version":3,"file":"links.js","sourceRoot":"","sources":["../../src/rules/links.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGzC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAE,gB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"../syntax/walk.js\";\nimport type { Definition, FootnoteDefinition, Nodes } from \"mdast\";\nimport type { Document, Finding, Rule } from \"../core/types.js\";\nimport { range } from \"../syntax/parse.js\";\nimport { changesForgeHeading } from \"../workspace/heading-attributes.js\";\nimport { splitDestination } from \"../workspace/index.js\";\nimport { giteaPyLine, optionsSchema } from \"./style.js\";\n\n/**\n * What Gitea's `_.py` emphasis exception can see of a link destination: whether\n * it contains `_`, and whether its first `_` starts `_.py`. A delimiter earlier\n * on the line looks for the next `_` there.\n */\nfunction giteaUnderscores(destination: string): string {\n return `${destination.includes(\"_\")} ${/^[^_]*_\\.py/.test(destination)}`;\n}\nfunction destination(node: Nodes): string | undefined {\n if (node.type === \"wikiLink\") return node.target;\n if (node.type === \"link\" || node.type === \"image\" || node.type === \"definition\") return node.url;\n return undefined;\n}\n/** Locate an inline destination within a parsed link, retaining labels and optional titles. */\nfunction destinationRange(raw: string): [number, number] | undefined {\n let bracket = 0;\n let opening = -1;\n for (let i = raw.startsWith(\"!\") ? 1 : 0; i < raw.length; i++) {\n if (raw[i] === \"\\\\\") {\n i++;\n continue;\n }\n if (raw[i] === \"[\") bracket++;\n if (raw[i] === \"]\" && --bracket === 0 && raw[i + 1] === \"(\") {\n opening = i + 2;\n break;\n }\n }\n if (opening < 0) return undefined;\n while (/\\s/.test(raw[opening] ?? \"\")) opening++;\n if (raw[opening] === \"<\") {\n for (let i = opening + 1; i < raw.length; i++) {\n if (raw[i] === \"\\\\\") {\n i++;\n continue;\n }\n if (raw[i] === \">\") return [opening, i + 1];\n }\n return undefined;\n }\n let depth = 0;\n for (let i = opening; i < raw.length; i++) {\n const char = raw[i]!;\n if (char === \"\\\\\") {\n i++;\n continue;\n }\n if (char === \"(\") depth++;\n if ((char === \")\" && depth-- === 0) || /\\s/.test(char)) return [opening, i];\n }\n return undefined;\n}\n\n/**\n * A Markdown link's destination as a wikilink's target, or undefined when a\n * wikilink cannot hold it. Obsidian takes a wikilink's text as the note's\n * name, so percent escapes are decoded: `My%20Note.md` is the note `My\n * Note.md`, which is right whether or not Obsidian decodes escapes in\n * wikilinks. A destination that does not decode, or whose decoded name holds\n * a character that a wikilink cannot contain, or that would change its meaning\n * there, stays a Markdown link.\n */\nfunction wikiTarget(url: string): string | undefined {\n const hash = url.indexOf(\"#\");\n const [name, fragment] = hash < 0 ? [url, undefined] : [url.slice(0, hash), url.slice(hash + 1)];\n let decodedName: string;\n let decodedFragment: string | undefined;\n try {\n decodedName = decodeURIComponent(name);\n decodedFragment = fragment === undefined ? undefined : decodeURIComponent(fragment);\n } catch {\n return undefined;\n }\n if (/[[\\]|#^\\r\\n]/.test(decodedName) || decodedName.trim() !== decodedName) return undefined;\n if (decodedFragment !== undefined) {\n if (/[[\\]|\\r\\n]/.test(decodedFragment)) return undefined;\n // An escaped `#` or `^` would become a separator or a block reference.\n const marks = (text: string) => text.replace(/[^#^]/g, \"\");\n if (marks(decodedFragment) !== marks(fragment!)) return undefined;\n }\n return decodedFragment === undefined ? decodedName : `${decodedName}#${decodedFragment}`;\n}\n/**\n * A label as CommonMark matches it: case folded, with its blank space\n * collapsed and trimmed. This is how the parser computes the `identifier` of\n * definitions and references, so the two compare equal.\n */\nfunction normalizeLabel(label: string): string {\n return label\n .replace(/[\\t\\n\\r ]+/g, \" \")\n .replace(/^ | $/g, \"\")\n .toLowerCase()\n .toUpperCase()\n .toLowerCase();\n}\n/**\n * A label's text as the parser reads it, from its source: without the block\n * quote markers and indentation that continue its lines inside a container.\n */\nfunction labelText(source: string): string {\n return source.replace(/(\\r\\n|\\r|\\n)[ \\t>]*/g, \"$1\");\n}\n/**\n * The end, after its `]`, of the link label that starts with the `[` at `at`\n * and ends before `limit`: the first unescaped `]`, with no unescaped `[`\n * before it, at most 999 characters, and something besides blank space.\n */\nfunction labelEnd(source: string, at: number, limit: number): number | undefined {\n let blank = true;\n for (let i = at + 1; i < limit && i - at <= 1000; i++) {\n const char = source[i]!;\n if (char === \"\\\\\" && /[[\\]\\\\]/.test(source[i + 1] ?? \"\")) {\n blank = false;\n i++;\n } else if (char === \"[\") return undefined;\n else if (char === \"]\") return blank ? undefined : i + 1;\n else if (!/[ \\t\\r\\n]/.test(char)) blank = false;\n }\n return undefined;\n}\n/** A GFM footnote label after `^`: no blank space, and brackets only escaped. */\nconst footnoteLabel = /^\\^((?:\\\\[[\\]\\\\]|\\\\(?![[\\]\\\\])|[^\\s[\\]\\\\]){1,999})$/;\n/** Inline nodes whose text is read for brackets; any other node is syntax or a link of its own. */\nconst transparent = new Set([\"emphasis\", \"strong\", \"delete\"]);\n/**\n * What before a reference's text makes it no reference to report: an ASCII\n * letter, digit, `_`, or `)`, as in the indexes `matrix[i][j]` and `f(x)[0][1]`\n * in prose, or a `]`, which continues a run like `[a][b][c]` that is reported\n * once, at its start.\n */\nconst notAfter = /[\\w\\])]/;\n/** Characters that a backslash escapes. */\nconst asciiPunctuation = /[!-/:-@[-`{-~]/;\ninterface Reference {\n start: number;\n end: number;\n label: string;\n footnote: boolean;\n}\n/**\n * The full (`[text][label]`) and collapsed (`[label][]`) references, and with\n * `footnotes` the footnote references (`[^label]`), whose label has no\n * definition. The parser leaves these as plain text, so they are found in the\n * text of each paragraph, heading, and table cell, as CommonMark pairs its\n * brackets. Brackets in code, math, HTML, links, images, and other syntax, and\n * escaped ones, are not read.\n */\nfunction undefinedReferences(\n document: Document,\n definitions: Set<string>,\n footnotes: Set<string> | undefined,\n): Reference[] {\n const { source } = document;\n if (!source.includes(\"[\")) return [];\n const references: Reference[] = [];\n const forge = document.dialect === \"forgejo\" || document.dialect === \"gitea\";\n // 1 where a character is text that the parser reads brackets in.\n const readable = new Uint8Array(source.length);\n const collect = (node: Nodes) => {\n if (!(\"children\" in node)) return;\n for (const child of node.children)\n if (child.type === \"text\") {\n const [from, to] = range(child);\n for (let i = from; i < to; i++) {\n if (source[i] === \"\\\\\" && i + 1 < to && asciiPunctuation.test(source[i + 1]!)) i++;\n else readable[i] = 1;\n }\n } else if (transparent.has(child.type)) collect(child);\n };\n walk(document.tree, (node) => {\n if (node.type !== \"paragraph\" && node.type !== \"heading\" && node.type !== \"tableCell\") return;\n const [start, end] = range(node);\n // Searched in the block's own text, so that blocks without brackets cost no more than that.\n const text = source.slice(start, end);\n if (!text.includes(\"[\")) return;\n collect(node);\n // Forgejo and Gitea render `\\(...\\)` and `\\[...\\]` as math, which GFM reads as text.\n if (forge)\n for (const [open, close] of [\n [\"\\\\(\", \"\\\\)\"],\n [\"\\\\[\", \"\\\\]\"],\n ] as const)\n for (let from = 0; ;) {\n const opening = text.indexOf(open, from);\n const closing = opening < 0 ? -1 : text.indexOf(close, opening + 2);\n if (closing < 0) break;\n readable.fill(0, start + opening, start + closing + 2);\n from = closing + 2;\n }\n const openers: number[] = [];\n // The opening bracket of the last full reference's label, which is not read again.\n let label = -1;\n for (let i = start; i < end; i++) {\n if (!readable[i]) continue;\n if (source[i] === \"[\") {\n openers.push(i);\n continue;\n }\n if (source[i] !== \"]\") continue;\n const opener = openers.pop();\n if (opener === undefined || opener === label) continue;\n let reference: Reference | undefined;\n if (source[i + 1] === \"[\" && readable[i + 1]) {\n if (source[i + 2] === \"]\" && readable[i + 2]) {\n // Collapsed: the text is the label.\n if (labelEnd(source, opener, i + 1) === i + 1)\n reference = {\n start: opener,\n end: i + 3,\n label: source.slice(opener + 1, i),\n footnote: false,\n };\n } else {\n const after = labelEnd(source, i + 1, end);\n if (after !== undefined && readable[after - 1]) {\n reference = {\n start: opener,\n end: after,\n label: source.slice(i + 2, after - 1),\n footnote: false,\n };\n label = i + 1;\n }\n }\n if (reference) {\n if (\n !definitions.has(normalizeLabel(labelText(reference.label))) &&\n !(opener > 0 && readable[opener - 1] && notAfter.test(source[opener - 1]!))\n )\n references.push(reference);\n continue;\n }\n }\n // A footnote label has at most 999 characters after its `^`.\n if (!footnotes || source[opener + 1] !== \"^\" || i - opener > 1001) continue;\n const footnote = footnoteLabel.exec(source.slice(opener + 1, i));\n if (footnote && !footnotes.has(normalizeLabel(footnote[1]!)))\n references.push({ start: opener, end: i + 1, label: footnote[1]!, footnote: true });\n }\n });\n return references;\n}\n\n/** Names the first few of the paths that could not be read, and counts the rest. */\nfunction named(paths: string[]): string {\n return paths.length > 3\n ? `${paths.slice(0, 3).join(\", \")}, and ${paths.length - 3} more`\n : paths.join(\", \");\n}\n\n/** The nodes inside table cells, where a `|` that is not escaped ends the cell. */\nfunction inTableCells(tree: Nodes): Set<Nodes> {\n const nodes = new Set<Nodes>();\n walk(tree, \"tableCell\", (cell) => walk(cell, (child) => nodes.add(child)));\n return nodes;\n}\n\nexport const linkRules: Record<string, Rule> = {\n \"links/valid\": {\n description: \"Check local link destinations and dialect-specific heading/block references.\",\n kind: \"problem\",\n schema: optionsSchema({}),\n check({ document, workspace }) {\n const findings: Finding[] = [];\n // The parser only produces reference nodes for labels that have a\n // definition; undefined references stay plain text.\n walk(document.tree, (node) => {\n const url = destination(node);\n if (url === undefined || !workspace) return;\n const result = workspace.resolve(\n document.path,\n url,\n document.dialect,\n node.type === \"wikiLink\",\n );\n if (result.status === \"missing\" && result.outside !== undefined && result.vault)\n // The file is there, so \"missing\" would mislead: Obsidian cannot reach it.\n findings.push({\n start: range(node)[0],\n message: `Local target is outside the vault: ${url} (${result.outside} is not in ${result.vault}, where Obsidian looks).`,\n });\n else if (result.status === \"missing\" || result.status === \"ambiguous\")\n findings.push({\n start: range(node)[0],\n message: `${result.status === \"missing\" ? \"Missing\" : \"Ambiguous\"} local target: ${url}.`,\n });\n else if (result.status === \"directory\" && document.dialect === \"obsidian\")\n findings.push({ start: range(node)[0], message: `Local target is a directory: ${url}.` });\n else if (result.status === \"unreadable\") {\n // Neither found nor known to be missing: say what stood in the way.\n const limits = result.unreadable ?? [];\n // The rest of a vault that the workspace root is only a folder of.\n const outsideRoot = (name: string) => name === \"..\" || name.startsWith(\"../\");\n const directories = limits.filter((name) => !outsideRoot(name));\n const reasons = [\n ...(directories.length ? [`cannot read ${named(directories)}`] : []),\n ...(limits.some(outsideRoot) ? [\"the workspace root is only a part of the vault\"] : []),\n ];\n findings.push({\n start: range(node)[0],\n message:\n result.leavesRoot !== undefined\n ? `Local target could not be checked: ${url} (${result.leavesRoot} leads outside the workspace root, which the tool does not read).`\n : result.target === undefined\n ? `Local target could not be checked: ${url} (no readable match; ${reasons.join(\"; \")}).`\n : `Fragment could not be checked: ${url} (cannot read ${result.target}).`,\n });\n } else if (result.status === \"resolved\" && !result.fragmentExists)\n findings.push({ start: range(node)[0], message: `Missing fragment in ${url}.` });\n });\n return findings;\n },\n },\n \"links/path\": {\n description: \"Rewrite verified local destinations using the configured path and bracket style.\",\n kind: \"style\",\n phase: \"inline\",\n schema: optionsSchema({\n style: { enum: [\"relative\", \"root\", \"shortest\", \"preserve\"] },\n brackets: { enum: [\"angle\", \"bare\", \"preserve\"] },\n extension: { enum: [\"include\", \"omit\", \"preserve\"] },\n leadingDot: { type: \"boolean\" },\n }),\n check({ document, options, workspace }) {\n const findings: Finding[] = [];\n let inCell: Set<Nodes> | undefined;\n walk(document.tree, (node) => {\n const url = destination(node);\n if (url === undefined || !workspace) return;\n const result = workspace.resolve(\n document.path,\n url,\n document.dialect,\n node.type === \"wikiLink\",\n );\n if (result.status !== \"resolved\" || !result.target || !result.fragmentExists) return;\n // Found by name among the readable files only: a directory that could not\n // be read may hold another match, and a rewrite would choose between them.\n if (result.unreadable) return;\n const parts = splitDestination(url);\n let target = parts.path;\n const style = options.style ?? \"preserve\";\n // Vault roots and extensionless Markdown are renderer-specific; don't change other dialects.\n if (\n document.dialect !== \"obsidian\" &&\n (style === \"root\" || style === \"shortest\" || options.extension === \"omit\")\n )\n return;\n if (parts.path) {\n // Obsidian counts a path from the note's vault, which need not be the root.\n const rooted = result.rooted ?? result.target;\n if (style === \"root\") target = rooted;\n else if (style === \"relative\")\n target = path.posix.relative(path.posix.dirname(document.path), result.target);\n else if (style === \"shortest\") {\n const basename = path.posix.basename(result.target);\n const resolved = workspace.resolve(document.path, basename, document.dialect, true);\n target =\n resolved.status === \"resolved\" &&\n resolved.target === result.target &&\n !resolved.unreadable\n ? basename\n : rooted;\n }\n if (document.dialect === \"obsidian\" && result.target.endsWith(\".md\")) {\n if (\n options.extension === \"omit\" ||\n ((options.extension ?? \"preserve\") === \"preserve\" && !parts.path.endsWith(\".md\"))\n )\n target = target.replace(/\\.md$/, \"\");\n else if (options.extension === \"include\" && !target.endsWith(\".md\")) target += \".md\";\n }\n if (style === \"relative\" && options.leadingDot === true && !target.startsWith(\".\"))\n target = `./${target}`;\n }\n // Encode reserved path characters before reattaching a separately parsed fragment.\n const hash = url.indexOf(\"#\");\n const encodedPath =\n target === parts.path\n ? hash < 0\n ? url\n : url.slice(0, hash)\n : target.replaceAll(\"%\", \"%25\").replaceAll(\"#\", \"%23\");\n let replacement =\n encodedPath +\n (hash < 0\n ? \"\"\n : target === parts.path\n ? url.slice(hash)\n : `#${parts.fragment.replaceAll(\"%\", \"%25\")}`);\n // A relative basename can collide with a vault-root path. Make the\n // relative spelling explicit before proposing an identity-changing edit.\n let verified = workspace.resolve(\n document.path,\n replacement,\n document.dialect,\n node.type === \"wikiLink\",\n );\n if (\n style === \"relative\" &&\n parts.path &&\n !replacement.startsWith(\".\") &&\n (verified.status !== \"resolved\" ||\n verified.target !== result.target ||\n verified.unreadable)\n ) {\n replacement = `./${replacement}`;\n verified = workspace.resolve(\n document.path,\n replacement,\n document.dialect,\n node.type === \"wikiLink\",\n );\n }\n if (\n verified.status !== \"resolved\" ||\n verified.target !== result.target ||\n verified.fragment !== result.fragment ||\n verified.unreadable\n )\n return;\n const [start, end] = range(node);\n if (node.type === \"wikiLink\") {\n if (/[[\\]|\\r\\n]/.test(replacement)) return;\n if (!node.embed && node.label === undefined && replacement !== node.target) return;\n // Only the destination changes. The divider stays as written, `|` or\n // `\\|`, which a table cell needs, and so do the label and an embed's size.\n const raw = document.source.slice(start, end);\n const open = node.embed ? 3 : 2;\n const divider = raw.indexOf(\"|\", open);\n const targetEnd =\n divider < 0 ? raw.length - 2 : raw[divider - 1] === \"\\\\\" ? divider - 1 : divider;\n if (raw.slice(open, targetEnd) !== node.target) return;\n replacement = raw.slice(0, open) + replacement + raw.slice(targetEnd);\n if (replacement !== raw)\n findings.push({\n start,\n end,\n message: \"Normalize wikilink destination.\",\n edit: { start, end, text: replacement },\n });\n return;\n }\n if (node.type === \"definition\") return; // Definitions are validated; retain their exact layout in this release.\n const raw = document.source.slice(start, end);\n const span = destinationRange(raw);\n if (!span) return; // Autolinks have no parenthesized destination.\n const original = raw.slice(...span);\n const angle =\n options.brackets === \"angle\" ||\n ((options.brackets ?? \"preserve\") === \"preserve\" && original.startsWith(\"<\"));\n if (angle)\n replacement = `<${replacement.replaceAll(\"<\", \"%3C\").replaceAll(\">\", \"%3E\").replaceAll(\"\\\\\", \"%5C\")}>`;\n else\n replacement = replacement\n .replaceAll(\" \", \"%20\")\n .replaceAll(\"(\", \"%28\")\n .replaceAll(\")\", \"%29\")\n .replaceAll(\"<\", \"%3C\")\n .replaceAll(\">\", \"%3E\");\n // A file or folder name can hold a `|`, which would end a table cell.\n if (replacement.includes(\"|\") && (inCell ??= inTableCells(document.tree)).has(node))\n replacement = replacement.replaceAll(\"|\", \"\\\\|\");\n if (\n document.dialect === \"gitea\" &&\n (giteaPyLine(document, start, end) || replacement.includes(\"_.py\")) &&\n giteaUnderscores(original) !== giteaUnderscores(replacement)\n )\n return;\n // On Forgejo, and Gitea before 1.26, the destination is part of the\n // heading's anchor, and text they read as attributes is no link there.\n if (changesForgeHeading(document, start, end)) return;\n if (original !== replacement)\n findings.push({\n start: start + span[0],\n end: start + span[1],\n message: \"Normalize link destination.\",\n edit: { start: start + span[0], end: start + span[1], text: replacement },\n });\n });\n return findings;\n },\n },\n \"links/notation\": {\n description: \"Convert plain-label Obsidian links between Markdown and wikilink notation.\",\n kind: \"style\",\n phase: \"inline\",\n schema: optionsSchema({ style: { enum: [\"markdown\", \"wiki\"] } }),\n check({ document, options, workspace }) {\n if (document.dialect !== \"obsidian\" || !workspace) return [];\n const findings: Finding[] = [];\n let inCell: Set<Nodes> | undefined;\n walk(document.tree, (node) => {\n const [start, end] = range(node);\n const pipe = () => ((inCell ??= inTableCells(document.tree)).has(node) ? \"\\\\|\" : \"|\");\n let replacement: string | undefined;\n if (\n options.style === \"markdown\" &&\n node.type === \"wikiLink\" &&\n !node.embed &&\n node.label !== undefined\n ) {\n if (/[[\\]<>\\\\\\r\\n]/.test(node.target ?? \"\") || /[*_`[\\]\\\\]/.test(node.label)) return;\n const label = node.label.includes(\"|\") ? node.label.replaceAll(\"|\", pipe()) : node.label;\n replacement = `[${label}](<${node.target}>)`;\n } else if (\n options.style === \"wiki\" &&\n node.type === \"link\" &&\n !node.title &&\n node.children.length === 1 &&\n node.children[0]?.type === \"text\"\n ) {\n const label = node.children[0].value;\n const target = wikiTarget(node.url);\n if (target === undefined || /[[\\]|\\r\\n]/.test(label)) return;\n replacement = `[[${target}${pipe()}${label}]]`;\n }\n const url = destination(node);\n if (!replacement || url === undefined) return;\n const result = workspace.resolve(\n document.path,\n url,\n document.dialect,\n node.type === \"wikiLink\",\n );\n // A target that is uncertain, because a directory could not be read, is left as written.\n if (result.status !== \"resolved\" || result.unreadable) return;\n findings.push({\n start,\n end,\n message: `Use ${String(options.style)} link notation.`,\n edit: { start, end, text: replacement },\n });\n });\n return findings;\n },\n },\n \"links/undefined-reference\": {\n description:\n \"Report full, collapsed, and footnote references whose label has no definition, which show as plain text.\",\n kind: \"problem\",\n schema: optionsSchema({}),\n check({ document }) {\n const definitions = new Set<string>();\n const footnotes = new Set<string>();\n walk(document.tree, (node) => {\n if (node.type === \"definition\") definitions.add(node.identifier);\n if (node.type === \"footnoteDefinition\") footnotes.add(node.identifier);\n });\n // CommonMark has no footnotes: there `[^label]` is an ordinary shortcut reference.\n return undefinedReferences(\n document,\n definitions,\n document.dialect === \"commonmark\" ? undefined : footnotes,\n ).map(({ start, end, label, footnote }) => {\n const name = (footnote ? `^${label}` : labelText(label)).replace(/\\s+/g, \" \").trim();\n return {\n start,\n end,\n message: `${footnote ? \"Footnote\" : \"Reference\"} [${name}] has no definition and shows as plain text.`,\n };\n });\n },\n },\n \"links/unused-definition\": {\n description: \"Report link and footnote definitions that no reference uses.\",\n kind: \"problem\",\n schema: optionsSchema({}),\n check({ document }) {\n // Link and footnote labels are kept apart, as `link:` and `footnote:` keys.\n const used = new Set<string>();\n const definitions: (Definition | FootnoteDefinition)[] = [];\n walk(document.tree, (node) => {\n // A shortcut reference `[label]` that has a definition is a reference node too.\n if (node.type === \"linkReference\" || node.type === \"imageReference\")\n used.add(`link:${node.identifier}`);\n else if (node.type === \"footnoteReference\") used.add(`footnote:${node.identifier}`);\n else if (node.type === \"definition\" || node.type === \"footnoteDefinition\")\n definitions.push(node);\n });\n const findings: Finding[] = [];\n const seen = new Set<string>();\n for (const node of definitions) {\n const footnote = node.type === \"footnoteDefinition\";\n const key = `${footnote ? \"footnote\" : \"link\"}:${node.identifier}`;\n const label = (node.label ?? node.identifier).replace(/\\s+/g, \" \").trim();\n const name = `[${footnote ? \"^\" : \"\"}${label}]`;\n const [start] = range(node);\n // CommonMark uses the first definition of a label; a later one is never used.\n if (seen.has(key))\n findings.push({\n start,\n message: `${footnote ? \"Footnote\" : \"Definition\"} ${name} repeats an earlier one, which references use instead.`,\n });\n else if (!used.has(key))\n findings.push({\n start,\n message: footnote\n ? `Footnote ${name} is not referenced${document.dialect === \"github\" ? \", and GitHub does not show it\" : \"\"}.`\n : `Definition ${name} is not used by any reference.`,\n });\n seen.add(key);\n }\n return findings;\n },\n },\n \"links/empty\": {\n description: \"Report links and images whose destination is empty or only #.\",\n kind: \"problem\",\n schema: optionsSchema({}),\n check({ document }) {\n const findings: Finding[] = [];\n // A reference has its definition's destination, which is reported once, at the definition.\n walk(document.tree, (node) => {\n if (node.type !== \"link\" && node.type !== \"image\" && node.type !== \"definition\") return;\n if (node.url !== \"\" && node.url !== \"#\") return;\n const what =\n node.type === \"image\"\n ? \"Image source\"\n : node.type === \"definition\"\n ? `Destination of definition [${(node.label ?? node.identifier).replace(/\\s+/g, \" \").trim()}]`\n : \"Link destination\";\n findings.push({\n start: range(node)[0],\n message:\n node.url === \"\"\n ? `${what} is empty.`\n : `${what} is only #${node.type === \"link\" ? \", which only leads to the top of the page\" : \"\"}.`,\n });\n });\n return findings;\n },\n },\n};\n"]}
@@ -1,3 +1,5 @@
1
+ import { misreadLists } from "../syntax/misread-lists.js";
2
+ import { joinsTomlFrontMatter } from "../syntax/parse.js";
1
3
  import { optionsSchema } from "./style.js";
2
4
  const tabStop = (column) => column + 4 - (column % 4);
3
5
  const isSpace = (character) => character === " " || character === "\t";
@@ -33,6 +35,12 @@ function analyze(document) {
33
35
  const sensitive = new Set();
34
36
  /** The innermost container of each line, by line index. */
35
37
  const innermost = [];
38
+ // Renderers may read a list where the parser read text that starts with a
39
+ // list marker, the blocks indented below it inside that list's last item,
40
+ // and the block after those as more of its items (issue #191). Another
41
+ // marker or indentation could move a list among them into or out of that
42
+ // item, or join it to that list, so its group of lists stays as written.
43
+ const misread = misreadLists(document);
36
44
  const visit = (node, parent, unit) => {
37
45
  const children = node.children;
38
46
  let group;
@@ -63,6 +71,8 @@ function analyze(document) {
63
71
  }
64
72
  target = group;
65
73
  }
74
+ if (misread.nested.has(child) || misread.next.has(child))
75
+ target.valid = false;
66
76
  const previous = children[index - 1];
67
77
  if (!run || previous?.type !== "list" || previous.ordered !== child.ordered) {
68
78
  run = [];
@@ -166,6 +176,13 @@ function analyze(document) {
166
176
  return item;
167
177
  };
168
178
  visit(document.tree, undefined, undefined);
179
+ // Renderers without TOML front matter read its lines as a paragraph, which
180
+ // a list directly below continues where it cannot interrupt one: a numbered
181
+ // list that does not start at 1, or one whose first item starts with a blank
182
+ // line (issue #333).
183
+ const below = units[0]?.lists[0];
184
+ if (below && joinsTomlFrontMatter(document.tree, below.node))
185
+ units[0].valid = false;
169
186
  for (const item of items.values())
170
187
  item.last = containers.get(item.node)?.last ?? item.first;
171
188
  for (const unit of units)