mdrefine 0.2.2 → 0.2.4
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.
- package/CHANGELOG.md +34 -0
- package/CONTRIBUTING.md +5 -0
- package/README.md +1 -1
- package/dist/core/engine.js +5 -3
- package/dist/core/engine.js.map +1 -1
- package/dist/rules/blocks.d.ts +9 -0
- package/dist/rules/blocks.js +22 -0
- package/dist/rules/blocks.js.map +1 -1
- package/dist/rules/links.js +25 -4
- package/dist/rules/links.js.map +1 -1
- package/dist/rules/style.js +4 -3
- package/dist/rules/style.js.map +1 -1
- package/dist/syntax/misread-lists.d.ts +30 -7
- package/dist/syntax/misread-lists.js +45 -4
- package/dist/syntax/misread-lists.js.map +1 -1
- package/docs/design.md +15 -9
- package/docs/dialects.md +5 -2
- package/docs/quick-start.md +1 -1
- package/docs/rules.md +17 -8
- package/package.json +1 -1
package/dist/rules/blocks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blocks.js","sourceRoot":"","sources":["../../src/rules/blocks.ts"],"names":[],"mappings":"AACA,OAAO,WAAW,MAAM,cAAc,CAAC;AAEvC,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,KAAK,EACL,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,+EAA+E;AAC/E,SAAS,MAAM,CAAC,UAAmC;IACjD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAAC;AACrE,CAAC;AACD,oEAAoE;AACpE,MAAM,SAAS,GAAG,YAAY,CAAC;AAC/B,SAAS,SAAS,CAAC,MAAc,EAAE,EAAU;IAC3C,OAAO,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,EAAE,GAAG,CAAC,CAAC,KAAK,IAAI,IAAI,MA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I,CAAC;oBACZ,KAAK;oBACL,GAAG;oBACH,OAAO,EAAE,oDAAoD;oBAC7D,IAAI,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE;iBAC/B,CAAC,CAAC;gBACH,SAAS;YACX,CAAC;YACD,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAE,CAAC;YAC/B,IAAI,CAAC,SAAS,IAAI,GAAG,CAAC,KAAK,KAAK,KAAK,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC;gBACnF,SAAS;YACX,QAAQ,CAAC,IAAI,CAAC;gBACZ,KAAK;gBACL,GAAG;gBACH,OAAO,EAAE,2CAA2C;gBACpD,IAAI,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE;aACjC,CAAC,CAAC;QACL,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAyB;IAC9C,mBAAmB,EAAE,UAAU;IAC/B,kBAAkB,EAAE,aAAa;IACjC,sBAAsB,EAAE,aAAa;IACrC,sBAAsB,EAAE,aAAa;CACtC,CAAC","sourcesContent":["import type { Code, Heading, Nodes } from \"mdast\";\nimport stringWidth from \"string-width\";\nimport type { Document, Edit, Finding, Rule } from \"../core/types.js\";\nimport {\n belowTomlFrontMatter,\n frontMatterReading,\n joinsTomlFrontMatter,\n range,\n startsWithMarker,\n unclosedFrontMatter,\n} from \"../syntax/parse.js\";\nimport { walk } from \"../syntax/walk.js\";\n\n/** A JSON Schema for an options object with these properties and no others. */\nfunction schema(properties: Record<string, unknown>) {\n return { type: \"object\", properties, additionalProperties: false };\n}\n/** Any CommonMark line ending, including a lone carriage return. */\nconst lineBreak = /\\r\\n|\\r|\\n/;\nfunction lineStart(source: string, at: number): number {\n while (at > 0 && source[at - 1] !== \"\\n\" && source[at - 1] !== \"\\r\") at--;\n return at;\n}\nfunction lineEnd(source: string, at: number): number {\n while (at < source.length && source[at] !== \"\\n\" && source[at] !== \"\\r\") at++;\n return at;\n}\n/** A physical line: where it starts, where its content ends, and where the next line starts. */\ninterface Line {\n start: number;\n end: number;\n next: number;\n}\nfunction physicalLines(source: string): Line[] {\n const lines: Line[] = [];\n let start = 0;\n for (const match of source.matchAll(/\\r\\n|\\r|\\n/g)) {\n lines.push({ start, end: match.index, next: match.index + match[0].length });\n start = match.index + match[0].length;\n }\n if (start < source.length) lines.push({ start, end: source.length, next: source.length });\n return lines;\n}\n/** Whether the parser gave a node, perhaps one of a plugin's syntax, a source position. */\nfunction located(node: Nodes): boolean {\n return node.position?.start.offset !== undefined && node.position.end.offset !== undefined;\n}\n/** Blocks whose lines hold other blocks, and blank lines between them. */\nconst containers = new Set([\"root\", \"blockquote\", \"list\", \"listItem\", \"footnoteDefinition\"]);\n/** Sort ranges and merge those that overlap or touch. */\nfunction merged(ranges: [number, number][]): [number, number][] {\n const result: [number, number][] = [];\n for (const [start, end] of ranges.filter(([a, b]) => a < b).sort((x, y) => x[0] - y[0])) {\n const last = result.at(-1);\n if (last && start <= last[1]) last[1] = Math.max(last[1], end);\n else result.push([start, end]);\n }\n return result;\n}\n\n/**\n * HTML blocks that end only at an end marker, by what starts them, with the\n * markers that end them, in lowercase, and the offset from which they are\n * searched: CommonMark's kinds 1 to 5. The other kinds end at a blank line.\n * These are CommonMark's markers, not HTML's: a comment's block ends only at\n * `-->`, not at `--!>`.\n */\nconst htmlEnds: [RegExp, string[], number][] = [\n [\n /^<(?:pre|script|style|textarea)(?:[\\t\\n\\r >]|$)/i,\n [\"</pre>\", \"</script>\", \"</style>\", \"</textarea>\"],\n 1,\n ],\n [/^<!--/, [\"-->\"], 2],\n [/^<\\?/, [\"?>\"], 1],\n [/^<!\\[CDATA\\[/, [\"]]>\"], 9],\n [/^<![A-Za-z]/, [\">\"], 2],\n];\n/**\n * Whether a block is an HTML block of a kind that ends only at its end marker,\n * or an Obsidian comment, and lacks that marker. Such a block runs to the end\n * of its container and takes in every line ending and blank line up to there.\n */\nfunction unclosed(node: Nodes): boolean {\n if (node.type === \"obsidianComment\") return node.value.indexOf(\"%%\", 2) < 0;\n if (node.type !== \"html\") return false;\n // The value keeps the block's indentation.\n const value = node.value.replace(/^[ \\t]+/, \"\");\n for (const [opening, ends, from] of htmlEnds) {\n if (!opening.test(value)) continue;\n const rest = value.slice(from).toLowerCase();\n return !ends.some((end) => rest.includes(end));\n }\n return false;\n}\n/**\n * Whether a line added directly below `node`, at its own level, would become\n * part of an HTML block or Obsidian comment that `node` ends with and that has\n * no end marker. The parser lets such an HTML block run on through the blank\n * lines of a list item or footnote, and through a final line ending, but a\n * block quote ends it. An Obsidian comment runs on to the end of the document,\n * whatever contains it.\n */\nexport function takesLines(node: Nodes): boolean {\n let quoted = false;\n while (containers.has(node.type) && \"children\" in node && node.children.length) {\n if (node.type === \"blockquote\") quoted = true;\n node = node.children.at(-1)!;\n }\n return unclosed(node) && (node.type === \"obsidianComment\" || !quoted);\n}\n/**\n * Whether a line ending added at the end of the document would change its\n * last block. Besides the blocks of `takesLines`, the parser counts a last\n * line of blank space in a code or math block that has no closing fence only\n * when a line ending follows it.\n */\nexport function takesFinalLineEnding(document: Document): boolean {\n if (takesLines(document.tree)) return true;\n if (!/(?:^|[\\r\\n])[ \\t]+$/.test(document.source)) return false;\n const last = lastBlock(document.tree);\n if ((last.type !== \"code\" && last.type !== \"math\") || !located(last)) return false;\n const fence = codeFence(document.source, last);\n return fence !== undefined && !fence.close;\n}\n\n/**\n * Whether `style/heading` writes headings of levels 1 and 2 underlined: with\n * `setext`, or with `consistent` when the document's first heading is.\n */\nexport function underlinedHeadings(document: Document, style: unknown): boolean {\n if (style !== \"consistent\") return style === \"setext\";\n let first: Heading | undefined;\n walk(document.tree, \"heading\", (node) => {\n if (!first && located(node)) first = node;\n });\n return first !== undefined && /[\\r\\n]/.test(document.source.slice(...range(first)));\n}\n/**\n * The start of a line that would not begin a paragraph after a blank line: a\n * list item, heading, block quote, thematic break, fence, HTML, math, or\n * Obsidian comment, a link reference definition, or a table row, which `---`\n * below it could make a table.\n */\nconst notParagraph =\n /^(?:[-+*](?:[ \\t]|$)|\\d{1,9}[.)](?:[ \\t]|$)|#{1,6}(?:[ \\t]|$)|>|([-*_])[ \\t]*(?:\\1[ \\t]*){2,}$|`{3,}|~{3,}|<|\\$\\$|%%|\\[[^]*\\]:)|\\|/;\n/**\n * The edit that writes the `#` heading `node`, of level 1 or 2, underlined\n * with `===` or `---`, or undefined where its text could not stand on a line\n * of its own as the same heading. Only headings at the start of a line of the\n * document itself, below a blank line or at the start, are underlined:\n * directly below text, the heading's line would continue a paragraph. On\n * Forgejo and Gitea, a heading with a `{` keeps its form, because their\n * attribute blocks depend on it.\n */\nexport function underlineEdit(document: Document, node: Heading): Edit | undefined {\n const { source } = document;\n const first = node.children[0];\n const last = node.children.at(-1);\n if (node.depth > 2 || !first || !last || !located(first) || !located(last)) return undefined;\n const [start] = range(node);\n if (lineStart(source, start) !== start) return undefined;\n if (start > 0) {\n const above = lineStart(source, start - (source.startsWith(\"\\r\\n\", start - 2) ? 2 : 1));\n if (!/^[ \\t]*$/.test(source.slice(above, lineEnd(source, above)))) return undefined;\n }\n const text = source.slice(range(first)[0], range(last)[1]);\n if (notParagraph.test(text) || text.endsWith(\"\\\\\")) return undefined;\n if ((document.dialect === \"forgejo\" || document.dialect === \"gitea\") && text.includes(\"{\"))\n return undefined;\n // Forgejo and Gitea open a definition or display math with these.\n if (/^(?::[ \\t]|\\\\\\[)/.test(text)) return undefined;\n const newline = /\\r\\n|\\r|\\n/.exec(source)?.[0] ?? \"\\n\";\n // Below a first line of `---` that opens no front matter, an underline of\n // `---` alone would close it (issue #278).\n const shortest = node.depth === 2 && unclosedFrontMatter(source) === \"---\" ? 4 : 3;\n const underline = (node.depth === 1 ? \"=\" : \"-\").repeat(Math.max(shortest, stringWidth(text)));\n return { start, end: lineEnd(source, start), text: `${text}${newline}${underline}` };\n}\n\n/** The fences of a fenced code or math block: the marker runs, as source ranges. */\ninterface Fence {\n marker: \"`\" | \"~\" | \"$\";\n open: [number, number];\n /** Absent when the block runs to the end of its container without a closing fence. */\n close?: [number, number];\n}\n/** The fences of a code or math block, or undefined for an indented code block. */\nfunction codeFence(\n source: string,\n node: Code | Extract<Nodes, { type: \"math\" }>,\n): Fence | undefined {\n const [start, end] = range(node);\n // A fenced block starts at its fence; an indented one at its indentation.\n const opening = /^(?:`{3,}|~{3,}|\\${2,})/.exec(source.slice(start, lineEnd(source, start)));\n if (!opening) return undefined;\n const marker = opening[0][0] as Fence[\"marker\"];\n const fence: Fence = { marker, open: [start, start + opening[0].length] };\n // The block's lines are the opening fence, the content, and the closing\n // fence if there is one. An empty value is no line or one blank line, and a\n // closing fence is never blank.\n const lines = source.slice(start, end).split(lineBreak);\n const last = lines.at(-1)!;\n const closing = new RegExp(\n `(?:${marker === \"$\" ? \"\\\\$\" : marker}){${opening[0].length},}(?=[ \\\\t]*$)`,\n ).exec(last);\n const content = node.value === \"\" ? undefined : node.value.split(lineBreak).length;\n if (closing && lines.length > 1 && (content === undefined || lines.length === content + 2)) {\n const at = end - last.length + closing.index;\n fence.close = [at, at + closing[0].length];\n }\n return fence;\n}\n\nconst codeFenceRule: Rule = {\n description: \"Write code fences with one marker and the length their content needs.\",\n kind: \"style\",\n phase: \"block\",\n schema: schema({ marker: { enum: [\"```\", \"~~~\", \"consistent\"] } }),\n check({ document, options }) {\n const { source } = document;\n const fences: { node: Code; fence: Fence }[] = [];\n walk(document.tree, \"code\", (node) => {\n const fence = located(node) ? codeFence(source, node) : undefined;\n if (fence) fences.push({ node, fence });\n });\n // `consistent` takes the marker of the first fence in the document.\n const marker =\n options.marker === \"~~~\"\n ? \"~\"\n : options.marker === \"consistent\"\n ? (fences[0]?.fence.marker ?? \"`\")\n : \"`\";\n const findings: Finding[] = [];\n for (const { node, fence } of fences) {\n // The info string of a backtick fence cannot contain a backtick.\n if (\n marker === \"`\" &&\n source.slice(fence.open[1], lineEnd(source, fence.open[1])).includes(\"`\")\n )\n continue;\n // A content line of the marker alone, at any indentation, could close a\n // fence that is not longer than it.\n let longest = 0;\n for (const line of node.value.split(lineBreak)) {\n const run = /^[ \\t]*(`+|~+)[ \\t]*$/.exec(line)?.[1];\n if (run?.[0] === marker) longest = Math.max(longest, run.length);\n }\n const text = marker.repeat(Math.max(3, longest + 1));\n for (const [start, end] of fence.close ? [fence.open, fence.close] : [fence.open])\n if (source.slice(start, end) !== text)\n findings.push({\n start,\n end,\n message: `Use ${text} for the code fence.`,\n edit: { start, end, text },\n });\n }\n return findings;\n },\n};\n\n/** The innermost last block of a container, where its text ends. */\nfunction lastBlock(node: Nodes): Nodes {\n while (containers.has(node.type) && \"children\" in node && node.children.length)\n node = node.children.at(-1)!;\n return node;\n}\nconst thematicBreak: Rule = {\n description: \"Write thematic breaks with one marker.\",\n kind: \"style\",\n phase: \"block\",\n schema: schema({ marker: { enum: [\"---\", \"***\", \"___\", \"consistent\"] } }),\n check({ document, options }) {\n const { source } = document;\n let marker = typeof options.marker === \"string\" ? options.marker : \"---\";\n // `consistent` takes the character of the first thematic break in the document.\n if (marker === \"consistent\") {\n let first: string | undefined;\n walk(document.tree, \"thematicBreak\", (node) => {\n if (first === undefined && located(node)) first = source[range(node)[0]];\n });\n marker = (first ?? \"-\").repeat(3);\n }\n const findings: Finding[] = [];\n walk(document.tree, \"thematicBreak\", (node, index, parent) => {\n if (!located(node)) return;\n const [start, last] = range(node);\n // The break's range includes blank space after its markers.\n const end = start + source.slice(start, last).replace(/[ \\t]+$/, \"\").length;\n if (source.slice(start, end) === marker) return;\n // At the start of the document, a break written `---` would open front\n // matter if a later line closed it, as a line of `---` alone does, also\n // one that this rule writes. A first-line `---` that the parser reads as a\n // break and site generators as front matter stays (issue #295).\n if (\n start === 0 &&\n (marker === \"---\" || (source.startsWith(\"---\") && frontMatterReading(document.tree)))\n )\n return;\n // Below a first line of `---` that opens no front matter, a line of `---`\n // alone would close it (issue #278).\n if (\n marker === \"---\" &&\n lineStart(source, start) === start &&\n unclosedFrontMatter(source) === \"---\"\n )\n return;\n // Renderers without TOML front matter read its lines as a paragraph,\n // which a line of `---` directly below underlines as a heading, as one\n // written there already does (issue #333).\n if (\n (marker === \"---\" && belowTomlFrontMatter(document.tree, node)) ||\n joinsTomlFrontMatter(document.tree, node)\n )\n return;\n // On the line of list items whose markers are the new marker's character,\n // the items and the break would become one thematic break, as `- ---`,\n // `1. - ---`, and `* ***` are.\n const items = new RegExp(`[ \\\\t${marker[0] === \"-\" ? \"\\\\-\" : marker[0]}]*$`);\n const prefix = source.slice(lineStart(source, start), start);\n if (items.exec(prefix)![0].includes(marker[0]!)) return;\n if (marker === \"---\") {\n // Directly below a paragraph or a link reference definition, `---`\n // would underline it as a heading, and so it would display math,\n // which GitHub builds from a paragraph (issue #336).\n const above = index && parent ? lastBlock(parent.children[index - 1]!) : undefined;\n if (\n above &&\n (above.type === \"paragraph\" || above.type === \"definition\" || above.type === \"math\") &&\n above.position?.end.line === node.position!.start.line - 1\n )\n return;\n }\n findings.push({\n start,\n end,\n message: `Write the thematic break as ${marker}.`,\n edit: { start, end, text: marker },\n });\n });\n return findings;\n },\n};\n\n/** Where blank lines are content, or their number counts, as source ranges. */\nfunction contentBlocks(document: Document): [number, number][] {\n const blocks: [number, number][] = [];\n walk(document.tree, (node, _, parent) => {\n if (!located(node)) return;\n if (parent && containers.has(parent.type) && !containers.has(node.type))\n blocks.push(range(node));\n // In a block quote, a list, list item, or footnote can extend over the\n // blank lines below its last block. The parser then reads a list as loose,\n // or a list item as tight, by how many there are.\n const last =\n node.type === \"list\" || node.type === \"listItem\" || node.type === \"footnoteDefinition\"\n ? node.children.at(-1)\n : undefined;\n if (last && located(last) && range(last)[1] < range(node)[1])\n blocks.push([range(last)[1], range(node)[1]]);\n });\n return merged(blocks);\n}\nconst blankLines: Rule = {\n description: \"Limit blank lines in a row and remove those around the document.\",\n kind: \"style\",\n phase: \"document\",\n // Fewer than one blank line would join the blocks that it separates.\n schema: schema({ maximum: { type: \"integer\", minimum: 1 } }),\n check({ document, options }) {\n const { source } = document;\n const maximum = typeof options.maximum === \"number\" ? options.maximum : 1;\n const lines = physicalLines(source);\n const text = (line: Line) => source.slice(line.start, line.end);\n const empty = (line: Line) => /^[ \\t]*$/.test(text(line));\n // A line of blank space and block quote markers is blank inside its quotes.\n const blank = (line: Line) => /^[ \\t>]*$/.test(text(line));\n const blocks = contentBlocks(document);\n let block = 0;\n /** Whether a line lies inside a block that began above it; asked in document order. */\n const inside = (line: Line) => {\n while (block < blocks.length && blocks[block]![1] < line.end) block++;\n return block < blocks.length && blocks[block]![0] < line.start;\n };\n const findings: Finding[] = [];\n const remove = (from: number, to: number, message: string) =>\n findings.push({ start: from, end: to, message, edit: { start: from, end: to, text: \"\" } });\n let first = 0;\n while (first < lines.length && empty(lines[first]!)) first++;\n if (first === lines.length) {\n if (source) remove(0, source.length, \"Remove the blank lines.\");\n return findings;\n }\n let last = lines.length;\n // A block without its end, such as an unclosed fence, takes in the blank lines at the end.\n const inBlock = lines.map((line) => blank(line) && inside(line));\n while (empty(lines[last - 1]!) && !inBlock[last - 1]) last--;\n // Below blank lines, `---` or `+++` on the first line would open front matter.\n if (first > 0 && !/^(?:-{3}|\\+{3})/.test(text(lines[first]!)))\n remove(0, lines[first]!.start, \"Remove the blank lines at the start of the document.\");\n // Blank lines in a row with the same block quote markers and indentation\n // are one separation, however many there are.\n const trimmed = (line: Line) => text(line).replace(/[ \\t]+$/, \"\");\n const message =\n maximum === 1\n ? \"Remove the repeated blank line.\"\n : `Remove the blank lines beyond ${maximum} in a row.`;\n for (let index = first; index < last;) {\n const line = lines[index]!;\n let end = index + 1;\n if (blank(line) && !inBlock[index])\n while (\n end < last &&\n blank(lines[end]!) &&\n !inBlock[end] &&\n trimmed(lines[end]!) === trimmed(line)\n )\n end++;\n if (end - index > maximum)\n remove(lines[index + maximum]!.start, lines[end - 1]!.next, message);\n index = end;\n }\n if (last < lines.length)\n remove(\n lines[last]!.start,\n source.length,\n \"Remove the blank lines at the end of the document.\",\n );\n return findings;\n },\n};\n\n/** Nodes whose source between the lines of their text is ordinary prose. */\nconst prose = new Set([\n ...containers,\n \"paragraph\",\n \"heading\",\n \"thematicBreak\",\n \"table\",\n \"tableRow\",\n \"tableCell\",\n \"text\",\n \"emphasis\",\n \"strong\",\n \"delete\",\n]);\nconst trailingSpace: Rule = {\n description: \"Remove spaces and tabs at the end of lines outside code and HTML.\",\n kind: \"style\",\n phase: \"document\",\n schema: schema({ hardBreak: { enum: [\"keep\", \"backslash\"] } }),\n check({ document, options }) {\n const { source } = document;\n if (!/[ \\t](?:\\r|\\n|$)/.test(source)) return [];\n const backslash = options.hardBreak === \"backslash\";\n const forge = document.dialect === \"forgejo\" || document.dialect === \"gitea\";\n /** Source in which blank space at the end of a line is content. */\n const kept: [number, number][] = [];\n /**\n * Hard line breaks, with the paragraph or heading each one is in, and\n * whether that block starts like an alert's or callout's marker, `[!`.\n */\n const breaks: { start: number; end: number; block: [number, number]; marker: boolean }[] = [];\n const links: [number, number][] = [];\n let block: [number, number] = [0, 0];\n let marker = false;\n walk(document.tree, (node, _, parent) => {\n if (!located(node)) {\n // A plugin's node without a position keeps whatever its parent spans.\n if (parent && located(parent)) kept.push(range(parent));\n return;\n }\n const [start, end] = range(node);\n if (node.type === \"paragraph\" || node.type === \"heading\") {\n block = [start, end];\n const written = source.slice(start, end);\n marker =\n node.type === \"paragraph\"\n ? startsWithMarker(written, node, /^\\[!/)\n : written.startsWith(\"[!\");\n }\n if (node.type === \"link\") links.push([start, end]);\n if (node.type === \"break\") breaks.push({ start, end, block, marker });\n else if (node.type === \"link\" || node.type === \"linkReference\") {\n // The link text is prose; a title or label that spans lines is not.\n let at = start;\n for (const child of node.children) {\n if (!located(child)) continue;\n kept.push([at, range(child)[0]]);\n at = range(child)[1];\n }\n kept.push([at, end]);\n } else if (node.type === \"code\") {\n const fence = codeFence(source, node);\n // A fence line ends in syntax, unless an info string's text runs to its end.\n const from = fence && !node.meta ? lineEnd(source, start) : start;\n kept.push([from, fence?.close ? lineStart(source, fence.close[0]) : end]);\n } else if (!prose.has(node.type)) kept.push([start, end]);\n });\n const ranges = merged(kept);\n let next = 0;\n let following = 0;\n let link = 0;\n /**\n * Whether a backslash in place of the blank space of a hard line break,\n * which starts at `start`, would mean the same. One after another\n * backslash would be escaped. A literal autolink such as `www.example.com`\n * runs on to the next blank space, so it would take the backslash in. A\n * paragraph that starts like `[label]:` could become a link reference\n * definition with the backslash as its destination, and the title line of\n * an alert or callout, also one written as `\\[!NOTE]`, would end with it.\n * On Forgejo and Gitea, a backslash inside `\\(...\\)` math would be part of\n * the formula.\n */\n const backslashSafe = (start: number, paragraph: [number, number], marker: boolean) => {\n if (source[start - 1] === \"\\\\\") return false;\n let word = start;\n while (word > paragraph[0] && !/[ \\t\\r\\n]/.test(source[word - 1]!)) word--;\n while (link < links.length && links[link]![1] <= word) link++;\n if (link < links.length && links[link]![0] < start) return false;\n const before = source.slice(paragraph[0], start);\n if (/^\\[[^]*\\]:/.test(before) || (marker && !/[\\r\\n]/.test(before))) return false;\n return !(forge && source.slice(...paragraph).includes(\"\\\\(\"));\n };\n const findings: Finding[] = [];\n for (const line of physicalLines(source)) {\n const space = /[ \\t]+$/.exec(source.slice(line.start, line.end));\n if (!space) continue;\n const start = line.start + space.index;\n const end = line.end;\n while (next < ranges.length && ranges[next]![1] <= start) next++;\n if (next < ranges.length && ranges[next]![0] < end) continue;\n // Breaks are in document order, as lines are.\n while (following < breaks.length && breaks[following]!.end <= start) following++;\n const hard = breaks[following]?.start !== undefined && breaks[following]!.start < end;\n if (!hard) {\n findings.push({\n start,\n end,\n message: \"Remove the spaces and tabs at the end of the line.\",\n edit: { start, end, text: \"\" },\n });\n continue;\n }\n const brk = breaks[following]!;\n if (!backslash || brk.start !== start || !backslashSafe(start, brk.block, brk.marker))\n continue;\n findings.push({\n start,\n end,\n message: \"Write the hard line break as a backslash.\",\n edit: { start, end, text: \"\\\\\" },\n });\n }\n return findings;\n },\n};\n\nexport const blockRules: Record<string, Rule> = {\n \"style/blank-lines\": blankLines,\n \"style/code-fence\": codeFenceRule,\n \"style/thematic-break\": thematicBreak,\n \"style/trailing-space\": trailingSpace,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"blocks.js","sourceRoot":"","sources":["../../src/rules/blocks.ts"],"names":[],"mappings":"AACA,OAAO,WAAW,MAAM,cAAc,CAAC;AAEvC,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,oBAAoB,EACpB,KAAK,EACL,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,+EAA+E;AAC/E,SAAS,MAAM,CAAC,UAAmC;IACjD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,UAAU,EAAE,oBAAoB,EAAE,KAAK,EAAE,CAAC;AACrE,CAAC;AACD,oEAAoE;AACpE,MAAM,SAAS,GAAG,YAAY,CAAC;AAC/B,SAAS,SAAS,CAAC,MAAc,EAAE,EAAU;IAC3C,OAAO,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,EAAE,GAAG,CAAC,CAAC,KAAK,IAAI,IAAI,MAAM,CAAC,EAAE,GAAG,CAAC,CAAC,KAAK,IAAI;QAAE,EAAE,EAAE,CAAC;IAC1E,OAAO,EAAE,CAAC;AACZ,CAAC;AACD,SAAS,OAAO,CAAC,MAAc,EAAE,EAAU;IACzC,OAAO,EAAE,GAAG,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,EAAE,CAAC,KAAK,IAAI,IAAI,MAAM,CAAC,EAAE,CAAC,KAAK,IAAI;QAAE,EAAE,EAAE,CAAC;IAC9E,OAAO,EAAE,CAAC;AACZ,CAAC;AAOD,SAAS,aAAa,CAAC,MAAc;IACnC,MAAM,KAAK,GAAW,EAAE,CAAC;IACzB,IAAI,KAAK,GAAG,CAA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AO,SAAS,GAAG,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,SAAS,CAAE,CAAC,GAAG,IAAI,KAAK;gBAAE,SAAS,EAAE,CAAC;YACjF,MAAM,IAAI,GAAG,MAAM,CAAC,SAAS,CAAC,EAAE,KAAK,KAAK,SAAS,IAAI,MAAM,CAAC,SAAS,CAAE,CAAC,KAAK,GAAG,GAAG,CAAC;YACtF,IAAI,CAAC,IAAI,EAAE,CAAC;gBACV,QAAQ,CAAC,IAAI,CAAC;oBACZ,KAAK;oBACL,GAAG;oBACH,OAAO,EAAE,oDAAoD;oBAC7D,IAAI,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,EAAE;iBAC/B,CAAC,CAAC;gBACH,SAAS;YACX,CAAC;YACD,MAAM,GAAG,GAAG,MAAM,CAAC,SAAS,CAAE,CAAC;YAC/B,IAAI,CAAC,SAAS,IAAI,GAAG,CAAC,KAAK,KAAK,KAAK,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,CAAC;gBACnF,SAAS;YACX,QAAQ,CAAC,IAAI,CAAC;gBACZ,KAAK;gBACL,GAAG;gBACH,OAAO,EAAE,2CAA2C;gBACpD,IAAI,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE;aACjC,CAAC,CAAC;QACL,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,UAAU,GAAyB;IAC9C,mBAAmB,EAAE,UAAU;IAC/B,kBAAkB,EAAE,aAAa;IACjC,sBAAsB,EAAE,aAAa;IACrC,sBAAsB,EAAE,aAAa;CACtC,CAAC","sourcesContent":["import type { Code, Heading, Nodes } from \"mdast\";\nimport stringWidth from \"string-width\";\nimport type { Document, Edit, Finding, Rule } from \"../core/types.js\";\nimport {\n belowTomlFrontMatter,\n frontMatterReading,\n joinsTomlFrontMatter,\n range,\n startsWithMarker,\n unclosedFrontMatter,\n} from \"../syntax/parse.js\";\nimport { walk } from \"../syntax/walk.js\";\n\n/** A JSON Schema for an options object with these properties and no others. */\nfunction schema(properties: Record<string, unknown>) {\n return { type: \"object\", properties, additionalProperties: false };\n}\n/** Any CommonMark line ending, including a lone carriage return. */\nconst lineBreak = /\\r\\n|\\r|\\n/;\nfunction lineStart(source: string, at: number): number {\n while (at > 0 && source[at - 1] !== \"\\n\" && source[at - 1] !== \"\\r\") at--;\n return at;\n}\nfunction lineEnd(source: string, at: number): number {\n while (at < source.length && source[at] !== \"\\n\" && source[at] !== \"\\r\") at++;\n return at;\n}\n/** A physical line: where it starts, where its content ends, and where the next line starts. */\ninterface Line {\n start: number;\n end: number;\n next: number;\n}\nfunction physicalLines(source: string): Line[] {\n const lines: Line[] = [];\n let start = 0;\n for (const match of source.matchAll(/\\r\\n|\\r|\\n/g)) {\n lines.push({ start, end: match.index, next: match.index + match[0].length });\n start = match.index + match[0].length;\n }\n if (start < source.length) lines.push({ start, end: source.length, next: source.length });\n return lines;\n}\n/** Whether the parser gave a node, perhaps one of a plugin's syntax, a source position. */\nfunction located(node: Nodes): boolean {\n return node.position?.start.offset !== undefined && node.position.end.offset !== undefined;\n}\n/** Blocks whose lines hold other blocks, and blank lines between them. */\nconst containers = new Set([\"root\", \"blockquote\", \"list\", \"listItem\", \"footnoteDefinition\"]);\n/** Sort ranges and merge those that overlap or touch. */\nfunction merged(ranges: [number, number][]): [number, number][] {\n const result: [number, number][] = [];\n for (const [start, end] of ranges.filter(([a, b]) => a < b).sort((x, y) => x[0] - y[0])) {\n const last = result.at(-1);\n if (last && start <= last[1]) last[1] = Math.max(last[1], end);\n else result.push([start, end]);\n }\n return result;\n}\n\n/**\n * HTML blocks that end only at an end marker, by what starts them, with the\n * markers that end them, in lowercase, and the offset from which they are\n * searched: CommonMark's kinds 1 to 5. The other kinds end at a blank line.\n * These are CommonMark's markers, not HTML's: a comment's block ends only at\n * `-->`, not at `--!>`.\n */\nconst htmlEnds: [RegExp, string[], number][] = [\n [\n /^<(?:pre|script|style|textarea)(?:[\\t\\n\\r >]|$)/i,\n [\"</pre>\", \"</script>\", \"</style>\", \"</textarea>\"],\n 1,\n ],\n [/^<!--/, [\"-->\"], 2],\n [/^<\\?/, [\"?>\"], 1],\n [/^<!\\[CDATA\\[/, [\"]]>\"], 9],\n [/^<![A-Za-z]/, [\">\"], 2],\n];\n/**\n * Whether a block is an HTML block of a kind that ends only at its end marker,\n * or an Obsidian comment, and lacks that marker. Such a block runs to the end\n * of its container and takes in every line ending and blank line up to there.\n */\nfunction unclosed(node: Nodes): boolean {\n if (node.type === \"obsidianComment\") return node.value.indexOf(\"%%\", 2) < 0;\n if (node.type !== \"html\") return false;\n // The value keeps the block's indentation.\n const value = node.value.replace(/^[ \\t]+/, \"\");\n for (const [opening, ends, from] of htmlEnds) {\n if (!opening.test(value)) continue;\n const rest = value.slice(from).toLowerCase();\n return !ends.some((end) => rest.includes(end));\n }\n return false;\n}\n/**\n * Whether a line added directly below `node`, at its own level, would become\n * part of an HTML block or Obsidian comment that `node` ends with and that has\n * no end marker. The parser lets such an HTML block run on through the blank\n * lines of a list item or footnote, and through a final line ending, but a\n * block quote ends it. An Obsidian comment runs on to the end of the document,\n * whatever contains it.\n */\nexport function takesLines(node: Nodes): boolean {\n let quoted = false;\n while (containers.has(node.type) && \"children\" in node && node.children.length) {\n if (node.type === \"blockquote\") quoted = true;\n node = node.children.at(-1)!;\n }\n return unclosed(node) && (node.type === \"obsidianComment\" || !quoted);\n}\n/**\n * Whether a blank line added directly below `node`, at its own level, would be\n * read by renderers as part of a fenced code block that ends a list item in\n * `node` and has no closing fence. Such a block runs to the end of the item,\n * and renderers count the item's last blank lines as its content, while the\n * parser does not (issue #350). A block quote ends at a blank line, and so\n * does the code in it.\n */\nexport function endsInOpenFence(source: string, node: Nodes): boolean {\n let item = false;\n while (containers.has(node.type) && \"children\" in node && node.children.length) {\n if (node.type === \"blockquote\") return false;\n if (node.type === \"listItem\") item = true;\n node = node.children.at(-1)!;\n }\n if (!item || node.type !== \"code\" || !located(node)) return false;\n const fence = codeFence(source, node);\n return fence !== undefined && !fence.close;\n}\n/**\n * Whether a line ending added at the end of the document would change its\n * last block. Besides the blocks of `takesLines`, the parser counts a last\n * line of blank space in a code or math block that has no closing fence only\n * when a line ending follows it.\n */\nexport function takesFinalLineEnding(document: Document): boolean {\n if (takesLines(document.tree)) return true;\n if (!/(?:^|[\\r\\n])[ \\t]+$/.test(document.source)) return false;\n const last = lastBlock(document.tree);\n if ((last.type !== \"code\" && last.type !== \"math\") || !located(last)) return false;\n const fence = codeFence(document.source, last);\n return fence !== undefined && !fence.close;\n}\n\n/**\n * Whether `style/heading` writes headings of levels 1 and 2 underlined: with\n * `setext`, or with `consistent` when the document's first heading is.\n */\nexport function underlinedHeadings(document: Document, style: unknown): boolean {\n if (style !== \"consistent\") return style === \"setext\";\n let first: Heading | undefined;\n walk(document.tree, \"heading\", (node) => {\n if (!first && located(node)) first = node;\n });\n return first !== undefined && /[\\r\\n]/.test(document.source.slice(...range(first)));\n}\n/**\n * The start of a line that would not begin a paragraph after a blank line: a\n * list item, heading, block quote, thematic break, fence, HTML, math, or\n * Obsidian comment, a link reference definition, or a table row, which `---`\n * below it could make a table.\n */\nconst notParagraph =\n /^(?:[-+*](?:[ \\t]|$)|\\d{1,9}[.)](?:[ \\t]|$)|#{1,6}(?:[ \\t]|$)|>|([-*_])[ \\t]*(?:\\1[ \\t]*){2,}$|`{3,}|~{3,}|<|\\$\\$|%%|\\[[^]*\\]:)|\\|/;\n/**\n * The edit that writes the `#` heading `node`, of level 1 or 2, underlined\n * with `===` or `---`, or undefined where its text could not stand on a line\n * of its own as the same heading. Only headings at the start of a line of the\n * document itself, below a blank line or at the start, are underlined:\n * directly below text, the heading's line would continue a paragraph. On\n * Forgejo and Gitea, a heading with a `{` keeps its form, because their\n * attribute blocks depend on it.\n */\nexport function underlineEdit(document: Document, node: Heading): Edit | undefined {\n const { source } = document;\n const first = node.children[0];\n const last = node.children.at(-1);\n if (node.depth > 2 || !first || !last || !located(first) || !located(last)) return undefined;\n const [start] = range(node);\n if (lineStart(source, start) !== start) return undefined;\n if (start > 0) {\n const above = lineStart(source, start - (source.startsWith(\"\\r\\n\", start - 2) ? 2 : 1));\n if (!/^[ \\t]*$/.test(source.slice(above, lineEnd(source, above)))) return undefined;\n }\n const text = source.slice(range(first)[0], range(last)[1]);\n if (notParagraph.test(text) || text.endsWith(\"\\\\\")) return undefined;\n if ((document.dialect === \"forgejo\" || document.dialect === \"gitea\") && text.includes(\"{\"))\n return undefined;\n // Forgejo and Gitea open a definition or display math with these.\n if (/^(?::[ \\t]|\\\\\\[)/.test(text)) return undefined;\n const newline = /\\r\\n|\\r|\\n/.exec(source)?.[0] ?? \"\\n\";\n // Below a first line of `---` that opens no front matter, an underline of\n // `---` alone would close it (issue #278).\n const shortest = node.depth === 2 && unclosedFrontMatter(source) === \"---\" ? 4 : 3;\n const underline = (node.depth === 1 ? \"=\" : \"-\").repeat(Math.max(shortest, stringWidth(text)));\n return { start, end: lineEnd(source, start), text: `${text}${newline}${underline}` };\n}\n\n/** The fences of a fenced code or math block: the marker runs, as source ranges. */\ninterface Fence {\n marker: \"`\" | \"~\" | \"$\";\n open: [number, number];\n /** Absent when the block runs to the end of its container without a closing fence. */\n close?: [number, number];\n}\n/** The fences of a code or math block, or undefined for an indented code block. */\nfunction codeFence(\n source: string,\n node: Code | Extract<Nodes, { type: \"math\" }>,\n): Fence | undefined {\n const [start, end] = range(node);\n // A fenced block starts at its fence; an indented one at its indentation.\n const opening = /^(?:`{3,}|~{3,}|\\${2,})/.exec(source.slice(start, lineEnd(source, start)));\n if (!opening) return undefined;\n const marker = opening[0][0] as Fence[\"marker\"];\n const fence: Fence = { marker, open: [start, start + opening[0].length] };\n // The block's lines are the opening fence, the content, and the closing\n // fence if there is one. An empty value is no line or one blank line, and a\n // closing fence is never blank.\n const lines = source.slice(start, end).split(lineBreak);\n const last = lines.at(-1)!;\n const closing = new RegExp(\n `(?:${marker === \"$\" ? \"\\\\$\" : marker}){${opening[0].length},}(?=[ \\\\t]*$)`,\n ).exec(last);\n const content = node.value === \"\" ? undefined : node.value.split(lineBreak).length;\n if (closing && lines.length > 1 && (content === undefined || lines.length === content + 2)) {\n const at = end - last.length + closing.index;\n fence.close = [at, at + closing[0].length];\n }\n return fence;\n}\n\nconst codeFenceRule: Rule = {\n description: \"Write code fences with one marker and the length their content needs.\",\n kind: \"style\",\n phase: \"block\",\n schema: schema({ marker: { enum: [\"```\", \"~~~\", \"consistent\"] } }),\n check({ document, options }) {\n const { source } = document;\n const fences: { node: Code; fence: Fence }[] = [];\n walk(document.tree, \"code\", (node) => {\n const fence = located(node) ? codeFence(source, node) : undefined;\n if (fence) fences.push({ node, fence });\n });\n // `consistent` takes the marker of the first fence in the document.\n const marker =\n options.marker === \"~~~\"\n ? \"~\"\n : options.marker === \"consistent\"\n ? (fences[0]?.fence.marker ?? \"`\")\n : \"`\";\n const findings: Finding[] = [];\n for (const { node, fence } of fences) {\n // The info string of a backtick fence cannot contain a backtick.\n if (\n marker === \"`\" &&\n source.slice(fence.open[1], lineEnd(source, fence.open[1])).includes(\"`\")\n )\n continue;\n // A content line of the marker alone, at any indentation, could close a\n // fence that is not longer than it.\n let longest = 0;\n for (const line of node.value.split(lineBreak)) {\n const run = /^[ \\t]*(`+|~+)[ \\t]*$/.exec(line)?.[1];\n if (run?.[0] === marker) longest = Math.max(longest, run.length);\n }\n const text = marker.repeat(Math.max(3, longest + 1));\n for (const [start, end] of fence.close ? [fence.open, fence.close] : [fence.open])\n if (source.slice(start, end) !== text)\n findings.push({\n start,\n end,\n message: `Use ${text} for the code fence.`,\n edit: { start, end, text },\n });\n }\n return findings;\n },\n};\n\n/** The innermost last block of a container, where its text ends. */\nfunction lastBlock(node: Nodes): Nodes {\n while (containers.has(node.type) && \"children\" in node && node.children.length)\n node = node.children.at(-1)!;\n return node;\n}\nconst thematicBreak: Rule = {\n description: \"Write thematic breaks with one marker.\",\n kind: \"style\",\n phase: \"block\",\n schema: schema({ marker: { enum: [\"---\", \"***\", \"___\", \"consistent\"] } }),\n check({ document, options }) {\n const { source } = document;\n let marker = typeof options.marker === \"string\" ? options.marker : \"---\";\n // `consistent` takes the character of the first thematic break in the document.\n if (marker === \"consistent\") {\n let first: string | undefined;\n walk(document.tree, \"thematicBreak\", (node) => {\n if (first === undefined && located(node)) first = source[range(node)[0]];\n });\n marker = (first ?? \"-\").repeat(3);\n }\n const findings: Finding[] = [];\n walk(document.tree, \"thematicBreak\", (node, index, parent) => {\n if (!located(node)) return;\n const [start, last] = range(node);\n // The break's range includes blank space after its markers.\n const end = start + source.slice(start, last).replace(/[ \\t]+$/, \"\").length;\n if (source.slice(start, end) === marker) return;\n // At the start of the document, a break written `---` would open front\n // matter if a later line closed it, as a line of `---` alone does, also\n // one that this rule writes. A first-line `---` that the parser reads as a\n // break and site generators as front matter stays (issue #295).\n if (\n start === 0 &&\n (marker === \"---\" || (source.startsWith(\"---\") && frontMatterReading(document.tree)))\n )\n return;\n // Below a first line of `---` that opens no front matter, a line of `---`\n // alone would close it (issue #278).\n if (\n marker === \"---\" &&\n lineStart(source, start) === start &&\n unclosedFrontMatter(source) === \"---\"\n )\n return;\n // Renderers without TOML front matter read its lines as a paragraph,\n // which a line of `---` directly below underlines as a heading, as one\n // written there already does (issue #333).\n if (\n (marker === \"---\" && belowTomlFrontMatter(document.tree, node)) ||\n joinsTomlFrontMatter(document.tree, node)\n )\n return;\n // On the line of list items whose markers are the new marker's character,\n // the items and the break would become one thematic break, as `- ---`,\n // `1. - ---`, and `* ***` are.\n const items = new RegExp(`[ \\\\t${marker[0] === \"-\" ? \"\\\\-\" : marker[0]}]*$`);\n const prefix = source.slice(lineStart(source, start), start);\n if (items.exec(prefix)![0].includes(marker[0]!)) return;\n if (marker === \"---\") {\n // Directly below a paragraph or a link reference definition, `---`\n // would underline it as a heading, and so it would display math,\n // which GitHub builds from a paragraph (issue #336).\n const above = index && parent ? lastBlock(parent.children[index - 1]!) : undefined;\n if (\n above &&\n (above.type === \"paragraph\" || above.type === \"definition\" || above.type === \"math\") &&\n above.position?.end.line === node.position!.start.line - 1\n )\n return;\n }\n findings.push({\n start,\n end,\n message: `Write the thematic break as ${marker}.`,\n edit: { start, end, text: marker },\n });\n });\n return findings;\n },\n};\n\n/** Where blank lines are content, or their number counts, as source ranges. */\nfunction contentBlocks(document: Document): [number, number][] {\n const blocks: [number, number][] = [];\n walk(document.tree, (node, _, parent) => {\n if (!located(node)) return;\n if (parent && containers.has(parent.type) && !containers.has(node.type))\n blocks.push(range(node));\n // In a block quote, a list, list item, or footnote can extend over the\n // blank lines below its last block. The parser then reads a list as loose,\n // or a list item as tight, by how many there are.\n const last =\n node.type === \"list\" || node.type === \"listItem\" || node.type === \"footnoteDefinition\"\n ? node.children.at(-1)\n : undefined;\n if (last && located(last) && range(last)[1] < range(node)[1])\n blocks.push([range(last)[1], range(node)[1]]);\n });\n return merged(blocks);\n}\nconst blankLines: Rule = {\n description: \"Limit blank lines in a row and remove those around the document.\",\n kind: \"style\",\n phase: \"document\",\n // Fewer than one blank line would join the blocks that it separates.\n schema: schema({ maximum: { type: \"integer\", minimum: 1 } }),\n check({ document, options }) {\n const { source } = document;\n const maximum = typeof options.maximum === \"number\" ? options.maximum : 1;\n const lines = physicalLines(source);\n const text = (line: Line) => source.slice(line.start, line.end);\n const empty = (line: Line) => /^[ \\t]*$/.test(text(line));\n // A line of blank space and block quote markers is blank inside its quotes.\n const blank = (line: Line) => /^[ \\t>]*$/.test(text(line));\n const blocks = contentBlocks(document);\n let block = 0;\n /** Whether a line lies inside a block that began above it; asked in document order. */\n const inside = (line: Line) => {\n while (block < blocks.length && blocks[block]![1] < line.end) block++;\n return block < blocks.length && blocks[block]![0] < line.start;\n };\n const findings: Finding[] = [];\n const remove = (from: number, to: number, message: string) =>\n findings.push({ start: from, end: to, message, edit: { start: from, end: to, text: \"\" } });\n let first = 0;\n while (first < lines.length && empty(lines[first]!)) first++;\n if (first === lines.length) {\n if (source) remove(0, source.length, \"Remove the blank lines.\");\n return findings;\n }\n let last = lines.length;\n // A block without its end, such as an unclosed fence, takes in the blank lines at the end.\n const inBlock = lines.map((line) => blank(line) && inside(line));\n while (empty(lines[last - 1]!) && !inBlock[last - 1]) last--;\n // Below blank lines, `---` or `+++` on the first line would open front matter.\n if (first > 0 && !/^(?:-{3}|\\+{3})/.test(text(lines[first]!)))\n remove(0, lines[first]!.start, \"Remove the blank lines at the start of the document.\");\n // Blank lines in a row with the same block quote markers and indentation\n // are one separation, however many there are.\n const trimmed = (line: Line) => text(line).replace(/[ \\t]+$/, \"\");\n const message =\n maximum === 1\n ? \"Remove the repeated blank line.\"\n : `Remove the blank lines beyond ${maximum} in a row.`;\n for (let index = first; index < last;) {\n const line = lines[index]!;\n let end = index + 1;\n if (blank(line) && !inBlock[index])\n while (\n end < last &&\n blank(lines[end]!) &&\n !inBlock[end] &&\n trimmed(lines[end]!) === trimmed(line)\n )\n end++;\n if (end - index > maximum)\n remove(lines[index + maximum]!.start, lines[end - 1]!.next, message);\n index = end;\n }\n if (last < lines.length)\n remove(\n lines[last]!.start,\n source.length,\n \"Remove the blank lines at the end of the document.\",\n );\n return findings;\n },\n};\n\n/** Nodes whose source between the lines of their text is ordinary prose. */\nconst prose = new Set([\n ...containers,\n \"paragraph\",\n \"heading\",\n \"thematicBreak\",\n \"table\",\n \"tableRow\",\n \"tableCell\",\n \"text\",\n \"emphasis\",\n \"strong\",\n \"delete\",\n]);\nconst trailingSpace: Rule = {\n description: \"Remove spaces and tabs at the end of lines outside code and HTML.\",\n kind: \"style\",\n phase: \"document\",\n schema: schema({ hardBreak: { enum: [\"keep\", \"backslash\"] } }),\n check({ document, options }) {\n const { source } = document;\n if (!/[ \\t](?:\\r|\\n|$)/.test(source)) return [];\n const backslash = options.hardBreak === \"backslash\";\n const forge = document.dialect === \"forgejo\" || document.dialect === \"gitea\";\n /** Source in which blank space at the end of a line is content. */\n const kept: [number, number][] = [];\n /**\n * Hard line breaks, with the paragraph or heading each one is in, and\n * whether that block starts like an alert's or callout's marker, `[!`.\n */\n const breaks: { start: number; end: number; block: [number, number]; marker: boolean }[] = [];\n const links: [number, number][] = [];\n let block: [number, number] = [0, 0];\n let marker = false;\n walk(document.tree, (node, _, parent) => {\n if (!located(node)) {\n // A plugin's node without a position keeps whatever its parent spans.\n if (parent && located(parent)) kept.push(range(parent));\n return;\n }\n const [start, end] = range(node);\n if (node.type === \"paragraph\" || node.type === \"heading\") {\n block = [start, end];\n const written = source.slice(start, end);\n marker =\n node.type === \"paragraph\"\n ? startsWithMarker(written, node, /^\\[!/)\n : written.startsWith(\"[!\");\n }\n if (node.type === \"link\") links.push([start, end]);\n if (node.type === \"break\") breaks.push({ start, end, block, marker });\n else if (node.type === \"link\" || node.type === \"linkReference\") {\n // The link text is prose; a title or label that spans lines is not.\n let at = start;\n for (const child of node.children) {\n if (!located(child)) continue;\n kept.push([at, range(child)[0]]);\n at = range(child)[1];\n }\n kept.push([at, end]);\n } else if (node.type === \"code\") {\n const fence = codeFence(source, node);\n // A fence line ends in syntax, unless an info string's text runs to its end.\n const from = fence && !node.meta ? lineEnd(source, start) : start;\n kept.push([from, fence?.close ? lineStart(source, fence.close[0]) : end]);\n } else if (!prose.has(node.type)) kept.push([start, end]);\n });\n const ranges = merged(kept);\n let next = 0;\n let following = 0;\n let link = 0;\n /**\n * Whether a backslash in place of the blank space of a hard line break,\n * which starts at `start`, would mean the same. One after another\n * backslash would be escaped. A literal autolink such as `www.example.com`\n * runs on to the next blank space, so it would take the backslash in. A\n * paragraph that starts like `[label]:` could become a link reference\n * definition with the backslash as its destination, and the title line of\n * an alert or callout, also one written as `\\[!NOTE]`, would end with it.\n * On Forgejo and Gitea, a backslash inside `\\(...\\)` math would be part of\n * the formula.\n */\n const backslashSafe = (start: number, paragraph: [number, number], marker: boolean) => {\n if (source[start - 1] === \"\\\\\") return false;\n let word = start;\n while (word > paragraph[0] && !/[ \\t\\r\\n]/.test(source[word - 1]!)) word--;\n while (link < links.length && links[link]![1] <= word) link++;\n if (link < links.length && links[link]![0] < start) return false;\n const before = source.slice(paragraph[0], start);\n if (/^\\[[^]*\\]:/.test(before) || (marker && !/[\\r\\n]/.test(before))) return false;\n return !(forge && source.slice(...paragraph).includes(\"\\\\(\"));\n };\n const findings: Finding[] = [];\n for (const line of physicalLines(source)) {\n const space = /[ \\t]+$/.exec(source.slice(line.start, line.end));\n if (!space) continue;\n const start = line.start + space.index;\n const end = line.end;\n while (next < ranges.length && ranges[next]![1] <= start) next++;\n if (next < ranges.length && ranges[next]![0] < end) continue;\n // Breaks are in document order, as lines are.\n while (following < breaks.length && breaks[following]!.end <= start) following++;\n const hard = breaks[following]?.start !== undefined && breaks[following]!.start < end;\n if (!hard) {\n findings.push({\n start,\n end,\n message: \"Remove the spaces and tabs at the end of the line.\",\n edit: { start, end, text: \"\" },\n });\n continue;\n }\n const brk = breaks[following]!;\n if (!backslash || brk.start !== start || !backslashSafe(start, brk.block, brk.marker))\n continue;\n findings.push({\n start,\n end,\n message: \"Write the hard line break as a backslash.\",\n edit: { start, end, text: \"\\\\\" },\n });\n }\n return findings;\n },\n};\n\nexport const blockRules: Record<string, Rule> = {\n \"style/blank-lines\": blankLines,\n \"style/code-fence\": codeFenceRule,\n \"style/thematic-break\": thematicBreak,\n \"style/trailing-space\": trailingSpace,\n};\n"]}
|
package/dist/rules/links.js
CHANGED
|
@@ -269,6 +269,12 @@ function named(paths) {
|
|
|
269
269
|
? `${paths.slice(0, 3).join(", ")}, and ${paths.length - 3} more`
|
|
270
270
|
: paths.join(", ");
|
|
271
271
|
}
|
|
272
|
+
/** The nodes inside table cells, where a `|` that is not escaped ends the cell. */
|
|
273
|
+
function inTableCells(tree) {
|
|
274
|
+
const nodes = new Set();
|
|
275
|
+
walk(tree, "tableCell", (cell) => walk(cell, (child) => nodes.add(child)));
|
|
276
|
+
return nodes;
|
|
277
|
+
}
|
|
272
278
|
export const linkRules = {
|
|
273
279
|
"links/valid": {
|
|
274
280
|
description: "Check local link destinations and dialect-specific heading/block references.",
|
|
@@ -333,6 +339,7 @@ export const linkRules = {
|
|
|
333
339
|
}),
|
|
334
340
|
check({ document, options, workspace }) {
|
|
335
341
|
const findings = [];
|
|
342
|
+
let inCell;
|
|
336
343
|
walk(document.tree, (node) => {
|
|
337
344
|
const url = destination(node);
|
|
338
345
|
if (url === undefined || !workspace)
|
|
@@ -414,8 +421,16 @@ export const linkRules = {
|
|
|
414
421
|
return;
|
|
415
422
|
if (!node.embed && node.label === undefined && replacement !== node.target)
|
|
416
423
|
return;
|
|
417
|
-
|
|
418
|
-
|
|
424
|
+
// Only the destination changes. The divider stays as written, `|` or
|
|
425
|
+
// `\|`, which a table cell needs, and so do the label and an embed's size.
|
|
426
|
+
const raw = document.source.slice(start, end);
|
|
427
|
+
const open = node.embed ? 3 : 2;
|
|
428
|
+
const divider = raw.indexOf("|", open);
|
|
429
|
+
const targetEnd = divider < 0 ? raw.length - 2 : raw[divider - 1] === "\\" ? divider - 1 : divider;
|
|
430
|
+
if (raw.slice(open, targetEnd) !== node.target)
|
|
431
|
+
return;
|
|
432
|
+
replacement = raw.slice(0, open) + replacement + raw.slice(targetEnd);
|
|
433
|
+
if (replacement !== raw)
|
|
419
434
|
findings.push({
|
|
420
435
|
start,
|
|
421
436
|
end,
|
|
@@ -442,6 +457,9 @@ export const linkRules = {
|
|
|
442
457
|
.replaceAll(")", "%29")
|
|
443
458
|
.replaceAll("<", "%3C")
|
|
444
459
|
.replaceAll(">", "%3E");
|
|
460
|
+
// A file or folder name can hold a `|`, which would end a table cell.
|
|
461
|
+
if (replacement.includes("|") && (inCell ??= inTableCells(document.tree)).has(node))
|
|
462
|
+
replacement = replacement.replaceAll("|", "\\|");
|
|
445
463
|
if (document.dialect === "gitea" &&
|
|
446
464
|
(giteaPyLine(document, start, end) || replacement.includes("_.py")) &&
|
|
447
465
|
giteaUnderscores(original) !== giteaUnderscores(replacement))
|
|
@@ -470,8 +488,10 @@ export const linkRules = {
|
|
|
470
488
|
if (document.dialect !== "obsidian" || !workspace)
|
|
471
489
|
return [];
|
|
472
490
|
const findings = [];
|
|
491
|
+
let inCell;
|
|
473
492
|
walk(document.tree, (node) => {
|
|
474
493
|
const [start, end] = range(node);
|
|
494
|
+
const pipe = () => ((inCell ??= inTableCells(document.tree)).has(node) ? "\\|" : "|");
|
|
475
495
|
let replacement;
|
|
476
496
|
if (options.style === "markdown" &&
|
|
477
497
|
node.type === "wikiLink" &&
|
|
@@ -479,7 +499,8 @@ export const linkRules = {
|
|
|
479
499
|
node.label !== undefined) {
|
|
480
500
|
if (/[[\]<>\\\r\n]/.test(node.target ?? "") || /[*_`[\]\\]/.test(node.label))
|
|
481
501
|
return;
|
|
482
|
-
|
|
502
|
+
const label = node.label.includes("|") ? node.label.replaceAll("|", pipe()) : node.label;
|
|
503
|
+
replacement = `[${label}](<${node.target}>)`;
|
|
483
504
|
}
|
|
484
505
|
else if (options.style === "wiki" &&
|
|
485
506
|
node.type === "link" &&
|
|
@@ -490,7 +511,7 @@ export const linkRules = {
|
|
|
490
511
|
const target = wikiTarget(node.url);
|
|
491
512
|
if (target === undefined || /[[\]|\r\n]/.test(label))
|
|
492
513
|
return;
|
|
493
|
-
replacement = `[[${target}
|
|
514
|
+
replacement = `[[${target}${pipe()}${label}]]`;
|
|
494
515
|
}
|
|
495
516
|
const url = destination(node);
|
|
496
517
|
if (!replacement || url === undefined)
|
package/dist/rules/links.js.map
CHANGED
|
@@ -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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AAE,CAAC,IAAI,EAAE,EAAE;gBAC3B,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,IAAI,IAAI,CAAC,IAAI,KAAK,YAAY;oBAAE,OAAO;gBACxF,IAAI,IAAI,CAAC,GAAG,KAAK,EAAE,IAAI,IAAI,CAAC,GAAG,KAAK,GAAG;oBAAE,OAAO;gBAChD,MAAM,IAAI,GACR,IAAI,CAAC,IAAI,KAAK,OAAO;oBACnB,CAAC,CAAC,cAAc;oBAChB,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,YAAY;wBAC1B,CAAC,CAAC,8BAA8B,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,GAAG;wBAC9F,CAAC,CAAC,kBAAkB,CAAC;gBAC3B,QAAQ,CAAC,IAAI,CAAC;oBACZ,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;oBACrB,OAAO,EACL,IAAI,CAAC,GAAG,KAAK,EAAE;wBACb,CAAC,CAAC,GAAG,IAAI,YAAY;wBACrB,CAAC,CAAC,GAAG,IAAI,aAAa,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,2CAA2C,CAAC,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,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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BAAE,OAAO;gBACxF,IAAI,IAAI,CAAC,GAAG,KAAK,EAAE,IAAI,IAAI,CAAC,GAAG,KAAK,GAAG;oBAAE,OAAO;gBAChD,MAAM,IAAI,GACR,IAAI,CAAC,IAAI,KAAK,OAAO;oBACnB,CAAC,CAAC,cAAc;oBAChB,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,YAAY;wBAC1B,CAAC,CAAC,8BAA8B,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,GAAG;wBAC9F,CAAC,CAAC,kBAAkB,CAAC;gBAC3B,QAAQ,CAAC,IAAI,CAAC;oBACZ,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;oBACrB,OAAO,EACL,IAAI,CAAC,GAAG,KAAK,EAAE;wBACb,CAAC,CAAC,GAAG,IAAI,YAAY;wBACrB,CAAC,CAAC,GAAG,IAAI,aAAa,IAAI,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC,CAAC,2CAA2C,CAAC,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\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"]}
|
package/dist/rules/style.js
CHANGED
|
@@ -5,7 +5,7 @@ import { blockIdentifier } from "../syntax/block-identifier.js";
|
|
|
5
5
|
import { misreadLists } from "../syntax/misread-lists.js";
|
|
6
6
|
import { codeSpanText, joinsTomlFrontMatter, labelEnd, lazyIndentation, parse, range, startsWithMarker, } from "../syntax/parse.js";
|
|
7
7
|
import { changesForgeHeading, headingAttributeBlock } from "../workspace/heading-attributes.js";
|
|
8
|
-
import { takesFinalLineEnding, takesLines, underlinedHeadings, underlineEdit } from "./blocks.js";
|
|
8
|
+
import { endsInOpenFence, takesFinalLineEnding, takesLines, underlinedHeadings, underlineEdit, } from "./blocks.js";
|
|
9
9
|
export function optionsSchema(properties) {
|
|
10
10
|
return { type: "object", properties, additionalProperties: false };
|
|
11
11
|
}
|
|
@@ -1324,8 +1324,9 @@ function together(document, parent, index, directiveLines) {
|
|
|
1324
1324
|
// Front matter is not part of the document's text.
|
|
1325
1325
|
if (["yaml", "toml"].includes(before.type))
|
|
1326
1326
|
return true;
|
|
1327
|
-
// An unclosed HTML comment or block at the end of a list would take in the
|
|
1328
|
-
|
|
1327
|
+
// An unclosed HTML comment or block at the end of a list would take in the
|
|
1328
|
+
// blank line, and so would an unclosed code fence there on the renderers.
|
|
1329
|
+
if (takesLines(before) || endsInOpenFence(source, before))
|
|
1329
1330
|
return true;
|
|
1330
1331
|
// Other tools, too, read a comment as applying to the line below it, and
|
|
1331
1332
|
// `mdtools-disable-next-line` does: a blank line would take that line's place.
|