@descent-vtt/spec-harness 0.15.0 → 0.17.0
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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/CHANGELOG.md +198 -0
- package/README.md +18 -3
- package/dist/branch.js +12 -0
- package/dist/branch.js.map +1 -1
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +76 -56
- package/dist/cli.js.map +1 -1
- package/dist/configure.d.ts +200 -20
- package/dist/configure.js +514 -69
- package/dist/configure.js.map +1 -1
- package/dist/hooks.d.ts +17 -1
- package/dist/hooks.js +17 -1
- package/dist/hooks.js.map +1 -1
- package/dist/reader.js +5 -1
- package/dist/reader.js.map +1 -1
- package/dist/round.d.ts +35 -6
- package/dist/round.js +137 -17
- package/dist/round.js.map +1 -1
- package/dist/rulings.js +6 -0
- package/dist/rulings.js.map +1 -1
- package/dist/setup.d.ts +1 -1
- package/dist/setup.js +72 -17
- package/dist/setup.js.map +1 -1
- package/dist/signers.js +5 -1
- package/dist/signers.js.map +1 -1
- package/dist/usage.d.ts +48 -8
- package/dist/usage.js +35 -1
- package/dist/usage.js.map +1 -1
- package/dist/vendor/spec-core/jsonrpc/mcp.js.map +1 -1
- package/dist/vendor/spec-core/markdown/frontmatter.js.map +1 -1
- package/dist/vendor/spec-core/markdown/headings.js.map +1 -1
- package/dist/vendor/spec-core/markdown/links.js.map +1 -1
- package/dist/vendor/spec-core/markdown/scan.js.map +1 -1
- package/dist/vendor/spec-core/pattern/automaton.js.map +1 -1
- package/dist/vendor/spec-core/pattern/charset.js.map +1 -1
- package/dist/vendor/spec-core/pattern/regex.js.map +1 -1
- package/dist/vendor/spec-core/text/lines.js.map +1 -1
- package/dist/vendor/spec-core/text/width.js.map +1 -1
- package/dist/workspace.d.ts +12 -3
- package/dist/workspace.js +20 -3
- package/dist/workspace.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
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AS,CAAC,IAAI,CAAC,IAAI,CAAC;YAClE,OAAO,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI;SAC9D,CAAC,CAAC;IACL,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,OAAO,CAAC,IAAkB;IACxC,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC;AAClD,CAAC","sourcesContent":["/**\n * Headings, their GitHub anchors, and the sections they open.\n *\n * A heading is found in the structure mask, so one written in a code sample\n * or a comment is not one, and its text is read from the prose mask, so a\n * code span in it is kept and a comment after it is not.\n */\n\nimport { isMarkdown, isSpaceOrTab, visibleLead, type Layout } from './layout.js';\nimport { atxLevel, isThematicBreak, leadIndex, listMarker, setextUnderline } from './syntax.js';\nimport type { Heading, HeadingForm, HtmlComment, MarkdownScan, ScannedLine, Section, Table } from './types.js';\n\n/**\n * GitHub's slug of a heading's text: lower case, punctuation dropped, every\n * whitespace character a hyphen.\n *\n * spec-graph's slug, with two of its steps taken out because a later step\n * did their work: it dropped Markdown's punctuation and then all punctuation,\n * and trimmed before and after. What remains gives the same slug for every\n * text. It drops `_`, which GitHub keeps.\n */\nexport function slugify(text: string): string {\n return (\n text\n .toLowerCase()\n .replace(/[^\\p{L}\\p{N}\\s-]/gu, '')\n .trim()\n // GitHub hyphenates every whitespace character, so a run of two spaces\n // left behind by stripped punctuation becomes two hyphens, not one.\n .replace(/\\s/g, '-')\n );\n}\n\n/** A heading before GitHub's anchors are counted, which needs every heading. */\nexport type Unanchored = Omit<Heading, 'anchor'>;\n\n/**\n * ATX headings: `#` to `######` opening a line, after at most three spaces.\n *\n * Only a line whose first character is visible in the structure mask is read,\n * and the mask blanks every line of front matter, code and raw-text HTML.\n */\nexport function findAtxHeadings(layout: Layout): Unanchored[] {\n const out: Unanchored[] = [];\n const strip = commentStripper(layout);\n for (const line of layout.lines) {\n const level = atxLevel(line.content);\n if (level === 0 || !visibleLead(layout, line)) continue;\n const opened = line.contentStart + leadIndex(line.content) + level;\n const [textStart, textEnd] = atxText(layout.prose, opened, line.end);\n out.push(heading('atx', level, strip(textStart, textEnd), textStart, textEnd, line, line));\n }\n return out;\n}\n\n/**\n * The text of an ATX heading: trimmed, without a closing sequence. A closing\n * run of `#` counts only after a space or a tab, so `# C#` is about C#. The\n * character at `to` ends the line, and is not a space.\n */\nfunction atxText(prose: string, from: number, to: number): [number, number] {\n let start = from;\n while (isSpaceOrTab(prose, start)) start += 1;\n let end = to;\n while (end > start && isSpaceOrTab(prose, end - 1)) end -= 1;\n let hashes = end;\n while (hashes > start && prose.charCodeAt(hashes - 1) === 35) hashes -= 1;\n // Before a closing run there is the space it needs, or the space after the\n // opening run when the heading is nothing else.\n if (isSpaceOrTab(prose, hashes - 1)) {\n end = hashes;\n while (end > start && isSpaceOrTab(prose, end - 1)) end -= 1;\n }\n return [start, end];\n}\n\n/**\n * Every heading in order, ATX and setext, with GitHub's anchors.\n *\n * A setext heading is a paragraph line underlined with `=` or `-`. The line\n * above the underline must be one a paragraph can hold: not a heading, a list\n * item, a thematic break, a table row, blank, or indented four columns.\n * Otherwise `---` is a thematic break, and a table or a list followed by one\n * would gain a heading nobody wrote.\n */\nexport function findHeadings(layout: Layout, atx: readonly Unanchored[], tables: readonly Table[]): Heading[] {\n const { lines } = layout;\n const taken = new Set<number>();\n for (const h of atx) taken.add(h.line);\n for (const table of tables) for (let line = table.line; line <= table.endLine; line += 1) taken.add(line);\n\n const setext: Unanchored[] = [];\n const strip = commentStripper(layout);\n for (let i = 0; i + 1 < lines.length; i += 1) {\n const above = lines[i] as ScannedLine;\n const under = lines[i + 1] as ScannedLine;\n if (taken.has(above.line) || !paragraphLine(layout, above)) continue;\n if (!isMarkdown(under) || under.quoteDepth !== above.quoteDepth) continue;\n const mark = setextUnderline(under.content);\n if (mark === null || !visibleLead(layout, under)) continue;\n let textStart = above.contentStart;\n while (isSpaceOrTab(layout.prose, textStart)) textStart += 1;\n let textEnd = above.end;\n while (isSpaceOrTab(layout.prose, textEnd - 1)) textEnd -= 1;\n setext.push(heading('setext', mark === '=' ? 1 : 2, strip(textStart, textEnd), textStart, textEnd, above, under));\n // The underline is part of this heading, not the text of the next.\n i += 1;\n }\n\n const all = [...atx, ...setext].sort((a, b) => a.line - b.line);\n const occurrences = new Map<string, number>();\n return all.map((h) => ({ ...h, anchor: anchorOf(occurrences, h.slug) }));\n}\n\n/** A line that can be the text of a setext heading. */\nfunction paragraphLine(layout: Layout, line: ScannedLine): boolean {\n if (!isMarkdown(line) || line.blank || line.comment || line.indent >= 4) return false;\n return !(visibleLead(layout, line) && (listMarker(line.content) !== null || isThematicBreak(line.content)));\n}\n\n/**\n * GitHub's anchor for a slug: the slug itself the first time, then with `-1`,\n * `-2` and so on, skipping any suffixed form a heading already took.\n */\nfunction anchorOf(occurrences: Map<string, number>, slug: string): string {\n let anchor = slug;\n while (occurrences.has(anchor)) {\n const count = (occurrences.get(slug) as number) + 1;\n occurrences.set(slug, count);\n anchor = `${slug}-${count}`;\n }\n occurrences.set(anchor, 0);\n return anchor;\n}\n\nfunction heading(\n form: HeadingForm,\n level: number,\n text: string,\n textStart: number,\n textEnd: number,\n first: ScannedLine,\n last: ScannedLine,\n): Unanchored {\n return {\n form,\n level,\n text,\n slug: slugify(text),\n start: first.contentStart,\n end: last.end,\n textStart,\n textEnd,\n line: first.line,\n endLine: last.line,\n };\n}\n\n/**\n * The text between two offsets with the comments inside it taken out, as a\n * renderer shows it. Called with increasing offsets, so it walks the comments\n * once.\n */\nfunction commentStripper(layout: Layout): (start: number, end: number) => string {\n const { comments, text } = layout;\n let c = 0;\n return (start, end) => {\n let out = '';\n for (let at = start; at < end; at += 1) {\n while (c < comments.length && (comments[c] as HtmlComment).end <= at) c += 1;\n const comment = comments[c];\n if (comment === undefined || comment.start > at) out += text.charAt(at);\n }\n return out;\n };\n}\n\n/**\n * Each heading of `level` or deeper with everything under it, up to the next\n * heading at its level or above.\n */\nexport function sectionsOf(scan: MarkdownScan, level = 1): Section[] {\n const { headings, index, text } = scan;\n const out: Section[] = [];\n for (let h = 0; h < headings.length; h += 1) {\n const heading = headings[h] as Heading;\n if (heading.level < level) continue;\n let next: Heading | undefined;\n for (let k = h + 1; k < headings.length && next === undefined; k += 1) {\n const candidate = headings[k] as Heading;\n if (candidate.level <= heading.level) next = candidate;\n }\n out.push({\n heading,\n start: index.lineStart(heading.line),\n bodyStart: heading.endLine < index.lineCount ? index.lineStart(heading.endLine + 1) : text.length,\n end: next === undefined ? text.length : index.lineStart(next.line),\n endLine: next === undefined ? index.lineCount + 1 : next.line,\n });\n }\n return out;\n}\n\n/** The first level-one heading, which is what a reader takes as the title. */\nexport function titleOf(scan: MarkdownScan): Heading | undefined {\n return scan.headings.find((h) => h.level === 1);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"headings.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/markdown/headings.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,WAAW,EAAe,MAAM,aAAa,CAAC;AACjF,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,SAAS,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAGhG;;;;;;;;GAQG;AACH,MAAM,UAAU,OAAO,CAAC,IAAY;IAClC,OAAO,CACL,IAAI;SACD,WAAW,EAAE;SACb,OAAO,CAAC,oBAAoB,EAAE,EAAE,CAAC;SACjC,IAAI,EAAE;QACP,uEAAuE;QACvE,oEAAoE;SACnE,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CACvB,CAAC;AACJ,CAAC;AAKD;;;;;GAKG;AACH,MAAM,UAAU,eAAe,CAAC,MAAc;IAC5C,MAAM,GAAG,GAAi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AC,GAAG,QAAQ,CAAC,MAAM,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;YACtE,MAAM,SAAS,GAAG,QAAQ,CAAC,CAAC,CAAY,CAAC;YACzC,IAAI,SAAS,CAAC,KAAK,IAAI,OAAO,CAAC,KAAK;gBAAE,IAAI,GAAG,SAAS,CAAC;QACzD,CAAC;QACD,GAAG,CAAC,IAAI,CAAC;YACP,OAAO;YACP,KAAK,EAAE,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;YACpC,SAAS,EAAE,OAAO,CAAC,OAAO,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM;YACjG,GAAG,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;YAClE,OAAO,EAAE,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI;SAC9D,CAAC,CAAC;IACL,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,8EAA8E;AAC9E,MAAM,UAAU,OAAO,CAAC,IAAkB;IACxC,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC;AAClD,CAAC","sourcesContent":["/**\n * Headings, their GitHub anchors, and the sections they open.\n *\n * A heading is found in the structure mask, so one written in a code sample\n * or a comment is not one, and its text is read from the prose mask, so a\n * code span in it is kept and a comment after it is not.\n */\n\nimport { isMarkdown, isSpaceOrTab, visibleLead, type Layout } from './layout.js';\nimport { atxLevel, isThematicBreak, leadIndex, listMarker, setextUnderline } from './syntax.js';\nimport type { Heading, HeadingForm, HtmlComment, MarkdownScan, ScannedLine, Section, Table } from './types.js';\n\n/**\n * GitHub's slug of a heading's text: lower case, punctuation dropped, every\n * whitespace character a hyphen.\n *\n * spec-graph's slug, with two of its steps taken out because a later step\n * did their work: it dropped Markdown's punctuation and then all punctuation,\n * and trimmed before and after. What remains gives the same slug for every\n * text. It drops `_`, which GitHub keeps.\n */\nexport function slugify(text: string): string {\n return (\n text\n .toLowerCase()\n .replace(/[^\\p{L}\\p{N}\\s-]/gu, '')\n .trim()\n // GitHub hyphenates every whitespace character, so a run of two spaces\n // left behind by stripped punctuation becomes two hyphens, not one.\n .replace(/\\s/g, '-')\n );\n}\n\n/** A heading before GitHub's anchors are counted, which needs every heading. */\nexport type Unanchored = Omit<Heading, 'anchor'>;\n\n/**\n * ATX headings: `#` to `######` opening a line, after at most three spaces.\n *\n * Only a line whose first character is visible in the structure mask is read,\n * and the mask blanks every line of front matter, code and raw-text HTML.\n */\nexport function findAtxHeadings(layout: Layout): Unanchored[] {\n const out: Unanchored[] = [];\n const strip = commentStripper(layout);\n for (const line of layout.lines) {\n const level = atxLevel(line.content);\n if (level === 0 || !visibleLead(layout, line)) continue;\n const opened = line.contentStart + leadIndex(line.content) + level;\n const [textStart, textEnd] = atxText(layout.prose, opened, line.end);\n out.push(heading('atx', level, strip(textStart, textEnd), textStart, textEnd, line, line));\n }\n return out;\n}\n\n/**\n * The text of an ATX heading: trimmed, without a closing sequence. A closing\n * run of `#` counts only after a space or a tab, so `# C#` is about C#. The\n * character at `to` ends the line, and is not a space.\n */\nfunction atxText(prose: string, from: number, to: number): [number, number] {\n let start = from;\n while (isSpaceOrTab(prose, start)) start += 1;\n let end = to;\n while (end > start && isSpaceOrTab(prose, end - 1)) end -= 1;\n let hashes = end;\n while (hashes > start && prose.charCodeAt(hashes - 1) === 35) hashes -= 1;\n // Before a closing run there is the space it needs, or the space after the\n // opening run when the heading is nothing else.\n if (isSpaceOrTab(prose, hashes - 1)) {\n end = hashes;\n while (end > start && isSpaceOrTab(prose, end - 1)) end -= 1;\n }\n return [start, end];\n}\n\n/**\n * Every heading in order, ATX and setext, with GitHub's anchors.\n *\n * A setext heading is a paragraph line underlined with `=` or `-`. The line\n * above the underline must be one a paragraph can hold: not a heading, a list\n * item, a thematic break, a table row, blank, or indented four columns.\n * Otherwise `---` is a thematic break, and a table or a list followed by one\n * would gain a heading nobody wrote.\n */\nexport function findHeadings(layout: Layout, atx: readonly Unanchored[], tables: readonly Table[]): Heading[] {\n const { lines } = layout;\n const taken = new Set<number>();\n for (const h of atx) taken.add(h.line);\n for (const table of tables) for (let line = table.line; line <= table.endLine; line += 1) taken.add(line);\n\n const setext: Unanchored[] = [];\n const strip = commentStripper(layout);\n for (let i = 0; i + 1 < lines.length; i += 1) {\n const above = lines[i] as ScannedLine;\n const under = lines[i + 1]!;\n if (taken.has(above.line) || !paragraphLine(layout, above)) continue;\n if (!isMarkdown(under) || under.quoteDepth !== above.quoteDepth) continue;\n const mark = setextUnderline(under.content);\n if (mark === null || !visibleLead(layout, under)) continue;\n let textStart = above.contentStart;\n while (isSpaceOrTab(layout.prose, textStart)) textStart += 1;\n let textEnd = above.end;\n while (isSpaceOrTab(layout.prose, textEnd - 1)) textEnd -= 1;\n setext.push(heading('setext', mark === '=' ? 1 : 2, strip(textStart, textEnd), textStart, textEnd, above, under));\n // The underline is part of this heading, not the text of the next.\n i += 1;\n }\n\n const all = [...atx, ...setext].sort((a, b) => a.line - b.line);\n const occurrences = new Map<string, number>();\n return all.map((h) => ({ ...h, anchor: anchorOf(occurrences, h.slug) }));\n}\n\n/** A line that can be the text of a setext heading. */\nfunction paragraphLine(layout: Layout, line: ScannedLine): boolean {\n if (!isMarkdown(line) || line.blank || line.comment || line.indent >= 4) return false;\n return !(visibleLead(layout, line) && (listMarker(line.content) !== null || isThematicBreak(line.content)));\n}\n\n/**\n * GitHub's anchor for a slug: the slug itself the first time, then with `-1`,\n * `-2` and so on, skipping any suffixed form a heading already took.\n */\nfunction anchorOf(occurrences: Map<string, number>, slug: string): string {\n let anchor = slug;\n while (occurrences.has(anchor)) {\n const count = (occurrences.get(slug) as number) + 1;\n occurrences.set(slug, count);\n anchor = `${slug}-${count}`;\n }\n occurrences.set(anchor, 0);\n return anchor;\n}\n\nfunction heading(\n form: HeadingForm,\n level: number,\n text: string,\n textStart: number,\n textEnd: number,\n first: ScannedLine,\n last: ScannedLine,\n): Unanchored {\n return {\n form,\n level,\n text,\n slug: slugify(text),\n start: first.contentStart,\n end: last.end,\n textStart,\n textEnd,\n line: first.line,\n endLine: last.line,\n };\n}\n\n/**\n * The text between two offsets with the comments inside it taken out, as a\n * renderer shows it. Called with increasing offsets, so it walks the comments\n * once.\n */\nfunction commentStripper(layout: Layout): (start: number, end: number) => string {\n const { comments, text } = layout;\n let c = 0;\n return (start, end) => {\n let out = '';\n for (let at = start; at < end; at += 1) {\n while (c < comments.length && (comments[c] as HtmlComment).end <= at) c += 1;\n const comment = comments[c];\n if (comment === undefined || comment.start > at) out += text.charAt(at);\n }\n return out;\n };\n}\n\n/**\n * Each heading of `level` or deeper with everything under it, up to the next\n * heading at its level or above.\n */\nexport function sectionsOf(scan: MarkdownScan, level = 1): Section[] {\n const { headings, index, text } = scan;\n const out: Section[] = [];\n for (let h = 0; h < headings.length; h += 1) {\n const heading = headings[h] as Heading;\n if (heading.level < level) continue;\n let next: Heading | undefined;\n for (let k = h + 1; k < headings.length && next === undefined; k += 1) {\n const candidate = headings[k] as Heading;\n if (candidate.level <= heading.level) next = candidate;\n }\n out.push({\n heading,\n start: index.lineStart(heading.line),\n bodyStart: heading.endLine < index.lineCount ? index.lineStart(heading.endLine + 1) : text.length,\n end: next === undefined ? text.length : index.lineStart(next.line),\n endLine: next === undefined ? index.lineCount + 1 : next.line,\n });\n }\n return out;\n}\n\n/** The first level-one heading, which is what a reader takes as the title. */\nexport function titleOf(scan: MarkdownScan): Heading | undefined {\n return scan.headings.find((h) => h.level === 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oBACxC,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,EAAE,CAAW,CAAC;oBAClC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC;oBAClB,gEAAgE;oBAChE,gEAAgE;oBAChE,oDAAoD;oBACpD,EAAE,IAAI,CAAC,CAAC;gBACV,CAAC;qBAAM,CAAC;oBACN,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC;gBAChB,CAAC;YACH,CAAC;QACH,CAAC;QACD,KAAK,GAAG,IAAI,CAAC;IACf,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * Links, images and reference definitions, read from the structure mask so\n * that nothing in code or a comment is one.\n *\n * Six forms: inline `[text](dest \"title\")`, full and collapsed reference\n * `[text][label]` and `[label][]`, shortcut `[label]`, autolink `<https://x>`,\n * wiki `[[target|text]]`, and the definition `[label]: dest` the reference\n * forms are read through. Each may be an image, written with a leading `!`.\n * A link's text is read again for images, which CommonMark renders there - a\n * badge wrapped in a link has two destinations - and for nothing else; each\n * is listed after the link it lies in.\n *\n * Links may not contain links, as CommonMark has it: in\n * `[a [b](inner.md) c](outer.md)` the inner pair is the link, and the outer\n * brackets and `(outer.md)` are text. So before a paragraph is read its pairs\n * are read innermost first, as CommonMark reads them, to learn which `[`\n * holds a link at any depth.\n *\n * Brackets are paired once per paragraph with a stack, and the tables that\n * say where a destination or a title ends are built once per paragraph, so\n * no bracket searches the text again for its partner. A document of nothing\n * but brackets costs its length.\n *\n * A paragraph ends at `to`, and the character there is a line terminator,\n * which no loop here acts on; nor is any lookup made at the first three\n * offsets of a paragraph, before the shortest `[](` could end. Mutants that\n * move a bound onto those places change no answer, and are equivalent.\n */\n\nimport { inRanges, mergeRanges } from '../text/index.js';\nimport { isMarkdown, isSpaceOrTab, leadOffset, visibleLead, type Layout } from './layout.js';\nimport { atxLevel, isThematicBreak, listMarker } from './syntax.js';\nimport type { Heading, Link, ScannedLine } from './types.js';\n\nconst BANG = 33;\nconst DOUBLE_QUOTE = 34;\nconst SINGLE_QUOTE = 39;\nconst OPEN_PAREN = 40;\nconst CLOSE_PAREN = 41;\nconst LESS_THAN = 60;\nconst GREATER_THAN = 62;\nconst OPEN_BRACKET = 91;\nconst BACKSLASH = 92;\nconst CLOSE_BRACKET = 93;\nconst LF = 10;\nconst CR = 13;\n\n/** CommonMark: a link label holds at most 999 characters. */\nconst MAX_LABEL = 999;\n\n/**\n * A label holds no bracket but an escaped one. Its two alternatives never\n * start on the same character, so a label is read without backtracking.\n */\nconst DEFINITION = /^ {0,3}\\[(?!\\^)((?:[^[\\]\\\\]|\\\\.)+)\\]:[ \\t]*(<[^<>]*>|\\S+)/;\n/** What may follow a definition's destination: nothing, or a title after whitespace. */\nconst TITLE_ONLY = /^(?:[ \\t]+(?:\"[^\"]*\"|'[^']*'|\\([^)]*\\)))?[ \\t]*$/;\nconst AUTOLINK = /<((?:https?|ftp|mailto):[^<>\\s]+)>/g;\n\ninterface Definition {\n readonly target: string;\n readonly targetStart: number;\n readonly targetEnd: number;\n}\n\nexport function findLinks(layout: Layout, headings: readonly Heading[]): Link[] {\n const definitions = new Map<string, Definition>();\n const defined = readDefinitions(layout, headings, definitions);\n const bracketed = readBrackets(layout, definitions, new Set(defined.map((d) => d.line)));\n // `<https://x>` as a link's destination or text is part of that link.\n const taken = mergeRanges([...defined, ...bracketed]);\n const autolinks = readAutolinks(layout).filter((link) => !inRanges(taken, link.start));\n return [...defined, ...bracketed, ...autolinks].sort((a, b) => a.start - b.start);\n}\n\n/**\n * How labels compare: trimmed, whitespace collapsed, and case folded as\n * CommonMark's reference implementations fold it, down and then up, so that\n * `ẞ` and `SS` are one label.\n */\nfunction normalizeLabel(label: string): string {\n return label.trim().replace(/\\s+/g, ' ').toLowerCase().toUpperCase();\n}\n\n/**\n * Definitions come first: the reference forms are read through them, and a\n * definition is conventionally written at the foot of the file, after the\n * links that use it. The first definition of a label wins.\n *\n * `[Note]: this matters` is prose that looks like one, so a definition has\n * nothing after its destination but a title. `[^1]: text` is a footnote.\n *\n * A definition cannot interrupt a paragraph, as CommonMark has it: one\n * written on the line under a paragraph's text is that text. It opens a\n * paragraph, or follows a definition that did.\n */\nfunction readDefinitions(layout: Layout, headings: readonly Heading[], definitions: Map<string, Definition>): Link[] {\n const { text, structure, lines, continues } = layout;\n const closed = closingLines(layout, headings);\n const out: Link[] = [];\n for (const line of lines) {\n if (!isMarkdown(line) || !visibleLead(layout, line)) continue;\n const masked = structure.slice(line.contentStart, line.end);\n const match = DEFINITION.exec(masked);\n if (match === null || !TITLE_ONLY.test(masked.slice(match[0].length))) continue;\n // Under a definition the paragraph holds nothing else yet. `continues`\n // holds no first line, so there is a line above whenever it is asked about.\n const follows = out[out.length - 1]?.line === line.line - 1;\n if (!follows && continues.has(line.line) && paragraphOpen(lines[line.line - 2] as ScannedLine, closed)) continue;\n const between = (match[1] as string).length;\n const start = line.contentStart + match[0].indexOf('[');\n const label = text.slice(start + 1, start + 1 + between).trim();\n if (label.length === 0 || between > MAX_LABEL) continue;\n const written = match[2] as string;\n const end = line.contentStart + match[0].length;\n const angle = written.charCodeAt(0) === LESS_THAN ? 1 : 0;\n const targetStart = end - written.length + angle;\n const targetEnd = end - angle;\n const target = text.slice(targetStart, targetEnd);\n const key = normalizeLabel(label);\n if (!definitions.has(key)) definitions.set(key, { target, targetStart, targetEnd });\n out.push({ form: 'definition', image: false, text: label, target, label, start, end, targetStart, targetEnd, line: line.line });\n }\n return out;\n}\n\n/**\n * The lines after which no paragraph is open, though the line under one\n * would go on with a paragraph written there: the last line of a heading,\n * and of an HTML block a comment opens. Such a block starts where a comment\n * opens a line, after at most three columns, and ends on the line the\n * comment closes on.\n */\nfunction closingLines(layout: Layout, headings: readonly Heading[]): Set<number> {\n const closed = new Set<number>();\n for (const heading of headings) closed.add(heading.endLine);\n for (const comment of layout.comments) {\n const opened = layout.lines[comment.line - 1] as ScannedLine;\n if (opened.indent <= 3 && comment.start === leadOffset(opened)) closed.add(layout.index.positionAt(comment.end).line);\n }\n return closed;\n}\n\n/**\n * Whether a paragraph is open after a line, for the line under it to go on\n * with. None is after a blank line, code, a thematic break or a closing\n * line, and none is open in a list item whose marker has nothing after it,\n * or a heading or a thematic break.\n */\nfunction paragraphOpen(line: ScannedLine, closed: ReadonlySet<number>): boolean {\n if (!isMarkdown(line) || line.blank || closed.has(line.line) || isThematicBreak(line.content)) return false;\n const marker = listMarker(line.content);\n if (marker === null) return true;\n // The marker takes every space after it, so what is left is empty or text.\n const rest = line.content.slice(marker.offset + marker.width);\n return rest.length > 0 && atxLevel(rest) === 0 && !isThematicBreak(rest);\n}\n\nfunction readAutolinks(layout: Layout): Link[] {\n const out: Link[] = [];\n for (const match of layout.structure.matchAll(AUTOLINK)) {\n const start = match.index;\n const end = start + match[0].length;\n out.push({\n form: 'autolink',\n image: false,\n text: '',\n target: match[1] as string,\n label: null,\n start,\n end,\n targetStart: start + 1,\n targetEnd: end - 1,\n line: layout.index.positionAt(start).line,\n });\n }\n return out;\n}\n\n/** The brackets of a paragraph, `[` paired with `]` as a stack pairs them, escaped ones skipped. */\ninterface Brackets {\n /** Each `[` a `]` closes, to that `]`, in the order of the `]`s: every pair after the pairs inside it. */\n readonly pairs: Map<number, number>;\n /** Each paired `[` to the `[` still open around it, where there is one. */\n readonly outer: Map<number, number>;\n /** Each paired `[` to how many pairs had closed when it opened: the pairs wholly before it. */\n readonly before: Map<number, number>;\n /** Every `[` written after an unescaped `!`: an image's. */\n readonly images: Set<number>;\n /** Every `[` with a pair inside it: those whose text holds an unescaped bracket. */\n readonly nested: Set<number>;\n}\n\nfunction pairBrackets(structure: string, from: number, to: number): Brackets {\n const brackets: Brackets = { pairs: new Map(), outer: new Map(), before: new Map(), images: new Set(), nested: new Set() };\n const { pairs } = brackets;\n const open: { readonly at: number; readonly before: number }[] = [];\n let escaped = -1;\n for (let at = from; at < to; at += 1) {\n const ch = structure.charCodeAt(at);\n if (ch === BACKSLASH) {\n escaped = at + 1;\n at += 1;\n } else if (ch === OPEN_BRACKET) {\n open.push({ at, before: pairs.size });\n if (structure.charCodeAt(at - 1) === BANG && escaped !== at - 1) brackets.images.add(at);\n } else if (ch === CLOSE_BRACKET) {\n // A `]` with nothing to close pairs with nothing; recorded under\n // `undefined` it would not be found either, so this test changes no\n // answer, only what the maps hold.\n const opened = open.pop();\n if (opened !== undefined) {\n pairs.set(opened.at, at);\n brackets.before.set(opened.at, opened.before);\n const around = open[open.length - 1];\n if (around !== undefined) {\n brackets.outer.set(opened.at, around.at);\n brackets.nested.add(around.at);\n }\n }\n }\n }\n return brackets;\n}\n\n/**\n * For every offset of a paragraph, where what starts there ends, or the end\n * of the paragraph when nothing does: a bare destination at the next space or\n * control character, or at the first `)` its own parentheses leave unmatched;\n * a title at its next unescaped closing quote or parenthesis. Filled from the\n * right in one pass, so every lookup is a read.\n */\ninterface Ends {\n readonly space: Int32Array;\n readonly paren: Int32Array;\n readonly doubleQuote: Int32Array;\n readonly singleQuote: Int32Array;\n readonly closeParen: Int32Array;\n readonly openParen: Int32Array;\n}\n\nfunction endsOf(structure: string, from: number, to: number): Ends {\n const length = to - from;\n const escaped = new Uint8Array(length + 1);\n for (let x = 0; x < length; x += 1) {\n if (escaped[x] === 0 && structure.charCodeAt(from + x) === BACKSLASH) escaped[x + 1] = 1;\n }\n // Two past the last offset: a `(` whose `)` is the paragraph's last\n // character looks one further for the next unmatched `)`, and finds none.\n const make = (): Int32Array => new Int32Array(length + 2).fill(to);\n const ends: Ends = { space: make(), paren: make(), doubleQuote: make(), singleQuote: make(), closeParen: make(), openParen: make() };\n for (let x = length - 1; x >= 0; x -= 1) {\n const at = from + x;\n const ch = structure.charCodeAt(at);\n const plain = escaped[x] === 0;\n ends.space[x] = ch <= 32 || ch === 127 ? at : (ends.space[x + 1] as number);\n // From a `(`, the first unmatched `)` is the first one after the `)` that\n // closes it, which is the first unmatched `)` after the `(`.\n const unmatched = ends.paren[x + 1] as number;\n if (plain && ch === CLOSE_PAREN) ends.paren[x] = at;\n else if (plain && ch === OPEN_PAREN) ends.paren[x] = ends.paren[unmatched + 1 - from] as number;\n else ends.paren[x] = unmatched;\n ends.doubleQuote[x] = plain && ch === DOUBLE_QUOTE ? at : (ends.doubleQuote[x + 1] as number);\n ends.singleQuote[x] = plain && ch === SINGLE_QUOTE ? at : (ends.singleQuote[x + 1] as number);\n ends.closeParen[x] = plain && ch === CLOSE_PAREN ? at : (ends.closeParen[x + 1] as number);\n ends.openParen[x] = plain && ch === OPEN_PAREN ? at : (ends.openParen[x + 1] as number);\n }\n return ends;\n}\n\ninterface Destination {\n readonly targetStart: number;\n readonly targetEnd: number;\n /** Offset just past the closing `)`. */\n readonly end: number;\n}\n\n/**\n * The bracket forms, a paragraph at a time. A paragraph here is a run of\n * Markdown lines, none blank or a definition, each continuing the one above:\n * a bracket never pairs across a blank line, a heading, a definition, or the\n * start of another block.\n */\nfunction readBrackets(layout: Layout, definitions: ReadonlyMap<string, Definition>, defined: ReadonlySet<number>): Link[] {\n const { lines, continues, structure, text } = layout;\n const out: Link[] = [];\n // The first `]]` at or after the last place one was looked for; the cursor\n // only moves forward, so each is found once.\n let doubleClose = -2;\n\n const lookup = (from: number, to: number): Definition | undefined =>\n to - from > MAX_LABEL ? undefined : definitions.get(normalizeLabel(text.slice(from, to)));\n\n // A blank or code line let into a paragraph would bring only characters the\n // structure mask blanks, so those two tests shape the runs and change no\n // link. A definition's line is no paragraph's: it holds a label, a\n // destination and a title, none of them a link, and the text after it is a\n // paragraph of its own, whose brackets pair with nothing before it. Past\n // the last line there is no line, and `continues` holds nothing there, so\n // no run reaches past it: the loop below could take one step more, and the\n // test for a line that is not there could go.\n const inParagraph = (i: number): boolean => {\n const line = lines[i];\n return line !== undefined && isMarkdown(line) && !line.blank && !defined.has(i + 1);\n };\n\n for (let first = 0; first < lines.length; first += 1) {\n if (!inParagraph(first)) continue;\n let last = first;\n while (inParagraph(last + 1) && continues.has(last + 2)) last += 1;\n const from = (lines[first] as ScannedLine).start;\n const to = (lines[last] as ScannedLine).end;\n const brackets = pairBrackets(structure, from, to);\n const { pairs } = brackets;\n // Each `[` with a link inside it, at any depth.\n const holding = new Set<number>();\n let ends: Ends | null = null;\n\n // Spaces and tabs, and at most one line ending inside the paragraph. The\n // character at `to` ends the paragraph's last line and is none of these.\n const skipSpace = (start: number): number => {\n let at = start;\n while (isSpaceOrTab(structure, at)) at += 1;\n if (at < to) {\n if (structure.charCodeAt(at) === CR) at += 1;\n if (structure.charCodeAt(at) === LF) at += 1;\n while (isSpaceOrTab(structure, at)) at += 1;\n }\n return at;\n };\n\n const destination = (open: number): Destination | null => {\n const at = skipSpace(open);\n let targetStart: number;\n let targetEnd: number;\n let after: number;\n if (structure.charCodeAt(at) === LESS_THAN) {\n // `<dest>`: no line ending and no unescaped `<` inside.\n let close = at + 1;\n for (;;) {\n if (close >= to) return null;\n const ch = structure.charCodeAt(close);\n if (ch === GREATER_THAN) break;\n if (ch === LESS_THAN || ch === LF || ch === CR) return null;\n close += ch === BACKSLASH ? 2 : 1;\n }\n targetStart = at + 1;\n targetEnd = close;\n after = close + 1;\n } else {\n ends ??= endsOf(structure, from, to);\n const space = ends.space[at - from] as number;\n const paren = ends.paren[at - from] as number;\n targetStart = at;\n // The two are equal only when neither is found, at `to`.\n targetEnd = paren < space ? paren : space;\n after = targetEnd;\n // An empty destination points nowhere a reader can follow.\n if (targetEnd === at) return null;\n }\n let k = skipSpace(after);\n if (structure.charCodeAt(k) === CLOSE_PAREN) return { targetStart, targetEnd, end: k + 1 };\n // A title is separated from the destination by whitespace, and quoted.\n if (k === after) return null;\n ends ??= endsOf(structure, from, to);\n const x = k + 1 - from;\n const quote = structure.charCodeAt(k);\n let close: number;\n if (quote === DOUBLE_QUOTE) close = ends.doubleQuote[x] as number;\n else if (quote === SINGLE_QUOTE) close = ends.singleQuote[x] as number;\n // A title in parentheses may not hold an unescaped `(`.\n else if (quote === OPEN_PAREN) close = (ends.openParen[x] as number) < (ends.closeParen[x] as number) ? to : (ends.closeParen[x] as number);\n else return null;\n // Equal ends are `to`, where the title fails either way. Past `to` the\n // next line opens a block of its own, and none opens with `)`.\n if (close === to) return null;\n k = skipSpace(close + 1);\n return structure.charCodeAt(k) === CLOSE_PAREN ? { targetStart, targetEnd, end: k + 1 } : null;\n };\n\n const wiki = (at: number, start: number, image: boolean, line: ScannedLine): Link | null => {\n if (structure.charCodeAt(at + 1) !== OPEN_BRACKET) return null;\n if (doubleClose !== -1 && doubleClose < at + 2) doubleClose = structure.indexOf(']]', at + 2);\n const close = doubleClose;\n if (close < 0 || close + 2 > line.end) return null;\n const inner = text.slice(at + 2, close);\n const written = inner.trim();\n const pipe = written.indexOf('|');\n const target = (pipe < 0 ? written : written.slice(0, pipe)).trim();\n // `[[ ]]` and `[[|text]]` name nothing to link to.\n if (target.length === 0) return null;\n const targetStart = at + 2 + inner.length - inner.trimStart().length;\n return {\n form: 'wiki',\n image,\n text: written,\n target,\n label: null,\n start,\n end: close + 2,\n targetStart,\n targetEnd: targetStart + target.length,\n line: line.line,\n };\n };\n\n const bracket = (at: number, start: number, image: boolean, line: ScannedLine): Link | null => {\n const close = pairs.get(at);\n // A link holding a link is text; an image holding one is still an image.\n if (close === undefined || (!image && holding.has(at))) return null;\n const label = (): string => text.slice(at + 1, close).trim();\n if (structure.charCodeAt(close + 1) === OPEN_PAREN) {\n const dest = destination(close + 2);\n if (dest !== null) {\n const target = text.slice(dest.targetStart, dest.targetEnd);\n return { form: 'inline', image, text: label(), target, label: null, start, line: line.line, ...dest };\n }\n } else {\n // Only a `[` is paired, so a second bracket follows exactly when this\n // finds one. It is a label unless it holds a bracket, which it does\n // when a pair lies inside it, or more than 999 characters; one that is\n // not leaves the first bracket to be read as a shortcut.\n const refClose = pairs.get(close + 1);\n // With no second bracket the length is NaN and the comparison false,\n // so the first test only narrows the type.\n if (refClose !== undefined && refClose - close - 2 <= MAX_LABEL && !brackets.nested.has(close + 1)) {\n // `[text][]` is read through its text; `[text][label]` through its label.\n const collapsed = text.slice(close + 2, refClose).trim() === '';\n const found = collapsed ? lookup(at + 1, close) : lookup(close + 2, refClose);\n if (found === undefined) return null;\n const written = collapsed ? label() : text.slice(close + 2, refClose).trim();\n return { form: 'reference', image, text: label(), label: written, start, end: refClose + 1, line: line.line, ...found };\n }\n }\n // `[text](not a destination)` is a shortcut followed by text, as CommonMark reads it.\n const found = lookup(at + 1, close);\n if (found === undefined) return null;\n return { form: 'shortcut', image, text: label(), label: label(), start, end: close + 1, line: line.line, ...found };\n };\n\n const lineAt = (at: number): ScannedLine => lines[layout.index.positionAt(at).line - 1] as ScannedLine;\n\n // CommonMark reads each pair at its `]`, so the pairs inside a `[` are\n // read before it, and a link among them makes it text, and every `[`\n // open around it: the pairs come innermost first, and fill `holding` on\n // the way out. An image among them does not; a link may hold one. What a\n // link or an image reads past its `]` - a destination, a title, a second\n // label - is not read for links again: `reach` is the furthest any of the\n // first so many pairs read to, and a `[` short of it opens nothing.\n const reach = [from];\n for (const at of pairs.keys()) {\n const line = lineAt(at);\n const image = brackets.images.has(at);\n const passed = (reach[brackets.before.get(at) as number] as number) > at;\n const link = passed ? null : bracket(at, at, image, line);\n reach.push(Math.max(reach[reach.length - 1] as number, link === null ? from : link.end));\n const around = brackets.outer.get(at);\n // `holding` is asked only about offsets, so the first test only\n // narrows the type.\n if (around !== undefined && (holding.has(at) || (link !== null && !image))) holding.add(around);\n }\n\n let at = from;\n // Inside a link's text, up to its `]`, where CommonMark reads an image -\n // a badge wrapped in a link - but no other link; then on past the link.\n // `textEnd` is -1 or a `]` that closes a `[`, so never 0, and the `]` is\n // read as no link. Leaving one step later, past it, resumes at the same\n // place, or ends the paragraph where a shortcut link ended it anyway: the\n // test below reads the same with `textEnd > 0` or `at > textEnd`, and so\n // does the one further into the loop with `textEnd > 0`. `resume` is read\n // only while `textEnd` is set, and the two are set together, so its first\n // value is never read.\n let textEnd = -1;\n let resume = -1;\n while (at < to) {\n if (textEnd >= 0 && at >= textEnd) {\n at = resume;\n textEnd = -1;\n continue;\n }\n const ch = structure.charCodeAt(at);\n if (ch === BACKSLASH) {\n at += 2;\n continue;\n }\n if (ch !== OPEN_BRACKET) {\n at += 1;\n continue;\n }\n const line = lineAt(at);\n const image = brackets.images.has(at);\n const start = image ? at - 1 : at;\n const link = wiki(at, start, image, line) ?? bracket(at, start, image, line);\n if (textEnd >= 0) {\n // An image that closes inside the text; its own text is alt text, and\n // holds nothing a reader follows.\n if (link !== null && link.image && link.form !== 'wiki' && link.end <= textEnd) {\n out.push(link);\n at = link.end;\n } else {\n at += 1;\n }\n } else if (link === null) {\n at += 1;\n } else {\n out.push(link);\n if (!link.image && link.form !== 'wiki') {\n textEnd = pairs.get(at) as number;\n resume = link.end;\n // Into the text. A step back instead reads the character before\n // the `[`, which opens nothing there - it opened no link before\n // this one, or it is escaped - and comes back here.\n at += 1;\n } else {\n at = link.end;\n }\n }\n }\n first = last;\n }\n return out;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"links.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/markdown/links.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAe,MAAM,aAAa,CAAC;AAC7F,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGpE,MAAM,IAAI,GAAG,EAAE,CAAC;AAChB,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,UAAU,GAAG,EAAE,CAAC;AACtB,MAAM,WAAW,GAAG,EAAE,CAAC;AACvB,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,SAAS,GAAG,EAAE,CAAC;AACrB,MAA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KAAK,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,GAAG,IAAI,OAAO,EAAE,CAAC;oBAC/E,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;oBACf,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC;gBAChB,CAAC;qBAAM,CAAC;oBACN,EAAE,IAAI,CAAC,CAAC;gBACV,CAAC;YACH,CAAC;iBAAM,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;gBACzB,EAAE,IAAI,CAAC,CAAC;YACV,CAAC;iBAAM,CAAC;gBACN,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACf,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;oBACxC,OAAO,GAAG,KAAK,CAAC,GAAG,CAAC,EAAE,CAAW,CAAC;oBAClC,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC;oBAClB,gEAAgE;oBAChE,gEAAgE;oBAChE,oDAAoD;oBACpD,EAAE,IAAI,CAAC,CAAC;gBACV,CAAC;qBAAM,CAAC;oBACN,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC;gBAChB,CAAC;YACH,CAAC;QACH,CAAC;QACD,KAAK,GAAG,IAAI,CAAC;IACf,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["/**\n * Links, images and reference definitions, read from the structure mask so\n * that nothing in code or a comment is one.\n *\n * Six forms: inline `[text](dest \"title\")`, full and collapsed reference\n * `[text][label]` and `[label][]`, shortcut `[label]`, autolink `<https://x>`,\n * wiki `[[target|text]]`, and the definition `[label]: dest` the reference\n * forms are read through. Each may be an image, written with a leading `!`.\n * A link's text is read again for images, which CommonMark renders there - a\n * badge wrapped in a link has two destinations - and for nothing else; each\n * is listed after the link it lies in.\n *\n * Links may not contain links, as CommonMark has it: in\n * `[a [b](inner.md) c](outer.md)` the inner pair is the link, and the outer\n * brackets and `(outer.md)` are text. So before a paragraph is read its pairs\n * are read innermost first, as CommonMark reads them, to learn which `[`\n * holds a link at any depth.\n *\n * Brackets are paired once per paragraph with a stack, and the tables that\n * say where a destination or a title ends are built once per paragraph, so\n * no bracket searches the text again for its partner. A document of nothing\n * but brackets costs its length.\n *\n * A paragraph ends at `to`, and the character there is a line terminator,\n * which no loop here acts on; nor is any lookup made at the first three\n * offsets of a paragraph, before the shortest `[](` could end. Mutants that\n * move a bound onto those places change no answer, and are equivalent.\n */\n\nimport { inRanges, mergeRanges } from '../text/index.js';\nimport { isMarkdown, isSpaceOrTab, leadOffset, visibleLead, type Layout } from './layout.js';\nimport { atxLevel, isThematicBreak, listMarker } from './syntax.js';\nimport type { Heading, Link, ScannedLine } from './types.js';\n\nconst BANG = 33;\nconst DOUBLE_QUOTE = 34;\nconst SINGLE_QUOTE = 39;\nconst OPEN_PAREN = 40;\nconst CLOSE_PAREN = 41;\nconst LESS_THAN = 60;\nconst GREATER_THAN = 62;\nconst OPEN_BRACKET = 91;\nconst BACKSLASH = 92;\nconst CLOSE_BRACKET = 93;\nconst LF = 10;\nconst CR = 13;\n\n/** CommonMark: a link label holds at most 999 characters. */\nconst MAX_LABEL = 999;\n\n/**\n * A label holds no bracket but an escaped one. Its two alternatives never\n * start on the same character, so a label is read without backtracking.\n */\nconst DEFINITION = /^ {0,3}\\[(?!\\^)((?:[^[\\]\\\\]|\\\\.)+)\\]:[ \\t]*(<[^<>]*>|\\S+)/;\n/** What may follow a definition's destination: nothing, or a title after whitespace. */\nconst TITLE_ONLY = /^(?:[ \\t]+(?:\"[^\"]*\"|'[^']*'|\\([^)]*\\)))?[ \\t]*$/;\nconst AUTOLINK = /<((?:https?|ftp|mailto):[^<>\\s]+)>/g;\n\ninterface Definition {\n readonly target: string;\n readonly targetStart: number;\n readonly targetEnd: number;\n}\n\nexport function findLinks(layout: Layout, headings: readonly Heading[]): Link[] {\n const definitions = new Map<string, Definition>();\n const defined = readDefinitions(layout, headings, definitions);\n const bracketed = readBrackets(layout, definitions, new Set(defined.map((d) => d.line)));\n // `<https://x>` as a link's destination or text is part of that link.\n const taken = mergeRanges([...defined, ...bracketed]);\n const autolinks = readAutolinks(layout).filter((link) => !inRanges(taken, link.start));\n return [...defined, ...bracketed, ...autolinks].sort((a, b) => a.start - b.start);\n}\n\n/**\n * How labels compare: trimmed, whitespace collapsed, and case folded as\n * CommonMark's reference implementations fold it, down and then up, so that\n * `ẞ` and `SS` are one label.\n */\nfunction normalizeLabel(label: string): string {\n return label.trim().replace(/\\s+/g, ' ').toLowerCase().toUpperCase();\n}\n\n/**\n * Definitions come first: the reference forms are read through them, and a\n * definition is conventionally written at the foot of the file, after the\n * links that use it. The first definition of a label wins.\n *\n * `[Note]: this matters` is prose that looks like one, so a definition has\n * nothing after its destination but a title. `[^1]: text` is a footnote.\n *\n * A definition cannot interrupt a paragraph, as CommonMark has it: one\n * written on the line under a paragraph's text is that text. It opens a\n * paragraph, or follows a definition that did.\n */\nfunction readDefinitions(layout: Layout, headings: readonly Heading[], definitions: Map<string, Definition>): Link[] {\n const { text, structure, lines, continues } = layout;\n const closed = closingLines(layout, headings);\n const out: Link[] = [];\n for (const line of lines) {\n if (!isMarkdown(line) || !visibleLead(layout, line)) continue;\n const masked = structure.slice(line.contentStart, line.end);\n const match = DEFINITION.exec(masked);\n if (match === null || !TITLE_ONLY.test(masked.slice(match[0].length))) continue;\n // Under a definition the paragraph holds nothing else yet. `continues`\n // holds no first line, so there is a line above whenever it is asked about.\n const follows = out[out.length - 1]?.line === line.line - 1;\n if (!follows && continues.has(line.line) && paragraphOpen(lines[line.line - 2]!, closed)) continue;\n const between = (match[1] as string).length;\n const start = line.contentStart + match[0].indexOf('[');\n const label = text.slice(start + 1, start + 1 + between).trim();\n if (label.length === 0 || between > MAX_LABEL) continue;\n const written = match[2] as string;\n const end = line.contentStart + match[0].length;\n const angle = written.charCodeAt(0) === LESS_THAN ? 1 : 0;\n const targetStart = end - written.length + angle;\n const targetEnd = end - angle;\n const target = text.slice(targetStart, targetEnd);\n const key = normalizeLabel(label);\n if (!definitions.has(key)) definitions.set(key, { target, targetStart, targetEnd });\n out.push({ form: 'definition', image: false, text: label, target, label, start, end, targetStart, targetEnd, line: line.line });\n }\n return out;\n}\n\n/**\n * The lines after which no paragraph is open, though the line under one\n * would go on with a paragraph written there: the last line of a heading,\n * and of an HTML block a comment opens. Such a block starts where a comment\n * opens a line, after at most three columns, and ends on the line the\n * comment closes on.\n */\nfunction closingLines(layout: Layout, headings: readonly Heading[]): Set<number> {\n const closed = new Set<number>();\n for (const heading of headings) closed.add(heading.endLine);\n for (const comment of layout.comments) {\n const opened = layout.lines[comment.line - 1]!;\n if (opened.indent <= 3 && comment.start === leadOffset(opened)) closed.add(layout.index.positionAt(comment.end).line);\n }\n return closed;\n}\n\n/**\n * Whether a paragraph is open after a line, for the line under it to go on\n * with. None is after a blank line, code, a thematic break or a closing\n * line, and none is open in a list item whose marker has nothing after it,\n * or a heading or a thematic break.\n */\nfunction paragraphOpen(line: ScannedLine, closed: ReadonlySet<number>): boolean {\n if (!isMarkdown(line) || line.blank || closed.has(line.line) || isThematicBreak(line.content)) return false;\n const marker = listMarker(line.content);\n if (marker === null) return true;\n // The marker takes every space after it, so what is left is empty or text.\n const rest = line.content.slice(marker.offset + marker.width);\n return rest.length > 0 && atxLevel(rest) === 0 && !isThematicBreak(rest);\n}\n\nfunction readAutolinks(layout: Layout): Link[] {\n const out: Link[] = [];\n for (const match of layout.structure.matchAll(AUTOLINK)) {\n const start = match.index;\n const end = start + match[0].length;\n out.push({\n form: 'autolink',\n image: false,\n text: '',\n target: match[1] as string,\n label: null,\n start,\n end,\n targetStart: start + 1,\n targetEnd: end - 1,\n line: layout.index.positionAt(start).line,\n });\n }\n return out;\n}\n\n/** The brackets of a paragraph, `[` paired with `]` as a stack pairs them, escaped ones skipped. */\ninterface Brackets {\n /** Each `[` a `]` closes, to that `]`, in the order of the `]`s: every pair after the pairs inside it. */\n readonly pairs: Map<number, number>;\n /** Each paired `[` to the `[` still open around it, where there is one. */\n readonly outer: Map<number, number>;\n /** Each paired `[` to how many pairs had closed when it opened: the pairs wholly before it. */\n readonly before: Map<number, number>;\n /** Every `[` written after an unescaped `!`: an image's. */\n readonly images: Set<number>;\n /** Every `[` with a pair inside it: those whose text holds an unescaped bracket. */\n readonly nested: Set<number>;\n}\n\nfunction pairBrackets(structure: string, from: number, to: number): Brackets {\n const brackets: Brackets = { pairs: new Map(), outer: new Map(), before: new Map(), images: new Set(), nested: new Set() };\n const { pairs } = brackets;\n const open: { readonly at: number; readonly before: number }[] = [];\n let escaped = -1;\n for (let at = from; at < to; at += 1) {\n const ch = structure.charCodeAt(at);\n if (ch === BACKSLASH) {\n escaped = at + 1;\n at += 1;\n } else if (ch === OPEN_BRACKET) {\n open.push({ at, before: pairs.size });\n if (structure.charCodeAt(at - 1) === BANG && escaped !== at - 1) brackets.images.add(at);\n } else if (ch === CLOSE_BRACKET) {\n // A `]` with nothing to close pairs with nothing; recorded under\n // `undefined` it would not be found either, so this test changes no\n // answer, only what the maps hold.\n const opened = open.pop();\n if (opened !== undefined) {\n pairs.set(opened.at, at);\n brackets.before.set(opened.at, opened.before);\n const around = open[open.length - 1];\n if (around !== undefined) {\n brackets.outer.set(opened.at, around.at);\n brackets.nested.add(around.at);\n }\n }\n }\n }\n return brackets;\n}\n\n/**\n * For every offset of a paragraph, where what starts there ends, or the end\n * of the paragraph when nothing does: a bare destination at the next space or\n * control character, or at the first `)` its own parentheses leave unmatched;\n * a title at its next unescaped closing quote or parenthesis. Filled from the\n * right in one pass, so every lookup is a read.\n */\ninterface Ends {\n readonly space: Int32Array;\n readonly paren: Int32Array;\n readonly doubleQuote: Int32Array;\n readonly singleQuote: Int32Array;\n readonly closeParen: Int32Array;\n readonly openParen: Int32Array;\n}\n\nfunction endsOf(structure: string, from: number, to: number): Ends {\n const length = to - from;\n const escaped = new Uint8Array(length + 1);\n for (let x = 0; x < length; x += 1) {\n if (escaped[x] === 0 && structure.charCodeAt(from + x) === BACKSLASH) escaped[x + 1] = 1;\n }\n // Two past the last offset: a `(` whose `)` is the paragraph's last\n // character looks one further for the next unmatched `)`, and finds none.\n const make = (): Int32Array => new Int32Array(length + 2).fill(to);\n const ends: Ends = { space: make(), paren: make(), doubleQuote: make(), singleQuote: make(), closeParen: make(), openParen: make() };\n for (let x = length - 1; x >= 0; x -= 1) {\n const at = from + x;\n const ch = structure.charCodeAt(at);\n const plain = escaped[x] === 0;\n ends.space[x] = ch <= 32 || ch === 127 ? at : ends.space[x + 1]!;\n // From a `(`, the first unmatched `)` is the first one after the `)` that\n // closes it, which is the first unmatched `)` after the `(`.\n const unmatched = ends.paren[x + 1]!;\n if (plain && ch === CLOSE_PAREN) ends.paren[x] = at;\n else if (plain && ch === OPEN_PAREN) ends.paren[x] = ends.paren[unmatched + 1 - from]!;\n else ends.paren[x] = unmatched;\n ends.doubleQuote[x] = plain && ch === DOUBLE_QUOTE ? at : ends.doubleQuote[x + 1]!;\n ends.singleQuote[x] = plain && ch === SINGLE_QUOTE ? at : ends.singleQuote[x + 1]!;\n ends.closeParen[x] = plain && ch === CLOSE_PAREN ? at : ends.closeParen[x + 1]!;\n ends.openParen[x] = plain && ch === OPEN_PAREN ? at : ends.openParen[x + 1]!;\n }\n return ends;\n}\n\ninterface Destination {\n readonly targetStart: number;\n readonly targetEnd: number;\n /** Offset just past the closing `)`. */\n readonly end: number;\n}\n\n/**\n * The bracket forms, a paragraph at a time. A paragraph here is a run of\n * Markdown lines, none blank or a definition, each continuing the one above:\n * a bracket never pairs across a blank line, a heading, a definition, or the\n * start of another block.\n */\nfunction readBrackets(layout: Layout, definitions: ReadonlyMap<string, Definition>, defined: ReadonlySet<number>): Link[] {\n const { lines, continues, structure, text } = layout;\n const out: Link[] = [];\n // The first `]]` at or after the last place one was looked for; the cursor\n // only moves forward, so each is found once.\n let doubleClose = -2;\n\n const lookup = (from: number, to: number): Definition | undefined =>\n to - from > MAX_LABEL ? undefined : definitions.get(normalizeLabel(text.slice(from, to)));\n\n // A blank or code line let into a paragraph would bring only characters the\n // structure mask blanks, so those two tests shape the runs and change no\n // link. A definition's line is no paragraph's: it holds a label, a\n // destination and a title, none of them a link, and the text after it is a\n // paragraph of its own, whose brackets pair with nothing before it. Past\n // the last line there is no line, and `continues` holds nothing there, so\n // no run reaches past it: the loop below could take one step more, and the\n // test for a line that is not there could go.\n const inParagraph = (i: number): boolean => {\n const line = lines[i];\n return line !== undefined && isMarkdown(line) && !line.blank && !defined.has(i + 1);\n };\n\n for (let first = 0; first < lines.length; first += 1) {\n if (!inParagraph(first)) continue;\n let last = first;\n while (inParagraph(last + 1) && continues.has(last + 2)) last += 1;\n const from = (lines[first] as ScannedLine).start;\n const to = (lines[last] as ScannedLine).end;\n const brackets = pairBrackets(structure, from, to);\n const { pairs } = brackets;\n // Each `[` with a link inside it, at any depth.\n const holding = new Set<number>();\n let ends: Ends | null = null;\n\n // Spaces and tabs, and at most one line ending inside the paragraph. The\n // character at `to` ends the paragraph's last line and is none of these.\n const skipSpace = (start: number): number => {\n let at = start;\n while (isSpaceOrTab(structure, at)) at += 1;\n if (at < to) {\n if (structure.charCodeAt(at) === CR) at += 1;\n if (structure.charCodeAt(at) === LF) at += 1;\n while (isSpaceOrTab(structure, at)) at += 1;\n }\n return at;\n };\n\n const destination = (open: number): Destination | null => {\n const at = skipSpace(open);\n let targetStart: number;\n let targetEnd: number;\n let after: number;\n if (structure.charCodeAt(at) === LESS_THAN) {\n // `<dest>`: no line ending and no unescaped `<` inside.\n let close = at + 1;\n for (;;) {\n if (close >= to) return null;\n const ch = structure.charCodeAt(close);\n if (ch === GREATER_THAN) break;\n if (ch === LESS_THAN || ch === LF || ch === CR) return null;\n close += ch === BACKSLASH ? 2 : 1;\n }\n targetStart = at + 1;\n targetEnd = close;\n after = close + 1;\n } else {\n ends ??= endsOf(structure, from, to);\n const space = ends.space[at - from]!;\n const paren = ends.paren[at - from]!;\n targetStart = at;\n // The two are equal only when neither is found, at `to`.\n targetEnd = paren < space ? paren : space;\n after = targetEnd;\n // An empty destination points nowhere a reader can follow.\n if (targetEnd === at) return null;\n }\n let k = skipSpace(after);\n if (structure.charCodeAt(k) === CLOSE_PAREN) return { targetStart, targetEnd, end: k + 1 };\n // A title is separated from the destination by whitespace, and quoted.\n if (k === after) return null;\n ends ??= endsOf(structure, from, to);\n const x = k + 1 - from;\n const quote = structure.charCodeAt(k);\n let close: number;\n if (quote === DOUBLE_QUOTE) close = ends.doubleQuote[x] as number;\n else if (quote === SINGLE_QUOTE) close = ends.singleQuote[x] as number;\n // A title in parentheses may not hold an unescaped `(`.\n else if (quote === OPEN_PAREN) close = (ends.openParen[x] as number) < (ends.closeParen[x] as number) ? to : (ends.closeParen[x] as number);\n else return null;\n // Equal ends are `to`, where the title fails either way. Past `to` the\n // next line opens a block of its own, and none opens with `)`.\n if (close === to) return null;\n k = skipSpace(close + 1);\n return structure.charCodeAt(k) === CLOSE_PAREN ? { targetStart, targetEnd, end: k + 1 } : null;\n };\n\n const wiki = (at: number, start: number, image: boolean, line: ScannedLine): Link | null => {\n if (structure.charCodeAt(at + 1) !== OPEN_BRACKET) return null;\n if (doubleClose !== -1 && doubleClose < at + 2) doubleClose = structure.indexOf(']]', at + 2);\n const close = doubleClose;\n if (close < 0 || close + 2 > line.end) return null;\n const inner = text.slice(at + 2, close);\n const written = inner.trim();\n const pipe = written.indexOf('|');\n const target = (pipe < 0 ? written : written.slice(0, pipe)).trim();\n // `[[ ]]` and `[[|text]]` name nothing to link to.\n if (target.length === 0) return null;\n const targetStart = at + 2 + inner.length - inner.trimStart().length;\n return {\n form: 'wiki',\n image,\n text: written,\n target,\n label: null,\n start,\n end: close + 2,\n targetStart,\n targetEnd: targetStart + target.length,\n line: line.line,\n };\n };\n\n const bracket = (at: number, start: number, image: boolean, line: ScannedLine): Link | null => {\n const close = pairs.get(at);\n // A link holding a link is text; an image holding one is still an image.\n if (close === undefined || (!image && holding.has(at))) return null;\n const label = (): string => text.slice(at + 1, close).trim();\n if (structure.charCodeAt(close + 1) === OPEN_PAREN) {\n const dest = destination(close + 2);\n if (dest !== null) {\n const target = text.slice(dest.targetStart, dest.targetEnd);\n return { form: 'inline', image, text: label(), target, label: null, start, line: line.line, ...dest };\n }\n } else {\n // Only a `[` is paired, so a second bracket follows exactly when this\n // finds one. It is a label unless it holds a bracket, which it does\n // when a pair lies inside it, or more than 999 characters; one that is\n // not leaves the first bracket to be read as a shortcut.\n const refClose = pairs.get(close + 1);\n // With no second bracket the length is NaN and the comparison false,\n // so the first test only narrows the type.\n if (refClose !== undefined && refClose - close - 2 <= MAX_LABEL && !brackets.nested.has(close + 1)) {\n // `[text][]` is read through its text; `[text][label]` through its label.\n const collapsed = text.slice(close + 2, refClose).trim() === '';\n const found = collapsed ? lookup(at + 1, close) : lookup(close + 2, refClose);\n if (found === undefined) return null;\n const written = collapsed ? label() : text.slice(close + 2, refClose).trim();\n return { form: 'reference', image, text: label(), label: written, start, end: refClose + 1, line: line.line, ...found };\n }\n }\n // `[text](not a destination)` is a shortcut followed by text, as CommonMark reads it.\n const found = lookup(at + 1, close);\n if (found === undefined) return null;\n return { form: 'shortcut', image, text: label(), label: label(), start, end: close + 1, line: line.line, ...found };\n };\n\n const lineAt = (at: number): ScannedLine => lines[layout.index.positionAt(at).line - 1]!;\n\n // CommonMark reads each pair at its `]`, so the pairs inside a `[` are\n // read before it, and a link among them makes it text, and every `[`\n // open around it: the pairs come innermost first, and fill `holding` on\n // the way out. An image among them does not; a link may hold one. What a\n // link or an image reads past its `]` - a destination, a title, a second\n // label - is not read for links again: `reach` is the furthest any of the\n // first so many pairs read to, and a `[` short of it opens nothing.\n const reach = [from];\n for (const at of pairs.keys()) {\n const line = lineAt(at);\n const image = brackets.images.has(at);\n const passed = (reach[brackets.before.get(at) as number] as number) > at;\n const link = passed ? null : bracket(at, at, image, line);\n reach.push(Math.max(reach[reach.length - 1]!, link === null ? from : link.end));\n const around = brackets.outer.get(at);\n // `holding` is asked only about offsets, so the first test only\n // narrows the type.\n if (around !== undefined && (holding.has(at) || (link !== null && !image))) holding.add(around);\n }\n\n let at = from;\n // Inside a link's text, up to its `]`, where CommonMark reads an image -\n // a badge wrapped in a link - but no other link; then on past the link.\n // `textEnd` is -1 or a `]` that closes a `[`, so never 0, and the `]` is\n // read as no link. Leaving one step later, past it, resumes at the same\n // place, or ends the paragraph where a shortcut link ended it anyway: the\n // test below reads the same with `textEnd > 0` or `at > textEnd`, and so\n // does the one further into the loop with `textEnd > 0`. `resume` is read\n // only while `textEnd` is set, and the two are set together, so its first\n // value is never read.\n let textEnd = -1;\n let resume = -1;\n while (at < to) {\n if (textEnd >= 0 && at >= textEnd) {\n at = resume;\n textEnd = -1;\n continue;\n }\n const ch = structure.charCodeAt(at);\n if (ch === BACKSLASH) {\n at += 2;\n continue;\n }\n if (ch !== OPEN_BRACKET) {\n at += 1;\n continue;\n }\n const line = lineAt(at);\n const image = brackets.images.has(at);\n const start = image ? at - 1 : at;\n const link = wiki(at, start, image, line) ?? bracket(at, start, image, line);\n if (textEnd >= 0) {\n // An image that closes inside the text; its own text is alt text, and\n // holds nothing a reader follows.\n if (link !== null && link.image && link.form !== 'wiki' && link.end <= textEnd) {\n out.push(link);\n at = link.end;\n } else {\n at += 1;\n }\n } else if (link === null) {\n at += 1;\n } else {\n out.push(link);\n if (!link.image && link.form !== 'wiki') {\n textEnd = pairs.get(at) as number;\n resume = link.end;\n // Into the text. A step back instead reads the character before\n // the `[`, which opens nothing there - it opened no link before\n // this one, or it is escaped - and comes back here.\n at += 1;\n } else {\n at = link.end;\n }\n }\n }\n first = last;\n }\n return out;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scan.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/markdown/scan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,QA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CAAC,KAAK,IAAI,IAAI,CAAC;IAChE,CAAC;AACH,CAAC","sourcesContent":["/**\n * A structural Markdown scanner.\n *\n * Deliberately not a CommonMark parser: nothing here renders. What it must get\n * exactly right is what is code, what is a comment, and what is neither,\n * because every reader downstream asks that question first. A heading inside\n * a fenced block is not a section, a template hint inside `<!-- -->` is not\n * content, and a link in a code sample is not a reference.\n *\n * The scan works on offsets. One pass over the lines finds front matter, code\n * blocks and raw-text HTML, and inside everything else it finds code spans and\n * comments in a single sweep from left to right, as CommonMark does: whichever\n * of the two opens first wins, so `` `<!--` `` is code that mentions a comment,\n * and a backtick inside a comment is a character. Three masks are built from\n * the result, and headings, list items, links and tables are read from them.\n *\n * Every pass is linear in the text. No search runs to the end of the document\n * once per opener: a code span looks for its closer only to the end of its\n * paragraph and remembers what it saw there, and a comment with no `-->`\n * after it tells every later one that there is none.\n *\n * Loops here that stop at a line's end compare against it, and the character\n * there is the line's terminator, which none of them acts on. A bound moved\n * to read one character further changes no answer; mutation testing reports\n * such mutants as surviving, and they are equivalent. So is a search for `-->`\n * compared as `close <= 0` rather than `close < 0`: it starts past `<!--`.\n */\n\nimport { createLineIndex, inRanges, maskRanges, mergeRanges, splitLines, stripBom, type LineIndex, type Range } from '../text/index.js';\nimport { frontMatterCloses, frontMatterKind } from './frontmatter.js';\nimport { findAtxHeadings, findHeadings } from './headings.js';\nimport type { Layout } from './layout.js';\nimport { findLinks } from './links.js';\nimport { findListItems } from './lists.js';\nimport {\n atxLevel,\n fenceCloses,\n fenceOpen,\n hasRawTextClose,\n isRawTextOpen,\n isThematicBreak,\n leadIndex,\n listMarker,\n measureIndent,\n opensComment,\n rawTextTag,\n setextUnderline,\n stripQuotes,\n type FenceOpen,\n type ListMarker,\n} from './syntax.js';\nimport { findTables } from './tables.js';\nimport type { Block, BlockKind, FrontMatterBlock, HtmlComment, MarkdownScan, MaskKind, Masks, ScannedLine, UnclosedFrontMatter } from './types.js';\n\nconst BACKTICK = 0x60;\nconst BACKSLASH = 0x5c;\n\n/** Scans a Markdown document. Pure, and linear in the length of the text. */\nexport function scanMarkdown(source: string): MarkdownScan {\n const text = stripBom(source);\n const index = createLineIndex(text);\n const { frontMatter, unclosedFrontMatter } = readFrontMatterBlock(text, index);\n const bodyStart = frontMatter === null ? 0 : frontMatter.bodyStart;\n const core = scanCore(text, index, frontMatter === null ? 0 : frontMatter.closeLine);\n\n // Without front matter this range is empty, and merging drops it.\n const front: Range[] = [{ start: 0, end: bodyStart }];\n const ranges: Record<MaskKind, Range[]> = {\n structure: mergeRanges([...front, ...core.blocks, ...core.spans, ...core.comments]),\n prose: mergeRanges([...front, ...core.comments]),\n directives: mergeRanges([...front, ...core.blocks, ...core.spans]),\n };\n // Headings are read from the structure and prose masks, and every caller\n // reads headings, so those two are made now. The rest is made the first\n // time it is read: most callers read one or two of links, list items and\n // the directives mask, and making all of them for every document was most\n // of what a spec-guard query spent (ADR-0004).\n const structure = maskRanges(text, ranges.structure);\n const prose = maskRanges(text, ranges.prose);\n const directives = once(() => maskRanges(text, ranges.directives));\n const masks: Masks = {\n structure,\n prose,\n get directives() {\n return directives();\n },\n };\n\n const layout: Layout = {\n text,\n index,\n lines: core.lines,\n blocks: core.blocks,\n comments: core.comments,\n structure,\n prose,\n covered: core.covered,\n continues: core.continues,\n };\n const atx = findAtxHeadings(layout);\n const tables = findTables(layout, atx);\n const headings = findHeadings(layout, atx, tables);\n const listItems = once(() => findListItems(layout, headings));\n const links = once(() => findLinks(layout, headings));\n\n return {\n text,\n bom: source.length - text.length,\n index,\n lines: core.lines,\n frontMatter,\n unclosedFrontMatter,\n bodyStart,\n blocks: core.blocks,\n codeSpans: core.spans,\n comments: core.comments,\n masks,\n headings,\n get listItems() {\n return listItems();\n },\n get links() {\n return links();\n },\n tables,\n isMasked: (offset, mask = 'structure') => inRanges(ranges[mask], offset),\n };\n}\n\n/**\n * The lines of the text or of one of its masks, without terminators, as\n * `splitLines` gives them: a final terminator leaves a last, empty line.\n * Every view has the same number of lines, each the same length.\n */\nexport function linesOf(scan: MarkdownScan, view: MaskKind | 'text' = 'text'): string[] {\n return splitLines(view === 'text' ? scan.text : scan.masks[view]);\n}\n\ninterface Front {\n readonly frontMatter: FrontMatterBlock | null;\n readonly unclosedFrontMatter: UnclosedFrontMatter | null;\n}\n\nconst NO_FRONT: Front = { frontMatter: null, unclosedFrontMatter: null };\n\n/**\n * YAML between `---` lines, closed by `---` or `...`, or TOML between `+++`\n * lines. The opening line is the document's first, exactly. An opening line\n * that is never closed opens nothing: it is a thematic break, and is reported\n * as unclosed front matter.\n */\nfunction readFrontMatterBlock(text: string, index: LineIndex): Front {\n const kind = frontMatterKind(index.lineText(1));\n if (kind === null) return NO_FRONT;\n for (let line = 2; line <= index.lineCount; line += 1) {\n if (!frontMatterCloses(index.lineText(line), kind)) continue;\n const start = index.lineStart(2);\n const end = index.lineStart(line);\n const bodyStart = line < index.lineCount ? index.lineStart(line + 1) : text.length;\n return { frontMatter: { kind, raw: text.slice(start, end), start, end, bodyStart, closeLine: line }, unclosedFrontMatter: null };\n }\n return { frontMatter: null, unclosedFrontMatter: { kind, line: 1, start: 0, end: index.lineEnd(1) } };\n}\n\n/** `make`, run the first time its value is asked for; the same value after. */\nfunction once<T>(make: () => T): () => T {\n let made: { readonly value: T } | null = null;\n return () => {\n made ??= { value: make() };\n return made.value;\n };\n}\n\ntype Mutable<T> = { -readonly [K in keyof T]: T[K] };\n\ninterface Core {\n readonly lines: ScannedLine[];\n readonly blocks: Block[];\n readonly spans: Range[];\n readonly comments: HtmlComment[];\n readonly covered: ReadonlySet<number>;\n readonly continues: ReadonlySet<number>;\n}\n\n/** What each body line is on its own, before anything around it is known. */\ninterface Shape {\n readonly contentStart: number;\n readonly depth: number;\n readonly indent: number;\n readonly blank: boolean;\n /** An ATX heading, which is a paragraph of one line. */\n readonly atx: boolean;\n /** Opens a block that ends a paragraph above it. */\n readonly interrupts: boolean;\n}\n\n/**\n * The block pass, with the inline sweep for code spans and comments run\n * inside it line by line.\n *\n * The two cannot be separate passes. Whether a line opens a fence depends on\n * whether it lies inside a comment, and whether a comment opens depends on\n * whether its `<!--` lies inside a code span.\n */\nfunction scanCore(text: string, index: LineIndex, frontLines: number): Core {\n const count = index.lineCount;\n const lines: Mutable<ScannedLine>[] = [];\n const blocks: Mutable<Block>[] = [];\n const spans: Range[] = [];\n const comments: HtmlComment[] = [];\n const covered = new Set<number>();\n\n for (let i = 0; i < frontLines; i += 1) {\n const start = index.lineStart(i + 1);\n const end = index.lineEnd(i + 1);\n lines.push(record(i, start, end, start, text.slice(start, end), 0, { frontMatter: true, code: false, html: false }));\n }\n\n // One shape too many, for a line past the last, would never be read.\n const shapes: Shape[] = [];\n for (let i = frontLines; i < count; i += 1) {\n const start = index.lineStart(i + 1);\n const end = index.lineEnd(i + 1);\n const q = stripQuotes(text, start, Number.POSITIVE_INFINITY);\n const content = text.slice(q.contentStart, end);\n const indent = measureIndent(content);\n const blank = leadIndex(content) === content.length;\n const atx = atxLevel(content) > 0;\n const previous = shapes[shapes.length - 1];\n const interrupts =\n atx ||\n isThematicBreak(content) ||\n setextUnderline(content) !== null ||\n opensComment(content) ||\n listMarker(content) !== null ||\n fenceOpen(content) !== null ||\n isRawTextOpen(content) ||\n (previous !== undefined && q.depth > previous.depth);\n shapes.push({ contentStart: q.contentStart, depth: q.depth, indent, blank, atx, interrupts });\n }\n const shapeOf = (i: number): Shape => shapes[i - frontLines] as Shape;\n\n // A line continues the paragraph above it when it is not blank, opens\n // nothing of its own, and the line above is not a one-line heading. After a\n // blank line there is no paragraph to continue, and no search asks. Each\n // body line's paragraph ends at `stops`, walked from the bottom up.\n const continues = new Set<number>();\n const stops = new Map<number, number>();\n for (let i = count - 1; i >= frontLines; i -= 1) {\n const shape = shapeOf(i);\n const above = shapes[i - frontLines - 1];\n if (above !== undefined && !above.atx && !shape.blank && !shape.interrupts) continues.add(i + 1);\n stops.set(i, continues.has(i + 2) ? (stops.get(i + 1) as number) : index.lineEnd(i + 1));\n }\n\n /* ------------------------------------------------------------ inline sweep */\n\n // Where the last failed search for a closing backtick run stopped, and the\n // last run of each length it passed. Openers come in order, so a later one\n // before that stop lies inside the stretch searched, and closes only if a\n // run of its length lies after it there, which is a lookup.\n let seen: { readonly end: number; readonly last: ReadonlyMap<number, number> } | null = null;\n\n /** Where the span opened by a run ending at `from` closes, if it does. */\n const closeRun = (from: number, length: number, line: number): number | undefined => {\n // A run of a length the search never saw - one an escape split in two -\n // has no closer either. Reading its absence as any number below `from`\n // gives that answer, and one that is not below it gives it by searching.\n // No run starts at `from`, which follows one, and an opener at `seen.end`\n // finds nothing either way: the comparisons are equivalent at equality.\n if (seen !== null && from < seen.end && (seen.last.get(length) ?? -1) < from) return undefined;\n const stop = stops.get(line) as number;\n const last = new Map<number, number>();\n // A run ends at `from`, so `from` is past 0 and holds no backtick. A\n // search that stopped at `from` itself would record a run of length\n // zero, which no opener asks for, and `at > 0` tests what `at >= 0` does.\n let at = text.indexOf('`', from);\n while (at >= 0 && at < stop) {\n const run = at;\n while (at < stop && text.charCodeAt(at) === BACKTICK) at += 1;\n if (at - run === length) return at;\n last.set(at - run, run);\n at = text.indexOf('`', at);\n }\n seen = { end: stop, last };\n return undefined;\n };\n\n // Once one `<!--` has no `-->` after it, no later one has either.\n let closable = true;\n\n /** Where the comment opened at `at` closes, if it does. */\n const commentEnd = (at: number): number | undefined => {\n // CommonMark 0.31: `<!-->` and `<!--->` are whole, empty comments.\n if (text.startsWith('<!-->', at)) return at + 5;\n if (text.startsWith('<!--->', at)) return at + 6;\n if (!closable) return undefined;\n const close = text.indexOf('-->', at + 4);\n closable = close !== -1;\n return closable ? close + 3 : undefined;\n };\n\n const pushComment = (start: number, end: number, closed: boolean): void => {\n comments.push({\n start,\n end,\n // An empty comment's `-->` overlaps its `<!--`, and the slice is empty.\n inner: text.slice(start + 4, closed ? end - 3 : end),\n innerStart: start + 4,\n line: index.positionAt(start).line,\n closed,\n });\n };\n /**\n * Sweeps one line from `from`, returning where the next line's sweep may\n * begin: past a span or comment that runs onto a later line, or the line's\n * end. `lead` is the offset at which a `<!--` would open the line, or the\n * end of the line when none can: a sweep never stops there.\n */\n const sweep = (from: number, end: number, line: number, lead: number): number => {\n let at = from;\n while (at < end) {\n const ch = text.charCodeAt(at);\n if (ch === BACKSLASH) {\n // An escaped backtick opens no span, and an escaped `<` no comment.\n at += 2;\n } else if (ch === BACKTICK) {\n let run = at + 1;\n while (run < end && text.charCodeAt(run) === BACKTICK) run += 1;\n const close = closeRun(run, run - at, line);\n if (close === undefined) {\n at = run;\n } else {\n spans.push({ start: at, end: close });\n at = close;\n }\n } else if (text.startsWith('<!--', at)) {\n const close = commentEnd(at);\n if (close !== undefined) {\n pushComment(at, close, true);\n at = close;\n } else if (at === lead) {\n // CommonMark's HTML block: a comment opening a line runs to its\n // `-->`, and one never closed runs to the end of the document.\n pushComment(at, text.length, false);\n return text.length;\n } else {\n at += 4;\n }\n } else {\n at += 1;\n }\n }\n return at;\n };\n\n /* ------------------------------------------------------------- block pass */\n\n interface Open {\n readonly block: Mutable<Block>;\n readonly depth: number;\n }\n let fence: (Open & { readonly open: FenceOpen }) | null = null;\n let raw: Open | null = null;\n let indented: Mutable<Block> | null = null;\n let previousBlank = true;\n // The content column of each list item open around the line, innermost last.\n // Each loop that pops it tests its length first, which says what is meant;\n // without the test it stops all the same, `undefined > indent` being false.\n const items: number[] = [];\n let pos = 0;\n\n const openBlock = (kind: BlockKind, i: number, info: string, tag: string | null): Mutable<Block> => {\n const block = { kind, start: index.lineStart(i + 1), end: index.lineEnd(i + 1), line: i + 1, endLine: i + 1, info, tag, closed: kind === 'indented' };\n blocks.push(block);\n return block;\n };\n const extend = (block: Mutable<Block>, i: number): void => {\n block.end = index.lineEnd(i + 1);\n block.endLine = i + 1;\n };\n // Blank lines after an indented block were marked as code in case more\n // code followed; the block ends at its last code line.\n const endIndented = (block: Mutable<Block>, next: number): void => {\n for (let i = block.endLine; i < next; i += 1) (lines[i] as Mutable<ScannedLine>).code = false;\n };\n\n /** Classifies one line and sweeps it; the caller records whether it was blank. */\n const scanLine = (i: number): void => {\n const start = index.lineStart(i + 1);\n const end = index.lineEnd(i + 1);\n const shape = shapeOf(i);\n const content = text.slice(shape.contentStart, end);\n const push = (kind: Kinds): void => {\n lines.push(record(i, start, end, shape.contentStart, content, shape.depth, kind));\n };\n\n if (pos > start) {\n // Inside a comment or span opened above: nothing opens a block here.\n covered.add(i + 1);\n push(NONE);\n pos = sweep(pos, end, i, end);\n return;\n }\n\n const container = fence ?? raw;\n if (container !== null) {\n // A fenced block or raw-text block ends with its block quote.\n const q = stripQuotes(text, start, container.depth);\n if (q.depth === container.depth) {\n const inside = text.slice(q.contentStart, end);\n lines.push(record(i, start, end, q.contentStart, inside, q.depth, fence === null ? HTML : CODE));\n extend(container.block, i);\n if (fence !== null ? fenceCloses(inside, fence.open) : hasRawTextClose(inside)) {\n container.block.closed = true;\n fence = null;\n raw = null;\n }\n return;\n }\n fence = null;\n raw = null;\n }\n\n // After a blank line, a line left of an item's content is outside it.\n if (!shape.blank && previousBlank) {\n while (items.length > 0 && (items[items.length - 1] as number) > shape.indent) items.pop();\n }\n // Indented code: four columns past the item the line is in, or past the\n // margin outside a list, and never interrupting a paragraph. Four columns\n // inside an item are its text, not code.\n const margin = items[items.length - 1] ?? 0;\n const deep = shape.indent >= margin + 4;\n if (!shape.blank && deep && (previousBlank || indented !== null)) {\n if (indented === null) indented = openBlock('indented', i, '', null);\n else extend(indented, i);\n push(CODE);\n return;\n }\n if (shape.blank) {\n push(indented === null ? NONE : CODE);\n return;\n }\n if (indented !== null) {\n endIndented(indented, i);\n indented = null;\n }\n\n // A fence as deep as indented code continues a paragraph instead.\n const open = deep ? null : fenceOpen(content);\n if (open !== null) {\n fence = { block: openBlock('fenced', i, open.info, null), depth: shape.depth, open };\n push(CODE);\n return;\n }\n const tag = rawTextTag(content);\n if (tag !== null) {\n const block = openBlock('html', i, '', tag);\n push(HTML);\n if (hasRawTextClose(content)) block.closed = true;\n else raw = { block, depth: shape.depth };\n return;\n }\n\n push(NONE);\n const marker = listMarker(content);\n if (marker !== null) {\n // A marker left of an item's content starts a sibling or an outer item.\n while (items.length > 0 && (items[items.length - 1] as number) > shape.indent) items.pop();\n items.push(itemColumn(shape.indent, marker));\n }\n // A heading ends a list whatever its indentation.\n if (shape.atx) items.length = 0;\n const lead = shape.indent <= 3 ? shape.contentStart + leadIndex(content) : end;\n pos = sweep(shape.contentStart, end, i, lead);\n };\n\n for (let i = frontLines; i < count; i += 1) {\n scanLine(i);\n // Whether the line was blank to look at, whatever it was classified as:\n // indented code starts only after one.\n previousBlank = shapeOf(i).blank;\n }\n if (indented !== null) endIndented(indented, count);\n\n markCommentLines(lines, comments);\n return { lines, blocks, spans, comments, covered, continues };\n}\n\n/**\n * The column an item's text starts at: past its marker and the one to four\n * spaces after it. With none, or five or more, the text starts one column\n * past the marker, and anything further is indented code. At one space both\n * arms give one, so `spaces > 1` would read the same as `spaces >= 1`.\n */\nfunction itemColumn(indent: number, marker: ListMarker): number {\n const spaces = marker.width - marker.marker.length;\n return indent + marker.marker.length + (spaces >= 1 && spaces <= 4 ? spaces : 1);\n}\n\ntype Kinds = Pick<ScannedLine, 'frontMatter' | 'code' | 'html'>;\nconst NONE: Kinds = { frontMatter: false, code: false, html: false };\nconst CODE: Kinds = { frontMatter: false, code: true, html: false };\nconst HTML: Kinds = { frontMatter: false, code: false, html: true };\n\nfunction record(\n i: number,\n start: number,\n end: number,\n contentStart: number,\n content: string,\n quoteDepth: number,\n kinds: Kinds,\n): Mutable<ScannedLine> {\n return {\n line: i + 1,\n start,\n end,\n contentStart,\n content,\n indent: measureIndent(content),\n blank: leadIndex(content) === content.length,\n quoteDepth,\n ...kinds,\n comment: false,\n };\n}\n\n/** Marks each line whose first non-blank character lies inside a comment. */\nfunction markCommentLines(lines: readonly Mutable<ScannedLine>[], comments: readonly HtmlComment[]): void {\n let c = 0;\n for (const line of lines) {\n if (line.blank) continue;\n const lead = line.contentStart + leadIndex(line.content);\n // No comment ends exactly at a line's first non-blank character: a\n // comment ends in `>`, so one that ends before it ends on an earlier line.\n while (c < comments.length && (comments[c] as HtmlComment).end <= lead) c += 1;\n const comment = comments[c];\n line.comment = comment !== undefined && comment.start <= lead;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"scan.js","sourceRoot":"","sources":["../../../../src/vendor/spec-core/markdown/scan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,eAAe,EAAE,QAAQ,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,EAA8B,MAAM,kBAAkB,CAAC;AACxI,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE9D,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAC3C,OAAO,EACL,QAAQ,EACR,WAAW,EACX,SAAS,EACT,eAAe,EACf,aAAa,EACb,eAAe,EACf,SAAS,EACT,UAAU,EACV,aAAa,EACb,YAAY,EACZ,UAAU,EACV,eAAe,EACf,WAAW,GAGZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAGzC,MAAM,QAAQ,GAAG,IAAI,CAAC;AACtB,MAAM,SAAS,GAAG,IAAI,CAAC;AAEvB,6EAA6E;AAC7E,MAAM,UAAU,YAAY,CAAC,MAAc;IACzC,MAAM,IAAI,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC9B,MAAM,KAAK,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;IACpC,MAAM,EAAE,WAAW,EAAE,mBAAmB,EAAE,GAAG,oBAAoB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC/E,MAAM,SAAS,GAAG,WAAW,KAAK,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AAS;QACzB,MAAM,IAAI,GAAG,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACzD,mEAAmE;QACnE,2EAA2E;QAC3E,OAAO,CAAC,GAAG,QAAQ,CAAC,MAAM,IAAK,QAAQ,CAAC,CAAC,CAAiB,CAAC,GAAG,IAAI,IAAI;YAAE,CAAC,IAAI,CAAC,CAAC;QAC/E,MAAM,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,OAAO,KAAK,SAAS,IAAI,OAAO,CAAC,KAAK,IAAI,IAAI,CAAC;IAChE,CAAC;AACH,CAAC","sourcesContent":["/**\n * A structural Markdown scanner.\n *\n * Deliberately not a CommonMark parser: nothing here renders. What it must get\n * exactly right is what is code, what is a comment, and what is neither,\n * because every reader downstream asks that question first. A heading inside\n * a fenced block is not a section, a template hint inside `<!-- -->` is not\n * content, and a link in a code sample is not a reference.\n *\n * The scan works on offsets. One pass over the lines finds front matter, code\n * blocks and raw-text HTML, and inside everything else it finds code spans and\n * comments in a single sweep from left to right, as CommonMark does: whichever\n * of the two opens first wins, so `` `<!--` `` is code that mentions a comment,\n * and a backtick inside a comment is a character. Three masks are built from\n * the result, and headings, list items, links and tables are read from them.\n *\n * Every pass is linear in the text. No search runs to the end of the document\n * once per opener: a code span looks for its closer only to the end of its\n * paragraph and remembers what it saw there, and a comment with no `-->`\n * after it tells every later one that there is none.\n *\n * Loops here that stop at a line's end compare against it, and the character\n * there is the line's terminator, which none of them acts on. A bound moved\n * to read one character further changes no answer; mutation testing reports\n * such mutants as surviving, and they are equivalent. So is a search for `-->`\n * compared as `close <= 0` rather than `close < 0`: it starts past `<!--`.\n */\n\nimport { createLineIndex, inRanges, maskRanges, mergeRanges, splitLines, stripBom, type LineIndex, type Range } from '../text/index.js';\nimport { frontMatterCloses, frontMatterKind } from './frontmatter.js';\nimport { findAtxHeadings, findHeadings } from './headings.js';\nimport type { Layout } from './layout.js';\nimport { findLinks } from './links.js';\nimport { findListItems } from './lists.js';\nimport {\n atxLevel,\n fenceCloses,\n fenceOpen,\n hasRawTextClose,\n isRawTextOpen,\n isThematicBreak,\n leadIndex,\n listMarker,\n measureIndent,\n opensComment,\n rawTextTag,\n setextUnderline,\n stripQuotes,\n type FenceOpen,\n type ListMarker,\n} from './syntax.js';\nimport { findTables } from './tables.js';\nimport type { Block, BlockKind, FrontMatterBlock, HtmlComment, MarkdownScan, MaskKind, Masks, ScannedLine, UnclosedFrontMatter } from './types.js';\n\nconst BACKTICK = 0x60;\nconst BACKSLASH = 0x5c;\n\n/** Scans a Markdown document. Pure, and linear in the length of the text. */\nexport function scanMarkdown(source: string): MarkdownScan {\n const text = stripBom(source);\n const index = createLineIndex(text);\n const { frontMatter, unclosedFrontMatter } = readFrontMatterBlock(text, index);\n const bodyStart = frontMatter === null ? 0 : frontMatter.bodyStart;\n const core = scanCore(text, index, frontMatter === null ? 0 : frontMatter.closeLine);\n\n // Without front matter this range is empty, and merging drops it.\n const front: Range[] = [{ start: 0, end: bodyStart }];\n const ranges: Record<MaskKind, Range[]> = {\n structure: mergeRanges([...front, ...core.blocks, ...core.spans, ...core.comments]),\n prose: mergeRanges([...front, ...core.comments]),\n directives: mergeRanges([...front, ...core.blocks, ...core.spans]),\n };\n // Headings are read from the structure and prose masks, and every caller\n // reads headings, so those two are made now. The rest is made the first\n // time it is read: most callers read one or two of links, list items and\n // the directives mask, and making all of them for every document was most\n // of what a spec-guard query spent (ADR-0004).\n const structure = maskRanges(text, ranges.structure);\n const prose = maskRanges(text, ranges.prose);\n const directives = once(() => maskRanges(text, ranges.directives));\n const masks: Masks = {\n structure,\n prose,\n get directives() {\n return directives();\n },\n };\n\n const layout: Layout = {\n text,\n index,\n lines: core.lines,\n blocks: core.blocks,\n comments: core.comments,\n structure,\n prose,\n covered: core.covered,\n continues: core.continues,\n };\n const atx = findAtxHeadings(layout);\n const tables = findTables(layout, atx);\n const headings = findHeadings(layout, atx, tables);\n const listItems = once(() => findListItems(layout, headings));\n const links = once(() => findLinks(layout, headings));\n\n return {\n text,\n bom: source.length - text.length,\n index,\n lines: core.lines,\n frontMatter,\n unclosedFrontMatter,\n bodyStart,\n blocks: core.blocks,\n codeSpans: core.spans,\n comments: core.comments,\n masks,\n headings,\n get listItems() {\n return listItems();\n },\n get links() {\n return links();\n },\n tables,\n isMasked: (offset, mask = 'structure') => inRanges(ranges[mask], offset),\n };\n}\n\n/**\n * The lines of the text or of one of its masks, without terminators, as\n * `splitLines` gives them: a final terminator leaves a last, empty line.\n * Every view has the same number of lines, each the same length.\n */\nexport function linesOf(scan: MarkdownScan, view: MaskKind | 'text' = 'text'): string[] {\n return splitLines(view === 'text' ? scan.text : scan.masks[view]);\n}\n\ninterface Front {\n readonly frontMatter: FrontMatterBlock | null;\n readonly unclosedFrontMatter: UnclosedFrontMatter | null;\n}\n\nconst NO_FRONT: Front = { frontMatter: null, unclosedFrontMatter: null };\n\n/**\n * YAML between `---` lines, closed by `---` or `...`, or TOML between `+++`\n * lines. The opening line is the document's first, exactly. An opening line\n * that is never closed opens nothing: it is a thematic break, and is reported\n * as unclosed front matter.\n */\nfunction readFrontMatterBlock(text: string, index: LineIndex): Front {\n const kind = frontMatterKind(index.lineText(1));\n if (kind === null) return NO_FRONT;\n for (let line = 2; line <= index.lineCount; line += 1) {\n if (!frontMatterCloses(index.lineText(line), kind)) continue;\n const start = index.lineStart(2);\n const end = index.lineStart(line);\n const bodyStart = line < index.lineCount ? index.lineStart(line + 1) : text.length;\n return { frontMatter: { kind, raw: text.slice(start, end), start, end, bodyStart, closeLine: line }, unclosedFrontMatter: null };\n }\n return { frontMatter: null, unclosedFrontMatter: { kind, line: 1, start: 0, end: index.lineEnd(1) } };\n}\n\n/** `make`, run the first time its value is asked for; the same value after. */\nfunction once<T>(make: () => T): () => T {\n let made: { readonly value: T } | null = null;\n return () => {\n made ??= { value: make() };\n return made.value;\n };\n}\n\ntype Mutable<T> = { -readonly [K in keyof T]: T[K] };\n\ninterface Core {\n readonly lines: ScannedLine[];\n readonly blocks: Block[];\n readonly spans: Range[];\n readonly comments: HtmlComment[];\n readonly covered: ReadonlySet<number>;\n readonly continues: ReadonlySet<number>;\n}\n\n/** What each body line is on its own, before anything around it is known. */\ninterface Shape {\n readonly contentStart: number;\n readonly depth: number;\n readonly indent: number;\n readonly blank: boolean;\n /** An ATX heading, which is a paragraph of one line. */\n readonly atx: boolean;\n /** Opens a block that ends a paragraph above it. */\n readonly interrupts: boolean;\n}\n\n/**\n * The block pass, with the inline sweep for code spans and comments run\n * inside it line by line.\n *\n * The two cannot be separate passes. Whether a line opens a fence depends on\n * whether it lies inside a comment, and whether a comment opens depends on\n * whether its `<!--` lies inside a code span.\n */\nfunction scanCore(text: string, index: LineIndex, frontLines: number): Core {\n const count = index.lineCount;\n const lines: Mutable<ScannedLine>[] = [];\n const blocks: Mutable<Block>[] = [];\n const spans: Range[] = [];\n const comments: HtmlComment[] = [];\n const covered = new Set<number>();\n\n for (let i = 0; i < frontLines; i += 1) {\n const start = index.lineStart(i + 1);\n const end = index.lineEnd(i + 1);\n lines.push(record(i, start, end, start, text.slice(start, end), 0, { frontMatter: true, code: false, html: false }));\n }\n\n // One shape too many, for a line past the last, would never be read.\n const shapes: Shape[] = [];\n for (let i = frontLines; i < count; i += 1) {\n const start = index.lineStart(i + 1);\n const end = index.lineEnd(i + 1);\n const q = stripQuotes(text, start, Number.POSITIVE_INFINITY);\n const content = text.slice(q.contentStart, end);\n const indent = measureIndent(content);\n const blank = leadIndex(content) === content.length;\n const atx = atxLevel(content) > 0;\n const previous = shapes[shapes.length - 1];\n const interrupts =\n atx ||\n isThematicBreak(content) ||\n setextUnderline(content) !== null ||\n opensComment(content) ||\n listMarker(content) !== null ||\n fenceOpen(content) !== null ||\n isRawTextOpen(content) ||\n (previous !== undefined && q.depth > previous.depth);\n shapes.push({ contentStart: q.contentStart, depth: q.depth, indent, blank, atx, interrupts });\n }\n const shapeOf = (i: number): Shape => shapes[i - frontLines]!;\n\n // A line continues the paragraph above it when it is not blank, opens\n // nothing of its own, and the line above is not a one-line heading. After a\n // blank line there is no paragraph to continue, and no search asks. Each\n // body line's paragraph ends at `stops`, walked from the bottom up.\n const continues = new Set<number>();\n const stops = new Map<number, number>();\n for (let i = count - 1; i >= frontLines; i -= 1) {\n const shape = shapeOf(i);\n const above = shapes[i - frontLines - 1];\n if (above !== undefined && !above.atx && !shape.blank && !shape.interrupts) continues.add(i + 1);\n stops.set(i, continues.has(i + 2) ? stops.get(i + 1)! : index.lineEnd(i + 1));\n }\n\n /* ------------------------------------------------------------ inline sweep */\n\n // Where the last failed search for a closing backtick run stopped, and the\n // last run of each length it passed. Openers come in order, so a later one\n // before that stop lies inside the stretch searched, and closes only if a\n // run of its length lies after it there, which is a lookup.\n let seen: { readonly end: number; readonly last: ReadonlyMap<number, number> } | null = null;\n\n /** Where the span opened by a run ending at `from` closes, if it does. */\n const closeRun = (from: number, length: number, line: number): number | undefined => {\n // A run of a length the search never saw - one an escape split in two -\n // has no closer either. Reading its absence as any number below `from`\n // gives that answer, and one that is not below it gives it by searching.\n // No run starts at `from`, which follows one, and an opener at `seen.end`\n // finds nothing either way: the comparisons are equivalent at equality.\n if (seen !== null && from < seen.end && (seen.last.get(length) ?? -1) < from) return undefined;\n const stop = stops.get(line) as number;\n const last = new Map<number, number>();\n // A run ends at `from`, so `from` is past 0 and holds no backtick. A\n // search that stopped at `from` itself would record a run of length\n // zero, which no opener asks for, and `at > 0` tests what `at >= 0` does.\n let at = text.indexOf('`', from);\n while (at >= 0 && at < stop) {\n const run = at;\n while (at < stop && text.charCodeAt(at) === BACKTICK) at += 1;\n if (at - run === length) return at;\n last.set(at - run, run);\n at = text.indexOf('`', at);\n }\n seen = { end: stop, last };\n return undefined;\n };\n\n // Once one `<!--` has no `-->` after it, no later one has either.\n let closable = true;\n\n /** Where the comment opened at `at` closes, if it does. */\n const commentEnd = (at: number): number | undefined => {\n // CommonMark 0.31: `<!-->` and `<!--->` are whole, empty comments.\n if (text.startsWith('<!-->', at)) return at + 5;\n if (text.startsWith('<!--->', at)) return at + 6;\n if (!closable) return undefined;\n const close = text.indexOf('-->', at + 4);\n closable = close !== -1;\n return closable ? close + 3 : undefined;\n };\n\n const pushComment = (start: number, end: number, closed: boolean): void => {\n comments.push({\n start,\n end,\n // An empty comment's `-->` overlaps its `<!--`, and the slice is empty.\n inner: text.slice(start + 4, closed ? end - 3 : end),\n innerStart: start + 4,\n line: index.positionAt(start).line,\n closed,\n });\n };\n /**\n * Sweeps one line from `from`, returning where the next line's sweep may\n * begin: past a span or comment that runs onto a later line, or the line's\n * end. `lead` is the offset at which a `<!--` would open the line, or the\n * end of the line when none can: a sweep never stops there.\n */\n const sweep = (from: number, end: number, line: number, lead: number): number => {\n let at = from;\n while (at < end) {\n const ch = text.charCodeAt(at);\n if (ch === BACKSLASH) {\n // An escaped backtick opens no span, and an escaped `<` no comment.\n at += 2;\n } else if (ch === BACKTICK) {\n let run = at + 1;\n while (run < end && text.charCodeAt(run) === BACKTICK) run += 1;\n const close = closeRun(run, run - at, line);\n if (close === undefined) {\n at = run;\n } else {\n spans.push({ start: at, end: close });\n at = close;\n }\n } else if (text.startsWith('<!--', at)) {\n const close = commentEnd(at);\n if (close !== undefined) {\n pushComment(at, close, true);\n at = close;\n } else if (at === lead) {\n // CommonMark's HTML block: a comment opening a line runs to its\n // `-->`, and one never closed runs to the end of the document.\n pushComment(at, text.length, false);\n return text.length;\n } else {\n at += 4;\n }\n } else {\n at += 1;\n }\n }\n return at;\n };\n\n /* ------------------------------------------------------------- block pass */\n\n interface Open {\n readonly block: Mutable<Block>;\n readonly depth: number;\n }\n let fence: (Open & { readonly open: FenceOpen }) | null = null;\n let raw: Open | null = null;\n let indented: Mutable<Block> | null = null;\n let previousBlank = true;\n // The content column of each list item open around the line, innermost last.\n // Each loop that pops it tests its length first, which says what is meant;\n // without the test it stops all the same, `undefined > indent` being false.\n const items: number[] = [];\n let pos = 0;\n\n const openBlock = (kind: BlockKind, i: number, info: string, tag: string | null): Mutable<Block> => {\n const block = { kind, start: index.lineStart(i + 1), end: index.lineEnd(i + 1), line: i + 1, endLine: i + 1, info, tag, closed: kind === 'indented' };\n blocks.push(block);\n return block;\n };\n const extend = (block: Mutable<Block>, i: number): void => {\n block.end = index.lineEnd(i + 1);\n block.endLine = i + 1;\n };\n // Blank lines after an indented block were marked as code in case more\n // code followed; the block ends at its last code line.\n const endIndented = (block: Mutable<Block>, next: number): void => {\n for (let i = block.endLine; i < next; i += 1) (lines[i] as Mutable<ScannedLine>).code = false;\n };\n\n /** Classifies one line and sweeps it; the caller records whether it was blank. */\n const scanLine = (i: number): void => {\n const start = index.lineStart(i + 1);\n const end = index.lineEnd(i + 1);\n const shape = shapeOf(i);\n const content = text.slice(shape.contentStart, end);\n const push = (kind: Kinds): void => {\n lines.push(record(i, start, end, shape.contentStart, content, shape.depth, kind));\n };\n\n if (pos > start) {\n // Inside a comment or span opened above: nothing opens a block here.\n covered.add(i + 1);\n push(NONE);\n pos = sweep(pos, end, i, end);\n return;\n }\n\n const container = fence ?? raw;\n if (container !== null) {\n // A fenced block or raw-text block ends with its block quote.\n const q = stripQuotes(text, start, container.depth);\n if (q.depth === container.depth) {\n const inside = text.slice(q.contentStart, end);\n lines.push(record(i, start, end, q.contentStart, inside, q.depth, fence === null ? HTML : CODE));\n extend(container.block, i);\n if (fence !== null ? fenceCloses(inside, fence.open) : hasRawTextClose(inside)) {\n container.block.closed = true;\n fence = null;\n raw = null;\n }\n return;\n }\n fence = null;\n raw = null;\n }\n\n // After a blank line, a line left of an item's content is outside it.\n if (!shape.blank && previousBlank) {\n while (items.length > 0 && items[items.length - 1]! > shape.indent) items.pop();\n }\n // Indented code: four columns past the item the line is in, or past the\n // margin outside a list, and never interrupting a paragraph. Four columns\n // inside an item are its text, not code.\n const margin = items[items.length - 1] ?? 0;\n const deep = shape.indent >= margin + 4;\n if (!shape.blank && deep && (previousBlank || indented !== null)) {\n if (indented === null) indented = openBlock('indented', i, '', null);\n else extend(indented, i);\n push(CODE);\n return;\n }\n if (shape.blank) {\n push(indented === null ? NONE : CODE);\n return;\n }\n if (indented !== null) {\n endIndented(indented, i);\n indented = null;\n }\n\n // A fence as deep as indented code continues a paragraph instead.\n const open = deep ? null : fenceOpen(content);\n if (open !== null) {\n fence = { block: openBlock('fenced', i, open.info, null), depth: shape.depth, open };\n push(CODE);\n return;\n }\n const tag = rawTextTag(content);\n if (tag !== null) {\n const block = openBlock('html', i, '', tag);\n push(HTML);\n if (hasRawTextClose(content)) block.closed = true;\n else raw = { block, depth: shape.depth };\n return;\n }\n\n push(NONE);\n const marker = listMarker(content);\n if (marker !== null) {\n // A marker left of an item's content starts a sibling or an outer item.\n while (items.length > 0 && items[items.length - 1]! > shape.indent) items.pop();\n items.push(itemColumn(shape.indent, marker));\n }\n // A heading ends a list whatever its indentation.\n if (shape.atx) items.length = 0;\n const lead = shape.indent <= 3 ? shape.contentStart + leadIndex(content) : end;\n pos = sweep(shape.contentStart, end, i, lead);\n };\n\n for (let i = frontLines; i < count; i += 1) {\n scanLine(i);\n // Whether the line was blank to look at, whatever it was classified as:\n // indented code starts only after one.\n previousBlank = shapeOf(i).blank;\n }\n if (indented !== null) endIndented(indented, count);\n\n markCommentLines(lines, comments);\n return { lines, blocks, spans, comments, covered, continues };\n}\n\n/**\n * The column an item's text starts at: past its marker and the one to four\n * spaces after it. With none, or five or more, the text starts one column\n * past the marker, and anything further is indented code. At one space both\n * arms give one, so `spaces > 1` would read the same as `spaces >= 1`.\n */\nfunction itemColumn(indent: number, marker: ListMarker): number {\n const spaces = marker.width - marker.marker.length;\n return indent + marker.marker.length + (spaces >= 1 && spaces <= 4 ? spaces : 1);\n}\n\ntype Kinds = Pick<ScannedLine, 'frontMatter' | 'code' | 'html'>;\nconst NONE: Kinds = { frontMatter: false, code: false, html: false };\nconst CODE: Kinds = { frontMatter: false, code: true, html: false };\nconst HTML: Kinds = { frontMatter: false, code: false, html: true };\n\nfunction record(\n i: number,\n start: number,\n end: number,\n contentStart: number,\n content: string,\n quoteDepth: number,\n kinds: Kinds,\n): Mutable<ScannedLine> {\n return {\n line: i + 1,\n start,\n end,\n contentStart,\n content,\n indent: measureIndent(content),\n blank: leadIndex(content) === content.length,\n quoteDepth,\n ...kinds,\n comment: false,\n };\n}\n\n/** Marks each line whose first non-blank character lies inside a comment. */\nfunction markCommentLines(lines: readonly Mutable<ScannedLine>[], comments: readonly HtmlComment[]): void {\n let c = 0;\n for (const line of lines) {\n if (line.blank) continue;\n const lead = line.contentStart + leadIndex(line.content);\n // No comment ends exactly at a line's first non-blank character: a\n // comment ends in `>`, so one that ends before it ends on an earlier line.\n while (c < comments.length && (comments[c] as HtmlComment).end <= lead) c += 1;\n const comment = comments[c];\n line.comment = comment !== undefined && comment.start <= lead;\n }\n}\n"]}
|