typewright 0.2.1
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/LICENSE +21 -0
- package/README.md +168 -0
- package/SPEC.md +327 -0
- package/dist/chunk-CZQO7TTL.js +1533 -0
- package/dist/chunk-CZQO7TTL.js.map +1 -0
- package/dist/chunk-KNEKNZXK.js +286 -0
- package/dist/chunk-KNEKNZXK.js.map +1 -0
- package/dist/chunk-M6IVEMXO.js +1398 -0
- package/dist/chunk-M6IVEMXO.js.map +1 -0
- package/dist/chunk-NJ7PJKHN.js +652 -0
- package/dist/chunk-NJ7PJKHN.js.map +1 -0
- package/dist/commands-Z3ndUSza.d.cts +221 -0
- package/dist/commands-Z3ndUSza.d.ts +221 -0
- package/dist/core/index.cjs +2952 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.cts +410 -0
- package/dist/core/index.d.ts +410 -0
- package/dist/core/index.js +4 -0
- package/dist/core/index.js.map +1 -0
- package/dist/mdx/index.cjs +662 -0
- package/dist/mdx/index.cjs.map +1 -0
- package/dist/mdx/index.d.cts +252 -0
- package/dist/mdx/index.d.ts +252 -0
- package/dist/mdx/index.js +3 -0
- package/dist/mdx/index.js.map +1 -0
- package/dist/react/index.cjs +7439 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.cts +140 -0
- package/dist/react/index.d.ts +140 -0
- package/dist/react/index.js +3644 -0
- package/dist/react/index.js.map +1 -0
- package/dist/streaming/index.cjs +1494 -0
- package/dist/streaming/index.cjs.map +1 -0
- package/dist/streaming/index.d.cts +64 -0
- package/dist/streaming/index.d.ts +64 -0
- package/dist/streaming/index.js +4 -0
- package/dist/streaming/index.js.map +1 -0
- package/dist/types-CX1GOx0Y.d.cts +319 -0
- package/dist/types-CX1GOx0Y.d.ts +319 -0
- package/package.json +128 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/core/ast.ts","../../src/core/parser.ts","../../src/core/render.ts","../../src/core/unified.ts","../../src/core/fold.ts","../../src/core/commands.ts","../../src/core/text.ts","../../src/core/highlight.ts","../../src/core/comments.ts","../../src/core/table.ts","../../src/core/index.ts"],"names":["node","commit","lineStart","children","MAX_URL","t","escapeHtml"],"mappings":";;;AA2PA,IAAM,YAAA,uBAAmB,GAAA,CAAI;AAAA,EAC3B,MAAA;AAAA,EACA,UAAA;AAAA,EACA,QAAA;AAAA,EACA,eAAA;AAAA,EACA,YAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EACA,UAAA;AAAA,EACA,OAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAAC,CAAA;AAEM,SAAS,SAAS,IAAA,EAA+B;AACtD,EAAA,OAAO,YAAA,CAAa,GAAA,CAAI,IAAA,CAAK,IAAI,CAAA;AACnC;AAGO,SAAS,IAAA,CAAK,MAAe,KAAA,EAAgD;AAClF,EAAA,MAAM,EAAA,GAAK,CAAC,CAAA,KAAqB;AAC/B,IAAA,IAAI,KAAA,CAAM,CAAC,CAAA,KAAM,KAAA,EAAO;AACxB,IAAA,MAAM,IAAA,GAAO,WAAW,CAAC,CAAA;AACzB,IAAA,KAAA,MAAW,CAAA,IAAK,IAAA,EAAM,EAAA,CAAG,CAAC,CAAA;AAAA,EAC5B,CAAA;AACA,EAAA,EAAA,CAAG,IAAI,CAAA;AACT;AAEO,SAAS,WAAW,IAAA,EAA0B;AACnD,EAAA,QAAQ,KAAK,IAAA;AAAM,IACjB,KAAK,UAAA;AAAA,IACL,KAAK,YAAA;AACH,MAAA,OAAO,IAAA,CAAK,QAAA;AAAA,IACd,KAAK,SAAA;AAAA,IACL,KAAK,WAAA;AAAA,IACL,KAAK,UAAA;AAAA,IACL,KAAK,QAAA;AAAA,IACL,KAAK,eAAA;AAAA,IACL,KAAK,WAAA;AACH,MAAA,OAAO,IAAA,CAAK,QAAA;AAAA,IACd,KAAK,MAAA;AACH,MAAA,OAAO,IAAA,CAAK,QAAA;AAAA,IACd,K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W;AACX,EAAA,MAAM,IAAA,GAAO,WAAA,CAAY,IAAA,EAAM,KAAK,CAAA;AACpC,EAAA,IAAI,GAAA,IAAO,KAAK,GAAA,GAAM,IAAA,CAAK,MAAM,MAAA,EAAQ,IAAA,CAAK,KAAA,CAAM,GAAG,CAAA,GAAI,KAAA;AAC3D,EAAA,MAAM,WAAW,QAAA,CAAS,GAAA,EAAK,GAAG,IAAA,CAAK,KAAA,CAAM,SAAS,CAAC,CAAA;AACvD,EAAA,OAAO,MAAA,CAAO,IAAA,EAAM,KAAA,EAAO,IAAA,EAAM,GAAG,QAAQ,CAAA;AAC9C;;;ACxLO,IAAM,aAAN,MAAiB;AAAA,EACb,GAAA;AAAA,EAET,YAAY,OAAA,EAA4B;AACtC,IAAA,IAAA,CAAK,MAAM,OAAA,CAAQ,MAAA;AACnB,IAAA,MAAM,IAAI,KAAA;AAAA,MACR;AAAA,KAEF;AAAA,EACF;AAAA;AAAA,EAGA,IAAI,GAAA,GAAc;AAChB,IAAA,OAAO,EAAA;AAAA,EACT;AAAA;AAAA,EAGA,SAAS,OAAA,EAA0B;AAAA,EAEnC;AAAA,EAEA,aAAa,UAAA,EAAgC;AAAA,EAE7C;AAAA,EAEA,OAAA,GAAgB;AAAA,EAEhB;AACF","file":"index.cjs","sourcesContent":["/**\n * Typewright AST — the offset-exact node model the parser produces and the\n * renderer / unified-mode / fold services consume.\n *\n * Every node carries `from`/`to`: UTF-16 offsets into the source string. This\n * is the contract that makes non-destructive rendering, source-revealing, and\n * folding possible — a node always knows exactly which slice of the string it\n * owns. Marker offsets (e.g. a heading's `### `, an emphasis delimiter) are\n * exposed where a consumer needs to hide/reveal them.\n */\n\nexport interface Pos {\n /** Inclusive start offset into the source string. */\n from: number;\n /** Exclusive end offset into the source string. */\n to: number;\n}\n\n/* ------------------------------------------------------------------ *\n * Inline nodes\n * ------------------------------------------------------------------ */\n\nexport interface TextNode extends Pos {\n type: 'text';\n value: string;\n}\n\nexport interface Emphasis extends Pos {\n type: 'emphasis';\n /** The delimiter used (`*` or `_`). */\n marker: string;\n children: Inline[];\n}\n\nexport interface Strong extends Pos {\n type: 'strong';\n marker: string;\n children: Inline[];\n}\n\nexport interface Strikethrough extends Pos {\n type: 'strikethrough';\n children: Inline[];\n}\n\nexport interface InlineCode extends Pos {\n type: 'inlineCode';\n value: string;\n /** Number of backticks in the fence. */\n ticks: number;\n}\n\nexport interface Link extends Pos {\n type: 'link';\n url: string;\n title?: string;\n children: Inline[];\n}\n\nexport interface Image extends Pos {\n type: 'image';\n url: string;\n alt: string;\n title?: string;\n}\n\nexport interface Autolink extends Pos {\n type: 'autolink';\n url: string;\n}\n\nexport interface LineBreak extends Pos {\n type: 'break';\n /** A hard break (two trailing spaces or backslash) vs a soft newline. */\n hard: boolean;\n}\n\n/** Inline math (`$…$` inline, `$$…$$` inline-display). Opt-in via {@link ParseOptions.math}. */\nexport interface Math extends Pos {\n type: 'math';\n /** The TeX source between the delimiters (delimiters excluded). */\n value: string;\n /** `true` for a `$$…$$` display span, `false` for a `$…$` inline span. */\n display: boolean;\n}\n\n/** A footnote reference `[^id]`. Opt-in via {@link ParseOptions.footnotes}. */\nexport interface FootnoteRef extends Pos {\n type: 'footnoteRef';\n /** The referenced footnote label (between `[^` and `]`). */\n id: string;\n}\n\nexport type Inline =\n | TextNode\n | Emphasis\n | Strong\n | Strikethrough\n | InlineCode\n | Link\n | Image\n | Autolink\n | LineBreak\n | Math\n | FootnoteRef;\n\n/* ------------------------------------------------------------------ *\n * Block nodes\n * ------------------------------------------------------------------ */\n\nexport interface Heading extends Pos {\n type: 'heading';\n level: 1 | 2 | 3 | 4 | 5 | 6;\n /** Offset just past the `#`… marker + following space (start of content). */\n contentFrom: number;\n children: Inline[];\n}\n\nexport interface Paragraph extends Pos {\n type: 'paragraph';\n children: Inline[];\n}\n\nexport interface Blockquote extends Pos {\n type: 'blockquote';\n children: Block[];\n}\n\nexport type TaskState = 'checked' | 'unchecked' | null;\n\nexport interface ListItem extends Pos {\n type: 'listItem';\n /** Task-list state, or null for a plain item. */\n task: TaskState;\n /** Offset just past the list marker (`- `, `1. `, `- [x] `). */\n contentFrom: number;\n children: Block[];\n}\n\nexport interface List extends Pos {\n type: 'list';\n ordered: boolean;\n /** Start number for an ordered list. */\n start: number;\n /** Loose lists wrap items in paragraphs; tight lists don't. */\n tight: boolean;\n items: ListItem[];\n}\n\nexport interface CodeBlock extends Pos {\n type: 'codeBlock';\n /** Info string after the opening fence (may be empty). */\n lang: string;\n value: string;\n fenced: boolean;\n}\n\nexport interface ThematicBreak extends Pos {\n type: 'thematicBreak';\n}\n\nexport type CellAlign = 'left' | 'center' | 'right' | null;\n\nexport interface TableCell extends Pos {\n type: 'tableCell';\n children: Inline[];\n}\n\nexport interface Table extends Pos {\n type: 'table';\n align: CellAlign[];\n header: TableCell[];\n rows: TableCell[][];\n}\n\n/** Raw HTML or an MDX/JSX/ESM region — kept verbatim (markup only, not evaluated). */\nexport interface HtmlBlock extends Pos {\n type: 'htmlBlock';\n value: string;\n /** `html` for raw HTML, `mdxFlow` for a JSX element / ESM line at block level. */\n variant: 'html' | 'mdxFlow';\n}\n\n/** A `$$…$$` display-math block. Opt-in via {@link ParseOptions.math}. */\nexport interface MathBlock extends Pos {\n type: 'mathBlock';\n /** The TeX source between the `$$` fences (fences excluded). */\n value: string;\n}\n\n/** A footnote definition `[^id]: …`. Opt-in via {@link ParseOptions.footnotes}. */\nexport interface FootnoteDef extends Pos {\n type: 'footnoteDef';\n /** The footnote label (between `[^` and `]`). */\n id: string;\n children: Block[];\n}\n\n/** A single term + one-or-more definitions inside a {@link DefList}. */\nexport interface DefItem extends Pos {\n type: 'defItem';\n term: Inline[];\n /** Each `: …` definition, parsed as its own block sequence. */\n definitions: Block[][];\n}\n\n/** A definition list — terms with `: …` definitions. Opt-in via {@link ParseOptions.defLists}. */\nexport interface DefList extends Pos {\n type: 'defList';\n items: DefItem[];\n}\n\nexport type Block =\n | Heading\n | Paragraph\n | Blockquote\n | List\n | CodeBlock\n | ThematicBreak\n | Table\n | HtmlBlock\n | MathBlock\n | FootnoteDef\n | DefList;\n\nexport interface Document extends Pos {\n type: 'document';\n children: Block[];\n}\n\nexport type AstNode = Document | Block | ListItem | TableCell | DefItem | Inline;\n\n/**\n * Opt-in parser extensions. Every flag defaults to `false`, so `parse(src)`\n * behaves exactly as it always has; enabling a flag lights up the matching\n * construct (and nothing else). Kept semver-safe so a later wave can turn these\n * on from configuration without a breaking parser change.\n */\nexport interface ParseOptions {\n /** Parse `$…$` inline and `$$…$$` block math. */\n math?: boolean;\n /** Parse `[^id]` footnote references and `[^id]: …` definitions. */\n footnotes?: boolean;\n /** Parse `term` / `: definition` definition lists. */\n defLists?: boolean;\n}\n\n/* ------------------------------------------------------------------ *\n * Helpers\n * ------------------------------------------------------------------ */\n\nconst INLINE_TYPES = new Set([\n 'text',\n 'emphasis',\n 'strong',\n 'strikethrough',\n 'inlineCode',\n 'link',\n 'image',\n 'autolink',\n 'break',\n 'math',\n 'footnoteRef',\n]);\n\nexport function isInline(node: AstNode): node is Inline {\n return INLINE_TYPES.has(node.type);\n}\n\n/** Depth-first walk over the tree; return false from `visit` to skip children. */\nexport function walk(node: AstNode, visit: (node: AstNode) => boolean | void): void {\n const go = (n: AstNode): void => {\n if (visit(n) === false) return;\n const kids = childrenOf(n);\n for (const k of kids) go(k);\n };\n go(node);\n}\n\nexport function childrenOf(node: AstNode): AstNode[] {\n switch (node.type) {\n case 'document':\n case 'blockquote':\n return node.children;\n case 'heading':\n case 'paragraph':\n case 'emphasis':\n case 'strong':\n case 'strikethrough':\n case 'tableCell':\n return node.children;\n case 'link':\n return node.children;\n case 'list':\n return node.items;\n case 'listItem':\n return node.children;\n case 'table':\n return [...node.header, ...node.rows.flat()];\n case 'footnoteDef':\n return node.children;\n case 'defList':\n return node.items;\n case 'defItem':\n return [...node.term, ...node.definitions.flat()];\n default:\n return [];\n }\n}\n","/**\n * Typewright block + inline parser — a hand-written, zero-dependency GitHub\n * Flavored Markdown (+ light MDX-flow) parser that produces the offset-exact\n * AST in `./ast`. Every node carries `from`/`to` UTF-16 source offsets; markers\n * (heading `### `, list bullets, emphasis delimiters) are exposed so a consumer\n * can hide/reveal the raw syntax.\n *\n * Design notes:\n * - Block parsing works line-by-line. Container blocks (blockquote, list) build\n * a fresh line list whose `from` is advanced past the stripped prefix; because\n * only `from` moves, `src.slice(from, to)` still equals the line's content, so\n * offsets stay exact through arbitrary nesting.\n * - Inline parsing stitches a block's content lines into one buffer with a\n * per-character source-offset map, so emphasis/code spanning a soft line break\n * still reports correct absolute offsets.\n * - The parser never throws: unterminated emphasis / code / links / fences all\n * degrade to text (or run to end-of-input) rather than failing.\n */\n\nimport { walk } from './ast';\nimport type {\n AstNode,\n Autolink,\n Block,\n Blockquote,\n CellAlign,\n CodeBlock,\n DefItem,\n DefList,\n Document,\n Emphasis,\n FootnoteDef,\n FootnoteRef,\n Heading,\n HtmlBlock,\n Image,\n Inline,\n InlineCode,\n LineBreak,\n Link,\n List,\n ListItem,\n Math,\n MathBlock,\n Paragraph,\n ParseOptions,\n Strikethrough,\n Strong,\n Table,\n TableCell,\n TaskState,\n TextNode,\n ThematicBreak,\n} from './ast';\nimport type { Change } from './text';\n\n/* ------------------------------------------------------------------ *\n * Bounds — keep user/model-controlled strings sensibly capped.\n * ------------------------------------------------------------------ */\n\nconst MAX_URL = 4096;\nconst MAX_TITLE = 1024;\nconst MAX_ALT = 4096;\nconst MAX_LANG = 256;\nconst MAX_VALUE = 1_000_000;\n/** Footnote labels are short tokens; this caps the `[^…]` lookahead to O(1). */\nconst MAX_FOOTNOTE_ID = 256;\n\nconst cap = (s: string, n: number): string => (s.length > n ? s.slice(0, n) : s);\n\n/* ------------------------------------------------------------------ *\n * Opt-in extensions (math / footnotes / definition lists)\n *\n * All three default to `false`, so `parse(src)` is byte-for-byte what it always\n * was. The resolved flags live in module scope and are set once per `parse()`\n * call; parsing is synchronous and non-reentrant across calls, and every nested\n * `parseBlocks` within a single call shares the same flags — so this reads like\n * a closure variable without threading an argument through every builder.\n * ------------------------------------------------------------------ */\n\ninterface ResolvedOptions {\n math: boolean;\n footnotes: boolean;\n defLists: boolean;\n}\n\nlet opts: ResolvedOptions = { math: false, footnotes: false, defLists: false };\n\n/* ------------------------------------------------------------------ *\n * Line model\n * ------------------------------------------------------------------ */\n\ninterface Line {\n /** Offset of the first character of (stripped) content. */\n from: number;\n /** Offset just past the last content character (before the newline). */\n to: number;\n /** `src.slice(from, to)` — the line's content, minus any container prefix. */\n text: string;\n}\n\n/** Split source into content lines (newline + trailing `\\r` excluded). */\nfunction splitLines(src: string): Line[] {\n const lines: Line[] = [];\n let from = 0;\n for (let i = 0; i <= src.length; i++) {\n if (i === src.length || src[i] === '\\n') {\n let end = i;\n if (end > from && src[end - 1] === '\\r') end--;\n lines.push({ from, to: end, text: src.slice(from, end) });\n from = i + 1;\n }\n }\n return lines;\n}\n\nconst leadingSpaces = (t: string): number => {\n let n = 0;\n while (n < t.length && t[n] === ' ') n++;\n return n;\n};\n\nconst isBlank = (line: Line): boolean => line.text.trim() === '';\n\n/* ------------------------------------------------------------------ *\n * Block detectors\n * ------------------------------------------------------------------ */\n\nconst FENCE_RE = /^( {0,3})(`{3,}|~{3,})(.*)$/;\nconst ATX_RE = /^( {0,3})(#{1,6})(?=\\s|$)/;\nconst ITEM_RE = /^( {0,3})([-+*]|\\d{1,9}[.)])( +|$)/;\nconst HTML_TAG_RE = /^<\\/?([A-Za-z][A-Za-z0-9-]*)(?:[\\s/>]|$)/;\nconst ESM_RE = /^(?:import|export)\\b/;\n\nconst isFence = (t: string): boolean => {\n const m = FENCE_RE.exec(t);\n if (!m) return false;\n // A backtick info string may not itself contain a backtick.\n return m[2]![0] !== '`' || !m[3]!.includes('`');\n};\n\nconst isAtx = (t: string): boolean => ATX_RE.test(t);\n\nconst isThematic = (t: string): boolean => {\n const trimmed = t.trim();\n if (trimmed.length < 3) return false;\n const compact = trimmed.replace(/ /g, '');\n return /^(?:-{3,}|_{3,}|\\*{3,})$/.test(compact);\n};\n\nconst isQuote = (t: string): boolean => /^ {0,3}>/.test(t);\n\ninterface ItemInfo {\n indent: number;\n marker: string;\n markerLen: number;\n spacesAfter: number;\n ordered: boolean;\n}\n\nfunction detectItem(line: Line): ItemInfo | null {\n const m = ITEM_RE.exec(line.text);\n if (!m) return null;\n const marker = m[2]!;\n return {\n indent: m[1]!.length,\n marker,\n markerLen: marker.length,\n spacesAfter: m[3] === '' ? 0 : m[3]!.length,\n ordered: /\\d/.test(marker[0]!),\n };\n}\n\nfunction htmlVariant(t: string): 'html' | 'mdxFlow' | null {\n const s = t.replace(/^ {0,3}/, '');\n if (ESM_RE.test(s)) return 'mdxFlow';\n const m = HTML_TAG_RE.exec(s);\n if (!m) return null;\n return /[A-Z]/.test(m[1]![0]!) ? 'mdxFlow' : 'html';\n}\n\nfunction isDelimRow(t: string): boolean {\n let s = t.trim();\n if (!s.includes('-')) return false;\n s = s.replace(/^\\|/, '').replace(/\\|$/, '');\n const cells = s.split('|');\n return cells.length >= 1 && cells.every((c) => /^ *:?-+:? *$/.test(c));\n}\n\nfunction isTableStartAt(lines: Line[], j: number): boolean {\n const line = lines[j];\n const next = lines[j + 1];\n if (!line || !next) return false;\n if (isBlank(line)) return false;\n return line.text.includes('|') && isDelimRow(next.text);\n}\n\n/* --- opt-in detectors (inert unless the matching flag is on) --- */\n\n/** A `$$` display-math fence on its own line (opener or closer). */\nconst MATH_FENCE_RE = /^ {0,3}\\$\\$[ \\t]*$/;\nconst isMathOpen = (t: string): boolean => opts.math && MATH_FENCE_RE.test(t);\n\n/** A `[^id]:` footnote definition line. Never collides with `ITEM_RE`. */\nconst FOOTNOTE_DEF_RE = /^( {0,3})\\[\\^([^\\]\\s]+)\\]:/;\nconst isFootnoteDef = (line: Line): boolean => opts.footnotes && FOOTNOTE_DEF_RE.test(line.text);\n\n/** A `: …` definition-list definition line (up to 3 leading spaces). */\nconst DEF_RE = /^( {0,3}):[ \\t]+/;\n\n/**\n * Does line `j` open a definition list? Conservative: line `j` must be a plain\n * term (a line that would otherwise be a paragraph — not another block) and the\n * *immediately* following line must be a `: …` definition. The term guard reuses\n * `startsBlock` (which never recurses into this check), so a heading/quote/table\n * term is rejected.\n */\nfunction isDefListStartAt(lines: Line[], j: number): boolean {\n if (!opts.defLists) return false;\n const line = lines[j];\n const next = lines[j + 1];\n if (!line || !next) return false;\n if (isBlank(line)) return false;\n if (startsBlock(lines, j)) return false; // term must not be another block\n return DEF_RE.test(next.text);\n}\n\n/** Does line `j` begin a non-paragraph block (so a paragraph must stop)? */\nfunction startsBlock(lines: Line[], j: number): boolean {\n const line = lines[j]!;\n const t = line.text;\n return (\n isFence(t) ||\n isAtx(t) ||\n isThematic(t) ||\n isQuote(t) ||\n detectItem(line) !== null ||\n htmlVariant(t) !== null ||\n isTableStartAt(lines, j) ||\n isMathOpen(t) ||\n isFootnoteDef(line)\n );\n}\n\n/** Like `startsBlock` but excludes tables (used while consuming table rows). */\nfunction startsOtherBlock(line: Line): boolean {\n const t = line.text;\n return (\n isFence(t) ||\n isAtx(t) ||\n isThematic(t) ||\n isQuote(t) ||\n detectItem(line) !== null ||\n htmlVariant(t) !== null ||\n isMathOpen(t) ||\n isFootnoteDef(line)\n );\n}\n\n/* ------------------------------------------------------------------ *\n * Block builders\n * ------------------------------------------------------------------ */\n\ninterface Built {\n node: Block;\n next: number;\n}\n\nfunction buildHeading(line: Line): Heading {\n const t = line.text;\n const m = ATX_RE.exec(t)!;\n const indent = m[1]!.length;\n const hashes = m[2]!;\n const level = hashes.length as 1 | 2 | 3 | 4 | 5 | 6;\n let ce = indent + hashes.length;\n if (t[ce] === ' ') ce++;\n const contentFrom = line.from + ce;\n\n // Trim trailing whitespace + an optional closing `###` sequence for children.\n let end = t.length;\n while (end > ce && (t[end - 1] === ' ' || t[end - 1] === '\\t')) end--;\n let e2 = end;\n while (e2 > ce && t[e2 - 1] === '#') e2--;\n if (e2 < end && (e2 === ce || t[e2 - 1] === ' ' || t[e2 - 1] === '\\t')) {\n end = e2;\n while (end > ce && (t[end - 1] === ' ' || t[end - 1] === '\\t')) end--;\n }\n\n const children = parseInlineSegs([\n { from: contentFrom, to: line.from + end, text: t.slice(ce, end) },\n ]);\n return { type: 'heading', from: line.from, to: line.to, level, contentFrom, children };\n}\n\nfunction buildFence(lines: Line[], i: number): Built {\n const open = lines[i]!;\n const m = FENCE_RE.exec(open.text)!;\n const indent = m[1]!.length;\n const fenceChar = m[2]![0]!;\n const fenceLen = m[2]!.length;\n const lang = cap(m[3]!.trim(), MAX_LANG);\n\n const inner: Line[] = [];\n let j = i + 1;\n let closeTo: number | null = null;\n while (j < lines.length) {\n const cm = /^( {0,3})(`{3,}|~{3,}) *$/.exec(lines[j]!.text);\n if (cm && cm[2]![0] === fenceChar && cm[2]!.length >= fenceLen) {\n closeTo = lines[j]!.to;\n j++;\n break;\n }\n inner.push(lines[j]!);\n j++;\n }\n\n const value = cap(\n inner.map((l) => (leadingSpaces(l.text) >= indent ? l.text.slice(indent) : l.text.trimStart())).join('\\n'),\n MAX_VALUE,\n );\n const to = closeTo ?? (inner.length ? inner[inner.length - 1]!.to : open.to);\n return { node: { type: 'codeBlock', from: open.from, to, lang, value, fenced: true }, next: j };\n}\n\n/** A `$$` … `$$` display-math block. Unterminated → runs to end (like a fence). */\nfunction buildMathBlock(lines: Line[], i: number): Built {\n const open = lines[i]!;\n const inner: Line[] = [];\n let j = i + 1;\n let closeTo: number | null = null;\n while (j < lines.length) {\n if (MATH_FENCE_RE.test(lines[j]!.text)) {\n closeTo = lines[j]!.to;\n j++;\n break;\n }\n inner.push(lines[j]!);\n j++;\n }\n const value = cap(inner.map((l) => l.text).join('\\n'), MAX_VALUE);\n const to = closeTo ?? (inner.length ? inner[inner.length - 1]!.to : open.to);\n const node: MathBlock = { type: 'mathBlock', from: open.from, to, value };\n return { node, next: j };\n}\n\nfunction buildIndentedCode(lines: Line[], i: number): Built {\n const from = lines[i]!.from;\n const inner: Line[] = [lines[i]!];\n let j = i + 1;\n let pending: Line[] = [];\n while (j < lines.length) {\n const line = lines[j]!;\n if (isBlank(line)) {\n pending.push(line);\n j++;\n continue;\n }\n if (leadingSpaces(line.text) >= 4) {\n inner.push(...pending, line);\n pending = [];\n j++;\n continue;\n }\n break;\n }\n const last = inner[inner.length - 1]!;\n const value = cap(inner.map((l) => l.text.slice(4)).join('\\n'), MAX_VALUE);\n return {\n node: { type: 'codeBlock', from, to: last.to, lang: '', value, fenced: false },\n next: j,\n };\n}\n\nfunction buildThematic(line: Line): ThematicBreak {\n return { type: 'thematicBreak', from: line.from, to: line.to };\n}\n\nfunction stripQuote(line: Line): Line {\n const m = /^( {0,3})>( ?)/.exec(line.text)!;\n const cut = m[0].length;\n return { from: line.from + cut, to: line.to, text: line.text.slice(cut) };\n}\n\nfunction buildBlockquote(lines: Line[], i: number): Built {\n const from = lines[i]!.from;\n const inner: Line[] = [];\n let j = i;\n while (j < lines.length && isQuote(lines[j]!.text)) {\n inner.push(stripQuote(lines[j]!));\n j++;\n }\n const to = lines[j - 1]!.to;\n const children = parseBlocks(inner);\n return { node: { type: 'blockquote', from, to, children }, next: j };\n}\n\nconst TASK_RE = /^\\[([ xX])\\](\\s|$)/;\n\ninterface CollectedItem {\n item: ListItem;\n next: number;\n blankBefore: boolean;\n loose: boolean;\n}\n\nfunction collectItem(lines: Line[], idx: number): CollectedItem {\n const line0 = lines[idx]!;\n const det = detectItem(line0)!;\n const contentCol = det.indent + det.markerLen + 1;\n const localStart = det.indent + det.markerLen + (det.spacesAfter > 0 ? 1 : 0);\n\n let task: TaskState = null;\n let bodyStart = localStart;\n const afterMarker = line0.text.slice(localStart);\n const tm = TASK_RE.exec(afterMarker);\n if (tm) {\n task = tm[1] === ' ' ? 'unchecked' : 'checked';\n bodyStart = localStart + tm[0].length;\n }\n const contentFrom = line0.from + bodyStart;\n\n const body: Line[] = [\n { from: contentFrom, to: line0.to, text: line0.text.slice(bodyStart) },\n ];\n let lastTo = line0.to;\n let loose = false;\n let pendingBlank = false;\n let j = idx + 1;\n\n while (j < lines.length) {\n const lj = lines[j]!;\n if (isBlank(lj)) {\n pendingBlank = true;\n j++;\n continue;\n }\n const ind = leadingSpaces(lj.text);\n if (ind >= contentCol) {\n if (pendingBlank) {\n loose = true;\n body.push({ from: lj.from, to: lj.from, text: '' });\n }\n body.push({\n from: lj.from + contentCol,\n to: lj.to,\n text: lj.text.slice(contentCol),\n });\n lastTo = lj.to;\n pendingBlank = false;\n j++;\n continue;\n }\n if (detectItem(lj)) break; // sibling / new item\n if (pendingBlank) break; // blank then unindented, non-item → item ends\n if (startsOtherBlock(lj)) break; // a new block interrupts\n // lazy paragraph continuation\n body.push({ from: lj.from, to: lj.to, text: lj.text });\n lastTo = lj.to;\n j++;\n }\n\n const children = parseBlocks(body);\n const item: ListItem = {\n type: 'listItem',\n from: line0.from,\n to: lastTo,\n task,\n contentFrom,\n children,\n };\n return { item, next: j, blankBefore: pendingBlank, loose };\n}\n\nfunction buildList(lines: Line[], start: number): Built {\n const first = detectItem(lines[start]!)!;\n const ordered = first.ordered;\n const startNum = ordered ? parseInt(first.marker, 10) || 0 : 1;\n\n const items: ListItem[] = [];\n let loose = false;\n let i = start;\n while (i < lines.length) {\n const det = detectItem(lines[i]!);\n if (!det || det.ordered !== ordered) break;\n const r = collectItem(lines, i);\n if (r.blankBefore) loose = true;\n if (r.loose) loose = true;\n items.push(r.item);\n i = r.next;\n }\n\n const node: List = {\n type: 'list',\n from: items[0]!.from,\n to: items[items.length - 1]!.to,\n ordered,\n start: startNum,\n tight: !loose,\n items,\n };\n return { node, next: i };\n}\n\nfunction parseAligns(delim: string): CellAlign[] {\n return splitCellRanges(delim).map(([a, b]) => {\n const cell = delim.slice(a, b).trim();\n const left = cell.startsWith(':');\n const right = cell.endsWith(':');\n if (left && right) return 'center';\n if (left) return 'left';\n if (right) return 'right';\n return null;\n });\n}\n\n/** Local [start,end) ranges for each pipe-delimited cell, outer pipes dropped. */\nfunction splitCellRanges(t: string): Array<[number, number]> {\n const cells: Array<[number, number]> = [];\n let s = 0;\n for (let k = 0; k < t.length; k++) {\n if (t[k] === '|' && t[k - 1] !== '\\\\') {\n cells.push([s, k]);\n s = k + 1;\n }\n }\n cells.push([s, t.length]);\n if (cells.length > 1 && t.slice(cells[0]![0], cells[0]![1]).trim() === '') cells.shift();\n if (cells.length > 1 && t.slice(cells[cells.length - 1]![0], cells[cells.length - 1]![1]).trim() === '')\n cells.pop();\n return cells;\n}\n\nfunction splitRow(line: Line): TableCell[] {\n const t = line.text;\n return splitCellRanges(t).map(([a, b]) => {\n let ca = a;\n while (ca < b && t[ca] === ' ') ca++;\n let cb = b;\n while (cb > ca && t[cb - 1] === ' ') cb--;\n const from = line.from + ca;\n const to = line.from + cb;\n const children = parseInlineSegs([{ from, to, text: t.slice(ca, cb) }]);\n return { type: 'tableCell', from, to, children };\n });\n}\n\nfunction buildTable(lines: Line[], i: number): Built {\n const header = splitRow(lines[i]!);\n const align = parseAligns(lines[i + 1]!.text);\n const rows: TableCell[][] = [];\n let j = i + 2;\n let lastTo = lines[i + 1]!.to;\n while (j < lines.length) {\n const line = lines[j]!;\n if (isBlank(line) || startsOtherBlock(line)) break;\n rows.push(splitRow(line));\n lastTo = line.to;\n j++;\n }\n return {\n node: { type: 'table', from: lines[i]!.from, to: lastTo, align, header, rows },\n next: j,\n };\n}\n\nfunction buildHtml(lines: Line[], i: number): Built {\n const variant = htmlVariant(lines[i]!.text)!;\n const from = lines[i]!.from;\n const block: Line[] = [];\n let j = i;\n while (j < lines.length && !isBlank(lines[j]!)) {\n block.push(lines[j]!);\n j++;\n }\n const to = block[block.length - 1]!.to;\n const value = cap(block.map((l) => l.text).join('\\n'), MAX_VALUE);\n return { node: { type: 'htmlBlock', from, to, value, variant }, next: j };\n}\n\n/**\n * A `[^id]: …` footnote definition. Its body — the text after `]: ` plus any\n * indented / lazily-continued following lines — is parsed as nested blocks\n * (mirroring `collectItem`'s continuation model), so a def can hold paragraphs,\n * lists, code, etc.\n */\nfunction buildFootnoteDef(lines: Line[], i: number): Built {\n const line0 = lines[i]!;\n const m = FOOTNOTE_DEF_RE.exec(line0.text)!;\n const indent = m[1]!.length;\n const id = m[2]!;\n const markerLen = m[0].length - indent; // length of `[^id]:`\n const contentCol = indent + markerLen + 1; // continuation aligns past `[^id]: `\n let bodyStart = indent + markerLen;\n if (line0.text[bodyStart] === ' ') bodyStart++;\n const contentFrom = line0.from + bodyStart;\n\n const body: Line[] = [\n { from: contentFrom, to: line0.to, text: line0.text.slice(bodyStart) },\n ];\n let lastTo = line0.to;\n let pendingBlank = false;\n let j = i + 1;\n while (j < lines.length) {\n const lj = lines[j]!;\n if (isBlank(lj)) {\n pendingBlank = true;\n j++;\n continue;\n }\n const ind = leadingSpaces(lj.text);\n if (ind >= contentCol) {\n if (pendingBlank) body.push({ from: lj.from, to: lj.from, text: '' });\n body.push({ from: lj.from + contentCol, to: lj.to, text: lj.text.slice(contentCol) });\n lastTo = lj.to;\n pendingBlank = false;\n j++;\n continue;\n }\n if (pendingBlank) break; // blank then unindented → def ends\n if (isFootnoteDef(lj)) break; // sibling definition\n if (startsOtherBlock(lj)) break; // a new block interrupts\n if (isDefListStartAt(lines, j)) break;\n // lazy paragraph continuation\n body.push({ from: lj.from, to: lj.to, text: lj.text });\n lastTo = lj.to;\n j++;\n }\n\n const children = parseBlocks(body);\n const node: FootnoteDef = { type: 'footnoteDef', from: line0.from, to: lastTo, id, children };\n return { node, next: j };\n}\n\n/** One `: …` definition (+ its indented/lazy continuation) as a block sequence. */\nfunction collectDefinition(lines: Line[], idx: number): { blocks: Block[]; to: number; next: number } {\n const line0 = lines[idx]!;\n const m = DEF_RE.exec(line0.text)!;\n const contentCol = m[0].length; // content begins just past `: `\n const body: Line[] = [\n { from: line0.from + contentCol, to: line0.to, text: line0.text.slice(contentCol) },\n ];\n let lastTo = line0.to;\n let pendingBlank = false;\n let j = idx + 1;\n while (j < lines.length) {\n const lj = lines[j]!;\n if (isBlank(lj)) {\n pendingBlank = true;\n j++;\n continue;\n }\n if (DEF_RE.test(lj.text)) break; // next definition of the same term\n const ind = leadingSpaces(lj.text);\n if (ind >= contentCol) {\n if (pendingBlank) body.push({ from: lj.from, to: lj.from, text: '' });\n body.push({ from: lj.from + contentCol, to: lj.to, text: lj.text.slice(contentCol) });\n lastTo = lj.to;\n pendingBlank = false;\n j++;\n continue;\n }\n if (pendingBlank) break;\n if (startsOtherBlock(lj)) break;\n if (isFootnoteDef(lj)) break;\n if (isDefListStartAt(lines, j)) break; // next term/definition group\n // lazy paragraph continuation\n body.push({ from: lj.from, to: lj.to, text: lj.text });\n lastTo = lj.to;\n j++;\n }\n return { blocks: parseBlocks(body), to: lastTo, next: j };\n}\n\n/** A term line plus its one-or-more `: …` definitions. */\nfunction collectDefItem(lines: Line[], idx: number): { item: DefItem; next: number } {\n const termLine = lines[idx]!;\n const term = parseInlineSegs([\n { from: termLine.from, to: termLine.to, text: termLine.text },\n ]);\n const definitions: Block[][] = [];\n let lastTo = termLine.to;\n let j = idx + 1;\n while (j < lines.length && DEF_RE.test(lines[j]!.text)) {\n const d = collectDefinition(lines, j);\n definitions.push(d.blocks);\n lastTo = d.to;\n j = d.next;\n }\n const item: DefItem = { type: 'defItem', from: termLine.from, to: lastTo, term, definitions };\n return { item, next: j };\n}\n\n/** A definition list: consecutive `term` / `: definition` groups. */\nfunction buildDefList(lines: Line[], start: number): Built {\n const items: DefItem[] = [];\n let i = start;\n while (i < lines.length && isDefListStartAt(lines, i)) {\n const r = collectDefItem(lines, i);\n items.push(r.item);\n i = r.next;\n }\n const node: DefList = {\n type: 'defList',\n from: items[0]!.from,\n to: items[items.length - 1]!.to,\n items,\n };\n return { node, next: i };\n}\n\nfunction buildParagraph(lines: Line[], i: number): Built {\n const para: Line[] = [lines[i]!];\n let j = i + 1;\n while (j < lines.length) {\n if (isBlank(lines[j]!)) break;\n if (startsBlock(lines, j)) break;\n para.push(lines[j]!);\n j++;\n }\n const from = para[0]!.from;\n const to = para[para.length - 1]!.to;\n const children = parseInlineSegs(para.map((l) => ({ from: l.from, to: l.to, text: l.text })));\n return { node: { type: 'paragraph', from, to, children }, next: j };\n}\n\n/* ------------------------------------------------------------------ *\n * Block dispatch\n * ------------------------------------------------------------------ */\n\nfunction parseBlocks(lines: Line[]): Block[] {\n const out: Block[] = [];\n let i = 0;\n while (i < lines.length) {\n const line = lines[i]!;\n if (isBlank(line)) {\n i++;\n continue;\n }\n const t = line.text;\n\n if (isFence(t)) {\n const b = buildFence(lines, i);\n out.push(b.node);\n i = b.next;\n } else if (isMathOpen(t)) {\n const b = buildMathBlock(lines, i);\n out.push(b.node);\n i = b.next;\n } else if (leadingSpaces(t) >= 4) {\n const b = buildIndentedCode(lines, i);\n out.push(b.node);\n i = b.next;\n } else if (isAtx(t)) {\n out.push(buildHeading(line));\n i++;\n } else if (isThematic(t)) {\n out.push(buildThematic(line));\n i++;\n } else if (isQuote(t)) {\n const b = buildBlockquote(lines, i);\n out.push(b.node);\n i = b.next;\n } else if (detectItem(line)) {\n const b = buildList(lines, i);\n out.push(b.node);\n i = b.next;\n } else if (isDefListStartAt(lines, i)) {\n const b = buildDefList(lines, i);\n out.push(b.node);\n i = b.next;\n } else if (isTableStartAt(lines, i)) {\n const b = buildTable(lines, i);\n out.push(b.node);\n i = b.next;\n } else if (htmlVariant(t)) {\n const b = buildHtml(lines, i);\n out.push(b.node);\n i = b.next;\n } else if (isFootnoteDef(line)) {\n const b = buildFootnoteDef(lines, i);\n out.push(b.node);\n i = b.next;\n } else {\n const b = buildParagraph(lines, i);\n out.push(b.node);\n i = b.next;\n }\n }\n return out;\n}\n\n/* ------------------------------------------------------------------ *\n * Inline parsing\n * ------------------------------------------------------------------ */\n\ninterface Seg {\n from: number;\n to: number;\n text: string;\n}\n\nconst isWs = (ch: string | undefined): boolean =>\n ch === undefined || ch === ' ' || ch === '\\n' || ch === '\\t' || ch === '\\r';\n\nconst isAlnum = (ch: string | undefined): boolean =>\n ch !== undefined && /[0-9A-Za-z]/.test(ch);\n\n/**\n * Parse the inline content of a block, given its content lines. The lines are\n * stitched into one buffer separated by soft breaks; a per-character map lets\n * every produced node report exact absolute source offsets.\n */\nfunction parseInlineSegs(segs: Seg[]): Inline[] {\n if (segs.length === 0) return [];\n let buf = '';\n const map: number[] = [];\n for (let s = 0; s < segs.length; s++) {\n const seg = segs[s]!;\n if (s > 0) {\n map.push(segs[s - 1]!.to);\n buf += '\\n';\n }\n for (let k = 0; k < seg.text.length; k++) {\n map.push(seg.from + k);\n buf += seg.text[k];\n }\n }\n map.push(segs[segs.length - 1]!.to);\n\n const abs = (k: number): number => (k < map.length ? map[k]! : segs[segs.length - 1]!.to);\n\n /* --- inline node builders --- */\n const text = (from: number, to: number, value: string): TextNode => ({\n type: 'text',\n from,\n to,\n value: cap(value, MAX_VALUE),\n });\n\n /* --- construct scanners (buffer-index based) --- */\n\n interface Hit {\n node: Inline;\n endIdx: number;\n }\n\n function tryCode(i: number, end: number): Hit | null {\n let n = 1;\n while (i + n < end && buf[i + n] === '`') n++;\n let k = i + n;\n while (k < end) {\n if (buf[k] === '`') {\n let m = 1;\n while (k + m < end && buf[k + m] === '`') m++;\n if (m === n) {\n let val = buf.slice(i + n, k);\n if (val.length > 2 && val[0] === ' ' && val[val.length - 1] === ' ' && val.trim() !== '')\n val = val.slice(1, -1);\n const node: InlineCode = {\n type: 'inlineCode',\n from: abs(i),\n to: abs(k + n),\n value: cap(val, MAX_VALUE),\n ticks: n,\n };\n return { node, endIdx: k + n };\n }\n k += m;\n continue;\n }\n k++;\n }\n return null;\n }\n\n /**\n * Inline math `$…$` (or inline-display `$$…$$`). Modeled on `tryCode`: an\n * unterminated run returns null and degrades to literal text. Flanking rules\n * (opener not followed by space, closer not preceded by space) keep bare `$`\n * signs in prose — `$5 and $10` — from being read as math. `\\$` is escaped.\n */\n function tryMath(i: number, end: number): Hit | null {\n let n = 1;\n while (i + n < end && buf[i + n] === '$' && n < 2) n++;\n const after = buf[i + n];\n if (after === undefined || after === ' ' || after === '\\t' || after === '\\n') return null;\n let k = i + n;\n while (k < end) {\n const ch = buf[k];\n if (ch === '\\\\') {\n k += 2; // escaped char (e.g. `\\$`) can't close the span\n continue;\n }\n if (ch === '\\n') return null; // inline math stays on one line\n if (ch === '$') {\n let m = 1;\n while (k + m < end && buf[k + m] === '$' && m < 2) m++;\n if (m === n && k > i + n) {\n const prev = buf[k - 1];\n if (prev !== ' ' && prev !== '\\t' && prev !== '\\n') {\n const node: Math = {\n type: 'math',\n from: abs(i),\n to: abs(k + n),\n value: cap(buf.slice(i + n, k), MAX_VALUE),\n display: n === 2,\n };\n return { node, endIdx: k + n };\n }\n }\n k += m;\n continue;\n }\n k++;\n }\n return null;\n }\n\n /**\n * A footnote reference `[^id]`. The id scan is BOUNDED (`MAX_FOOTNOTE_ID`) and\n * stops at the first `]`, whitespace, or nested bracket — so it is O(1) per\n * `[` and never reintroduces the quadratic blow-up a scan-to-end would. A miss\n * returns null and the caller falls through to `tryLink`.\n */\n function tryFootnoteRef(i: number, end: number): Hit | null {\n const idStart = i + 2; // past `[^`\n const stop = Math.min(end, idStart + MAX_FOOTNOTE_ID);\n let k = idStart;\n while (k < stop) {\n const ch = buf[k];\n if (ch === ']') break;\n if (ch === ' ' || ch === '\\t' || ch === '\\n' || ch === '[' || ch === '^') return null;\n k++;\n }\n if (k >= stop || buf[k] !== ']' || k === idStart) return null;\n const node: FootnoteRef = {\n type: 'footnoteRef',\n from: abs(i),\n to: abs(k + 1),\n id: buf.slice(idStart, k),\n };\n return { node, endIdx: k + 1 };\n }\n\n function tryAutolink(i: number, end: number): Hit | null {\n let k = i + 1;\n while (k < end && buf[k] !== '>' && buf[k] !== '<' && buf[k] !== ' ' && buf[k] !== '\\n') k++;\n if (k >= end || buf[k] !== '>') return null;\n const content = buf.slice(i + 1, k);\n const isUri = /^[a-zA-Z][a-zA-Z0-9+.-]*:[^\\s]*$/.test(content);\n const isEmail = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(content);\n if (!isUri && !isEmail) return null;\n const node: Autolink = {\n type: 'autolink',\n from: abs(i),\n to: abs(k + 1),\n url: cap(content, MAX_URL),\n };\n return { node, endIdx: k + 1 };\n }\n\n /** Index of the `]` matching the `[` at `open`, or -1. */\n function matchLabel(open: number, end: number): number {\n // Bound the forward scan: link labels/text are short in practice, and an\n // unbounded scan from every `[` makes a run of unmatched brackets O(n^2)\n // (parse runs on every keystroke / streamed token).\n const stop = Math.min(end, open + 4096);\n let depth = 0;\n for (let k = open; k < stop; k++) {\n const ch = buf[k];\n if (ch === '\\\\') {\n k++;\n continue;\n }\n if (ch === '[') depth++;\n else if (ch === ']') {\n depth--;\n if (depth === 0) return k;\n }\n }\n return -1;\n }\n\n function tryLink(i: number, end: number, isImage: boolean): Hit | null {\n const br = i + (isImage ? 1 : 0);\n if (buf[br] !== '[') return null;\n const close = matchLabel(br, end);\n if (close < 0) return null;\n let k = close + 1;\n if (buf[k] !== '(') return null;\n k++;\n while (k < end && (buf[k] === ' ' || buf[k] === '\\n')) k++;\n\n let url = '';\n if (buf[k] === '<') {\n k++;\n const s = k;\n while (k < end && buf[k] !== '>' && buf[k] !== '\\n') k++;\n if (buf[k] !== '>') return null;\n url = buf.slice(s, k);\n k++;\n } else {\n const s = k;\n let depth = 0;\n while (k < end) {\n const ch = buf[k];\n if (ch === ' ' || ch === '\\n') break;\n if (ch === '(') depth++;\n else if (ch === ')') {\n if (depth === 0) break;\n depth--;\n }\n k++;\n }\n url = buf.slice(s, k);\n }\n\n let title: string | undefined;\n while (k < end && (buf[k] === ' ' || buf[k] === '\\n')) k++;\n const q = buf[k];\n if (q === '\"' || q === \"'\" || q === '(') {\n const closeCh = q === '(' ? ')' : q;\n k++;\n const s = k;\n while (k < end && buf[k] !== closeCh) k++;\n if (buf[k] !== closeCh) return null;\n title = buf.slice(s, k);\n k++;\n while (k < end && (buf[k] === ' ' || buf[k] === '\\n')) k++;\n }\n if (buf[k] !== ')') return null;\n const endIdx = k + 1;\n const from = abs(i);\n const to = abs(endIdx);\n\n if (isImage) {\n const node: Image = {\n type: 'image',\n from,\n to,\n url: cap(url, MAX_URL),\n alt: cap(buf.slice(br + 1, close), MAX_ALT),\n };\n if (title !== undefined) node.title = cap(title, MAX_TITLE);\n return { node, endIdx };\n }\n const node: Link = {\n type: 'link',\n from,\n to,\n url: cap(url, MAX_URL),\n children: parseInlineRange(br + 1, close),\n };\n if (title !== undefined) node.title = cap(title, MAX_TITLE);\n return { node, endIdx };\n }\n\n function tryEmph(i: number, end: number): Hit | null {\n const c = buf[i]!;\n let n = 1;\n while (i + n < end && buf[i + n] === c) n++;\n const isStrike = c === '~';\n if (isStrike && n < 2) return null;\n const strength = isStrike ? 2 : n >= 2 ? 2 : 1;\n if (i + strength > end) return null;\n\n const after = buf[i + strength];\n const before = buf[i - 1];\n if (isWs(after)) return null; // opener must be left-flanking\n if (c === '_' && isAlnum(before)) return null; // no intraword `_`\n\n let k = i + strength;\n while (k < end) {\n if (buf[k] === c) {\n let m = 1;\n while (k + m < end && buf[k + m] === c) m++;\n if (m >= strength) {\n const prev = buf[k - 1];\n const aft = buf[k + strength];\n if (!isWs(prev) && (c !== '_' || !isAlnum(aft))) {\n const children = parseInlineRange(i + strength, k);\n const from = abs(i);\n const to = abs(k + strength);\n let node: Inline;\n if (isStrike) {\n node = { type: 'strikethrough', from, to, children } satisfies Strikethrough;\n } else if (strength === 2) {\n node = { type: 'strong', from, to, marker: c.repeat(2), children } satisfies Strong;\n } else {\n node = { type: 'emphasis', from, to, marker: c, children } satisfies Emphasis;\n }\n return { node, endIdx: k + strength };\n }\n }\n k += m;\n continue;\n }\n k++;\n }\n return null;\n }\n\n function parseInlineRange(start: number, end: number): Inline[] {\n const out: Inline[] = [];\n let i = start;\n let textStart = start;\n const flush = (upto: number): void => {\n if (upto > textStart) out.push(text(abs(textStart), abs(upto), buf.slice(textStart, upto)));\n };\n const commit = (hit: Hit): void => {\n flush(i);\n out.push(hit.node);\n i = hit.endIdx;\n textStart = i;\n };\n\n while (i < end) {\n const c = buf[i];\n if (c === '\\\\') {\n if (buf[i + 1] === '\\n') {\n flush(i);\n out.push({ type: 'break', from: abs(i), to: abs(i + 2), hard: true } satisfies LineBreak);\n i += 2;\n textStart = i;\n continue;\n }\n i += 2; // escaped char stays part of the text run\n continue;\n }\n if (c === '\\n') {\n let sp = 0;\n let p = i - 1;\n while (p >= textStart && buf[p] === ' ') {\n sp++;\n p--;\n }\n const hard = sp >= 2;\n flush(hard ? i - sp : i);\n out.push({\n type: 'break',\n from: abs(hard ? i - sp : i),\n to: abs(i + 1),\n hard,\n } satisfies LineBreak);\n i++;\n textStart = i;\n continue;\n }\n if (c === '`') {\n const r = tryCode(i, end);\n if (r) {\n commit(r);\n continue;\n }\n i++;\n continue;\n }\n if (c === '$' && opts.math) {\n const r = tryMath(i, end);\n if (r) {\n commit(r);\n continue;\n }\n i++;\n continue;\n }\n if (c === '<') {\n const r = tryAutolink(i, end);\n if (r) {\n commit(r);\n continue;\n }\n i++;\n continue;\n }\n if (c === '!' && buf[i + 1] === '[') {\n const r = tryLink(i, end, true);\n if (r) {\n commit(r);\n continue;\n }\n i++;\n continue;\n }\n if (c === '[') {\n if (opts.footnotes && buf[i + 1] === '^') {\n const rf = tryFootnoteRef(i, end);\n if (rf) {\n commit(rf);\n continue;\n }\n }\n const r = tryLink(i, end, false);\n if (r) {\n commit(r);\n continue;\n }\n i++;\n continue;\n }\n if (c === '*' || c === '_' || c === '~') {\n const r = tryEmph(i, end);\n if (r) {\n commit(r);\n continue;\n }\n i++;\n continue;\n }\n i++;\n }\n flush(end);\n return out;\n }\n\n return parseInlineRange(0, buf.length);\n}\n\n/* ------------------------------------------------------------------ *\n * Entry point\n * ------------------------------------------------------------------ */\n\n/**\n * Parse Markdown/MDX source into an offset-exact {@link Document}.\n *\n * `options` gates the opt-in extensions (math, footnotes, definition lists);\n * every flag defaults to `false`, so `parse(src)` is unchanged from before.\n */\nexport function parse(src: string, options?: ParseOptions): Document {\n opts = {\n math: options?.math === true,\n footnotes: options?.footnotes === true,\n defLists: options?.defLists === true,\n };\n const lines = splitLines(src);\n const children = parseBlocks(lines);\n return { type: 'document', from: 0, to: src.length, children };\n}\n\n/* ------------------------------------------------------------------ *\n * Incremental reparse\n *\n * `parseIncremental` returns a document DEEP-EQUAL to `parse(nextSrc, options)`\n * but computed by reusing the leading top-level blocks of a previous parse that\n * the edit provably cannot have touched, then reparsing from the first safe block\n * boundary at/before the edit through to the end of `nextSrc`.\n *\n * Correctness rests on one invariant: every reused block's parse depends only on\n * the source PREFIX before the reparse cut, and that prefix is byte-identical in\n * `prevSrc` and `nextSrc` (the edit is entirely at/after the cut). Whenever a safe\n * cut cannot be cheaply proven, we fall back to a full `parse` — a correct result\n * is never sacrificed for a fast one.\n *\n * When possible the reparse is ALSO bounded on the RIGHT: rather than reparsing\n * from the cut to end-of-document, we reparse only the dirty block(s) plus a safe\n * look-around, then reuse the unchanged SUFFIX blocks from `prev`, re-offset by the\n * edit's length delta. That suffix reuse is only taken when a clean, self-terminated\n * dirty-region boundary can be PROVEN by a small bounded reparse that includes the\n * join line (an open fence / list / etc. that would bleed past the join makes the\n * proof fail, and we fall back to the reparse-to-EOF path — still correct, just less\n * tight). A small edit near the TOP of a large document therefore reparses a bounded\n * region instead of the whole tail. The one-way property test in\n * `parser.incremental.test.ts` is the oracle that enforces the deep-equality.\n * ------------------------------------------------------------------ */\n\n/** Instrumentation about what an incremental reparse reused vs rebuilt. */\nexport interface IncrementalStats {\n /** True when the fast path bailed and a full {@link parse} produced the result. */\n fellBack: boolean;\n /** Count of leading top-level blocks reused verbatim from the previous document. */\n reusedBlocks: number;\n /** Line index in `nextSrc` from which blocks were reparsed (0 ⇒ whole document). */\n reparsedFromLine: number;\n /**\n * Line index in `nextSrc` at which the reparsed region ENDS (exclusive). Equals\n * {@link totalLines} when the reparse ran to end-of-document (no suffix reuse); a\n * value `< totalLines` means the tail was bounded and trailing blocks were reused.\n */\n reparsedToLine: number;\n /** Count of trailing top-level blocks reused from `prev` (re-offset by the edit delta). */\n reusedSuffixBlocks: number;\n /** Total number of content lines in `nextSrc`. */\n totalLines: number;\n}\n\n/** The document plus {@link IncrementalStats} from {@link parseIncrementalWithStats}. */\nexport interface IncrementalResult {\n doc: Document;\n stats: IncrementalStats;\n}\n\ntype HeadSafety = 'always' | 'needs-blank' | 'never';\n\n/**\n * How safe it is to keep `block` as the LAST block of the reused prefix — i.e.\n * whether, once the source AFTER it changes, `block`'s parse could grow past the\n * cut and swallow the new content.\n *\n * - `always` self-delimiting or single-line: its extent never depends on\n * what follows (heading, thematic break, or a *closed* fenced /\n * `$$` block — an unclosed one runs to EOF and so is never an\n * interior block).\n * - `needs-blank` terminates only at a blank line: safe **iff** a blank line\n * sits between it and the cut. That blank, being before the edit,\n * is preserved in `nextSrc`, so no edit can un-terminate it.\n * - `never` lazily continues across blank lines by indentation, so a later\n * edit could indent a following line into it — indented code,\n * lists, footnote definitions and definition lists.\n */\nfunction headSafety(block: Block): HeadSafety {\n switch (block.type) {\n case 'heading':\n case 'thematicBreak':\n case 'mathBlock':\n return 'always';\n case 'codeBlock':\n return block.fenced ? 'always' : 'never';\n case 'paragraph':\n case 'table':\n case 'htmlBlock':\n case 'blockquote':\n return 'needs-blank';\n default:\n // list, footnoteDef, defList — loose/lazy continuation across blanks.\n return 'never';\n }\n}\n\n/** Is the source line ending just before `lineStart` (itself a line start) blank? */\nfunction prevLineIsBlank(src: string, lineStart: number): boolean {\n if (lineStart <= 0) return false;\n // `lineStart` is a line start ⇒ `src[lineStart - 1]` is the '\\n' ending the\n // previous line. Walk back to that line's own start and test it for blankness.\n const end = lineStart - 1;\n let start = end - 1;\n while (start >= 0 && src[start] !== '\\n') start--;\n start += 1;\n return src.slice(start, end).trim() === '';\n}\n\n/**\n * Like {@link prevLineIsBlank}, but ALSO requires the blank line to lie entirely at\n * or after `minStart` — i.e. wholly inside the source region the edit did not touch.\n * Used to prove a suffix-join boundary sits behind an unchanged blank separator, so\n * no construct can lazily bridge the reparsed dirty region into the reused suffix.\n */\nfunction blankLineFullyAfter(src: string, lineStart: number, minStart: number): boolean {\n if (lineStart <= 0) return false;\n const end = lineStart - 1; // the '\\n' that terminated the previous line\n let start = end - 1;\n while (start >= 0 && src[start] !== '\\n') start--;\n start += 1;\n if (start < minStart) return false; // blank line straddles / precedes the edit\n return src.slice(start, end).trim() === '';\n}\n\n/**\n * Deep-clone a block, shifting every `from`/`to` (and `contentFrom`, where present)\n * by `delta`. Used to re-offset an unchanged SUFFIX block reused from `prev` into\n * `nextSrc` coordinates without reparsing it. Walks the WHOLE subtree (nested\n * blocks, inline children, table cells, list/def items) via the shared {@link walk},\n * so no offset-bearing node is missed. `prev` is never mutated.\n */\nfunction shiftBlock(block: Block, delta: number): Block {\n const clone = structuredClone(block) as Block;\n walk(clone as AstNode, (n) => {\n const p = n as { from: number; to: number; contentFrom?: number };\n p.from += delta;\n p.to += delta;\n if (typeof p.contentFrom === 'number') p.contentFrom += delta;\n });\n return clone;\n}\n\n/** Index of the line in `lines` that begins exactly at offset `off`, or -1. */\nfunction lineStartingAt(lines: Line[], off: number): number {\n let lo = 0;\n let hi = lines.length - 1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n const f = lines[mid]!.from;\n if (f === off) return mid;\n if (f < off) lo = mid + 1;\n else hi = mid - 1;\n }\n return -1;\n}\n\n/** Largest index `k` with `blocks[k].from <= off` (blocks are offset-ordered), or -1. */\nfunction lastBlockAtOrBefore(blocks: Block[], off: number): number {\n let lo = 0;\n let hi = blocks.length - 1;\n let ans = -1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n if (blocks[mid]!.from <= off) {\n ans = mid;\n lo = mid + 1;\n } else {\n hi = mid - 1;\n }\n }\n return ans;\n}\n\n/** A proven bounded reparse: the freshly parsed dirty blocks + the reused, re-offset suffix. */\ninterface SuffixReuse {\n /** Freshly parsed dirty blocks, already carrying absolute `nextSrc` offsets. */\n dirty: Block[];\n /** Trailing blocks reused from `prev`, re-offset by the edit delta. */\n shifted: Block[];\n /** Line index in `nextSrc` at which the reparsed dirty region ends (exclusive). */\n endLine: number;\n /** Count of reused suffix blocks. */\n count: number;\n}\n\n/** Cap on how many join candidates we probe before giving up (bounds worst-case cost). */\nconst MAX_JOIN_ATTEMPTS = 4;\n\n/**\n * Try to bound the reparse on the RIGHT so a small edit near the top of a large doc\n * does not reparse the whole tail. Given the prefix cut (`cLine`/`k` already chosen),\n * find a prev block boundary AFTER the change whose reuse can be PROVEN sound, reparse\n * only `[cLine, joinLine)`, and reuse the trailing prev blocks re-offset by `delta`.\n *\n * Correctness rests on three facts:\n * 1. Suffix content is byte-identical (shifted by `delta`) — guaranteed by only\n * considering join offsets `>= to` (everything at/after the edit is unchanged).\n * 2. `parseBlocks` is strictly left-to-right, so the reused suffix `blocks[j..]`\n * equals `parseBlocks(nextLines.slice(joinLine))` shifted — *provided* a real\n * block boundary exists at the join in the full parse of `nextSrc`.\n * 3. That boundary is PROVEN by a bounded reparse that includes the join line: if\n * a block starts exactly at the join offset, no open construct (fence, list,\n * indented code, …) from the dirty region bled across it. If the proof fails we\n * return `null` and the caller falls back to reparse-to-EOF (still correct).\n * `opts` must already be set for `parseBlocks`.\n */\nfunction tryReuseSuffix(\n blocks: Block[],\n prevSrc: string,\n to: number,\n delta: number,\n nextLines: Line[],\n cLine: number,\n): SuffixReuse | null {\n // Last prev block starting at/before the change end — the dirty region covers it;\n // the first reuse candidate is the block after it.\n const dEnd = lastBlockAtOrBefore(blocks, to);\n let attempts = 0;\n for (let j = dEnd + 1; j < blocks.length; j++) {\n const joinOff = blocks[j]!.from;\n if (joinOff < to) continue; // suffix must be entirely in the unchanged region\n // A blank line wholly inside the unchanged region must precede the join, so no\n // lazily-continuing construct can bridge the dirty region into the suffix.\n if (!blankLineFullyAfter(prevSrc, joinOff, to)) continue;\n const nextJoinOff = joinOff + delta;\n const joinLine = lineStartingAt(nextLines, nextJoinOff);\n if (joinLine <= cLine) continue; // must reparse a non-empty region below the cut\n\n if (++attempts > MAX_JOIN_ATTEMPTS) break; // bound the probing cost, then fall back\n\n // Bounded, boundary-proving reparse: include the join line. A block starting\n // exactly at `nextJoinOff` proves the dirty region self-terminates there.\n const guard = parseBlocks(nextLines.slice(cLine, joinLine + 1));\n const dirty: Block[] = [];\n let proven = false;\n for (const b of guard) {\n if (b.from === nextJoinOff) {\n proven = true;\n break;\n }\n if (b.from > nextJoinOff) break; // overshot ⇒ no clean boundary here\n dirty.push(b);\n }\n if (!proven) continue; // an open construct crossed the join — try the next candidate\n\n const rest = blocks.slice(j);\n // Always clone the reused suffix — even at `delta === 0`. Returning `prev`'s\n // own block objects would alias subtrees between the old and new documents;\n // `shiftBlock(b, 0)` is a pure structuredClone (no-op offset shift), so the\n // returned tree never shares node identity with `prev`. (Insertions already\n // pay this clone; a same-length edit is no different.)\n const shifted = rest.map((b) => shiftBlock(b, delta));\n return { dirty, shifted, endLine: joinLine, count: rest.length };\n }\n return null;\n}\n\nfunction runIncremental(\n prev: Document,\n prevSrc: string,\n change: Change,\n nextSrc: string,\n options: ParseOptions | undefined,\n): IncrementalResult {\n const nextLines = splitLines(nextSrc);\n const total = nextLines.length;\n const full = (): IncrementalResult => ({\n doc: parse(nextSrc, options),\n stats: {\n fellBack: true,\n reusedBlocks: 0,\n reparsedFromLine: 0,\n reparsedToLine: total,\n reusedSuffixBlocks: 0,\n totalLines: total,\n },\n });\n\n // Normalize + validate the change against prevSrc. A malformed or inconsistent\n // change is never trusted — a correct full parse is always the safe answer.\n const from = Math.max(0, Math.min(change.from, change.to));\n const to = Math.min(prevSrc.length, Math.max(change.from, change.to));\n if (to < from) return full();\n if (nextSrc.length !== prevSrc.length + change.insert.length - (to - from)) return full();\n // Every candidate cut satisfies `cut <= from`, so a single check that the\n // prefix `[0, from)` is byte-identical proves every reused prefix identical.\n if (prevSrc.slice(0, from) !== nextSrc.slice(0, from)) return full();\n\n // Offset shift applied to any source position at/after the edit end `to`.\n const delta = change.insert.length - (to - from);\n\n const blocks = prev.children;\n const hi = Math.min(blocks.length - 1, lastBlockAtOrBefore(blocks, from));\n for (let k = hi; k >= 1; k--) {\n const cut = blocks[k]!.from; // reuse blocks[0..k-1]; reparse from `cut`\n if (cut > from) continue; // head must lie entirely before the edit\n const safety = headSafety(blocks[k - 1]!);\n if (safety === 'never') continue;\n if (safety === 'needs-blank' && !prevLineIsBlank(prevSrc, cut)) continue;\n const c = lineStartingAt(nextLines, cut);\n if (c < 0) continue; // `cut` is not a line start in nextSrc (should not happen)\n\n // The reparse runs `parseBlocks`, which reads the module-scoped `opts`; set\n // them from `options` so the reparsed region matches a full parse exactly.\n opts = {\n math: options?.math === true,\n footnotes: options?.footnotes === true,\n defLists: options?.defLists === true,\n };\n\n // Try to bound the reparse on the right and reuse the unchanged suffix; this\n // is what makes a top-of-doc edit cheap. If no clean boundary can be proven,\n // fall back to reparsing the whole tail (still correct, just not as tight).\n const suffix = tryReuseSuffix(blocks, prevSrc, to, delta, nextLines, c);\n if (suffix) {\n const children = blocks.slice(0, k).concat(suffix.dirty, suffix.shifted);\n return {\n doc: { type: 'document', from: 0, to: nextSrc.length, children },\n stats: {\n fellBack: false,\n reusedBlocks: k,\n reparsedFromLine: c,\n reparsedToLine: suffix.endLine,\n reusedSuffixBlocks: suffix.count,\n totalLines: total,\n },\n };\n }\n\n const tail = parseBlocks(nextLines.slice(c));\n const children = blocks.slice(0, k).concat(tail);\n return {\n doc: { type: 'document', from: 0, to: nextSrc.length, children },\n stats: {\n fellBack: false,\n reusedBlocks: k,\n reparsedFromLine: c,\n reparsedToLine: total,\n reusedSuffixBlocks: 0,\n totalLines: total,\n },\n };\n }\n return full();\n}\n\n/**\n * Incrementally reparse `prev` (the parse of `prevSrc`) after a single\n * {@link Change} produced `nextSrc`. The result is deep-equal to\n * `parse(nextSrc, options)`; pass the SAME `options` that produced `prev`.\n */\nexport function parseIncremental(\n prev: Document,\n prevSrc: string,\n change: Change,\n nextSrc: string,\n options?: ParseOptions,\n): Document {\n return runIncremental(prev, prevSrc, change, nextSrc, options).doc;\n}\n\n/** {@link parseIncremental} plus {@link IncrementalStats} about what was reused. */\nexport function parseIncrementalWithStats(\n prev: Document,\n prevSrc: string,\n change: Change,\n nextSrc: string,\n options?: ParseOptions,\n): IncrementalResult {\n return runIncremental(prev, prevSrc, change, nextSrc, options);\n}\n","/**\n * AST → sanitized HTML renderer.\n *\n * This is the `read`/`preview` output path (SPEC.md §4): it walks the offset-exact\n * AST produced by the parser and emits HTML that is safe to inject into a host\n * page. Safety is structural, not incidental:\n *\n * - every text / attribute value is HTML-escaped (`&`, `<`, `>`, `\"`);\n * - every URL passes {@link safeUrl}, so `javascript:` / `data:` / other active\n * schemes collapse to `#`;\n * - raw HTML / MDX blocks are emitted ESCAPED inside `<pre>` — this renderer\n * never re-emits untrusted markup, so it can be used on model output;\n * - footnote / definition ids are slugged to a URL-safe charset *and* escaped\n * before they reach an `id`/`href` attribute.\n *\n * The renderer never throws: malformed / partial nodes degrade to escaped text.\n *\n * {@link RenderOptions} lets a host plug in escaped-HTML producers for the two\n * constructs the core cannot render on its own — syntax highlighting and a math\n * engine. Both are trusted to return already-escaped HTML; without them the\n * renderer falls back to the safe escaped-source form. Passing no options\n * reproduces the exact default behaviour.\n */\n\nimport { walk } from './ast';\nimport type {\n Block,\n Document,\n FootnoteDef,\n Inline,\n ListItem,\n Table,\n TableCell,\n} from './ast';\n\n/** Hard cap on a URL length we are willing to place in an attribute. */\nconst MAX_URL = 8192;\n/** Schemes we consider inert enough to keep. */\nconst SAFE_SCHEMES = /^(https?:|mailto:)/;\n\n/* ------------------------------------------------------------------ *\n * Host-supplied render hooks\n * ------------------------------------------------------------------ */\n\n/**\n * Optional, host-supplied output producers for constructs the core cannot\n * render itself. Both hooks MUST return already-escaped, safe HTML — the\n * renderer trusts their output and does not re-escape it. Omitting a hook (or\n * the whole object) falls back to the safe escaped-source form.\n */\nexport interface RenderOptions {\n /**\n * Syntax highlighter for fenced code. Receives the fence info string and the\n * raw code; returns escaped HTML (e.g. `<span class=\"tw-tok-…\">` runs). The\n * host is responsible for escaping — see {@link highlightToHtml}.\n */\n highlight?: (lang: string, code: string) => string;\n /**\n * Math engine. Receives the TeX source and whether it is display math;\n * returns escaped/safe HTML. Without it, math renders as escaped source.\n */\n math?: (src: string, display: boolean) => string;\n}\n\n/**\n * Per-render footnote numbering context. Footnote references are numbered in\n * first-seen order across a single render pass (keyed by the slugged id, so\n * repeated references to the same note share a number). Held in a small object\n * threaded through the walk rather than in module state, so rendering stays\n * re-entrant.\n */\ninterface FnCtx {\n /** Slugged footnote id → its 1-based display number, in first-seen order. */\n nums: Map<string, number>;\n}\n\nfunction newFnCtx(): FnCtx {\n return { nums: new Map() };\n}\n\n/** The display number for a footnote id, allocating one on first sight. */\nfunction fnNumber(ctx: FnCtx, slug: string): number {\n const existing = ctx.nums.get(slug);\n if (existing !== undefined) return existing;\n const n = ctx.nums.size + 1;\n ctx.nums.set(slug, n);\n return n;\n}\n\n/* ------------------------------------------------------------------ *\n * Escaping + URL safety\n * ------------------------------------------------------------------ */\n\n/** Escape the five characters that matter in HTML text / double-quoted attrs. */\nfunction escapeHtml(value: string): string {\n let out = '';\n for (let i = 0; i < value.length; i++) {\n const ch = value.charCodeAt(i);\n switch (ch) {\n case 38 /* & */:\n out += '&';\n break;\n case 60 /* < */:\n out += '<';\n break;\n case 62 /* > */:\n out += '>';\n break;\n case 34 /* \" */:\n out += '"';\n break;\n default:\n out += value[i];\n }\n }\n return out;\n}\n\n/**\n * Reduce a footnote label to a slug that is safe both as an `id` attribute and\n * as a `#fragment` in an `href`: keep ASCII letters/digits/`_`/`-`, collapse any\n * other run to a single `-`. An empty result falls back to `_` so the id is\n * never blank. The same slug is applied to refs and defs, so their ids match.\n */\nfunction slugFootnoteId(id: string): string {\n const slug = id.replace(/[^A-Za-z0-9_-]+/g, '-');\n return slug === '' ? '_' : slug;\n}\n\n/**\n * Return `url` when it is safe to place in an `href`/`src`, otherwise `'#'`.\n *\n * Safe = an http/https/mailto absolute URL, OR anything without an explicit\n * scheme (relative paths, `?query`, `#anchor`, protocol-relative `//host`).\n * Any other scheme (`javascript:`, `data:`, `vbscript:`, `file:`, …) is denied.\n *\n * Scheme detection is done against a copy with whitespace + control characters\n * stripped, so obfuscations like `java\\tscript:` or a leading newline can't\n * smuggle an active scheme past the check.\n */\nexport function safeUrl(url: string): string {\n if (typeof url !== 'string' || url.length === 0) return '#';\n const trimmed = url.trim().slice(0, MAX_URL);\n if (trimmed === '') return '#';\n\n // Fold away whitespace + C0/DEL controls for the scheme test ONLY.\n const probe = trimmed.replace(/[\\u0000-\\u0020\\u007f]/g, '').toLowerCase();\n if (probe === '') return '#';\n\n // An allowed absolute scheme is fine.\n if (SAFE_SCHEMES.test(probe)) return trimmed;\n\n // Any OTHER explicit scheme (letter run followed by a colon) is denied.\n // Relative / anchor / protocol-relative URLs never match (they start with\n // `#`, `/`, `.`, `?`, or a bare path segment with no leading scheme colon).\n if (/^[a-z][a-z0-9+.-]*:/.test(probe)) return '#';\n\n return trimmed;\n}\n\n/** Convenience: an escaped, safety-checked URL ready for an attribute. */\nfunction attrUrl(url: string): string {\n return escapeHtml(safeUrl(url));\n}\n\n/* ------------------------------------------------------------------ *\n * Inline\n * ------------------------------------------------------------------ */\n\n/** Render a run of inline nodes to sanitized HTML. */\nexport function renderInline(nodes: Inline[], options?: RenderOptions): string {\n return inlineRun(nodes, options, newFnCtx());\n}\n\nfunction inlineRun(\n nodes: Inline[],\n options: RenderOptions | undefined,\n ctx: FnCtx,\n): string {\n let out = '';\n for (const node of nodes) out += renderInlineNode(node, options, ctx);\n return out;\n}\n\nfunction renderInlineNode(\n node: Inline,\n options: RenderOptions | undefined,\n ctx: FnCtx,\n): string {\n switch (node.type) {\n case 'text':\n return escapeHtml(node.value);\n case 'strong':\n return `<strong>${inlineRun(node.children, options, ctx)}</strong>`;\n case 'emphasis':\n return `<em>${inlineRun(node.children, options, ctx)}</em>`;\n case 'strikethrough':\n return `<del>${inlineRun(node.children, options, ctx)}</del>`;\n case 'inlineCode':\n return `<code>${escapeHtml(node.value)}</code>`;\n case 'link': {\n const title = node.title ? ` title=\"${escapeHtml(node.title)}\"` : '';\n return `<a href=\"${attrUrl(node.url)}\"${title}>${inlineRun(node.children, options, ctx)}</a>`;\n }\n case 'image': {\n const title = node.title ? ` title=\"${escapeHtml(node.title)}\"` : '';\n return `<img src=\"${attrUrl(node.url)}\" alt=\"${escapeHtml(node.alt)}\"${title}>`;\n }\n case 'autolink':\n return `<a href=\"${attrUrl(node.url)}\">${escapeHtml(node.url)}</a>`;\n case 'break':\n return node.hard ? '<br>\\n' : '\\n';\n case 'math':\n // Host math engine (trusted, returns escaped HTML) or safe escaped source.\n return options?.math\n ? options.math(node.value, node.display)\n : `<span class=\"tw-math-src\">${escapeHtml(node.value)}</span>`;\n case 'footnoteRef': {\n // GitHub-style superscript back-reference. The def with the matching id\n // is collected + rendered once at the end of the document (see\n // renderToHtml). Number is first-seen order; id links the two ends.\n const slug = slugFootnoteId(node.id);\n const n = fnNumber(ctx, slug);\n const safe = escapeHtml(slug);\n return `<sup class=\"tw-fnref\" id=\"fnref-${safe}\"><a href=\"#fn-${safe}\">[${n}]</a></sup>`;\n }\n default: {\n // Exhaustiveness guard — a new inline type must be handled above.\n const _never: never = node;\n return _never as never;\n }\n }\n}\n\n/* ------------------------------------------------------------------ *\n * Blocks\n * ------------------------------------------------------------------ */\n\n/** Render a single block node to sanitized HTML. */\nexport function renderNode(node: Block, options?: RenderOptions): string {\n return renderBlockNode(node, options, newFnCtx());\n}\n\nfunction renderBlockNode(\n node: Block,\n options: RenderOptions | undefined,\n ctx: FnCtx,\n): string {\n switch (node.type) {\n case 'heading': {\n const l = node.level;\n return `<h${l}>${inlineRun(node.children, options, ctx)}</h${l}>`;\n }\n case 'paragraph':\n return `<p>${inlineRun(node.children, options, ctx)}</p>`;\n case 'blockquote':\n return `<blockquote>${renderBlocks(node.children, options, ctx)}</blockquote>`;\n case 'list':\n return renderList(node.ordered, node.start, node.tight, node.items, options, ctx);\n case 'codeBlock': {\n const cls = node.lang\n ? ` class=\"language-${escapeHtml(node.lang)}\"`\n : '';\n // The highlighter is trusted to return escaped HTML; the default path\n // escapes here so raw code is never emitted live either way.\n const body = options?.highlight\n ? options.highlight(node.lang, node.value)\n : escapeHtml(node.value);\n return `<pre><code${cls}>${body}</code></pre>`;\n }\n case 'thematicBreak':\n return '<hr>';\n case 'table':\n return renderTable(node, options, ctx);\n case 'htmlBlock':\n // The safety boundary: raw HTML / MDX is emitted ESCAPED, never live.\n return `<pre>${escapeHtml(node.value)}</pre>`;\n case 'mathBlock':\n // A math block is always display math; host engine or escaped source.\n return options?.math\n ? options.math(node.value, true)\n : `<div class=\"tw-math-src\">${escapeHtml(node.value)}</div>`;\n case 'footnoteDef':\n // Canonical placement is the collected <section> that renderToHtml\n // appends. A standalone renderNode(footnoteDef) still renders its body\n // for completeness (renderBlocks skips defs only in document flow).\n return `<div class=\"tw-footnote-def\">${renderBlocks(node.children, options, ctx)}</div>`;\n case 'defList': {\n let out = '';\n for (const item of node.items) {\n out += `<dt>${inlineRun(item.term, options, ctx)}</dt>`;\n for (const def of item.definitions) {\n out += `<dd>${renderBlocks(def, options, ctx)}</dd>`;\n }\n }\n return `<dl>${out}</dl>`;\n }\n default: {\n const _never: never = node;\n return _never as never;\n }\n }\n}\n\n/**\n * Render a sequence of blocks in document flow. Footnote definitions are\n * skipped here: they are collected by {@link renderToHtml} and emitted once as\n * a trailing `<section>`, never inline where they were authored.\n */\nfunction renderBlocks(\n blocks: Block[],\n options: RenderOptions | undefined,\n ctx: FnCtx,\n): string {\n let out = '';\n for (const b of blocks) {\n if (b.type === 'footnoteDef') continue;\n out += renderBlockNode(b, options, ctx);\n }\n return out;\n}\n\nfunction renderList(\n ordered: boolean,\n start: number,\n tight: boolean,\n items: ListItem[],\n options: RenderOptions | undefined,\n ctx: FnCtx,\n): string {\n const tag = ordered ? 'ol' : 'ul';\n const startAttr =\n ordered && Number.isFinite(start) && start !== 1\n ? ` start=\"${escapeHtml(String(Math.trunc(start)))}\"`\n : '';\n let body = '';\n for (const item of items) body += renderListItem(item, tight, options, ctx);\n return `<${tag}${startAttr}>${body}</${tag}>`;\n}\n\nfunction renderListItem(\n item: ListItem,\n tight: boolean,\n options: RenderOptions | undefined,\n ctx: FnCtx,\n): string {\n let checkbox = '';\n if (item.task !== null) {\n const checked = item.task === 'checked' ? ' checked' : '';\n checkbox = `<input type=\"checkbox\" disabled${checked}> `;\n }\n return `<li>${checkbox}${renderItemChildren(item.children, tight, options, ctx)}</li>`;\n}\n\n/**\n * In a tight list a lone paragraph child renders WITHOUT its `<p>` wrapper\n * (GFM tight-list behaviour), so a task item reads `<li><input…> text</li>`.\n * Loose lists keep full block structure.\n */\nfunction renderItemChildren(\n children: Block[],\n tight: boolean,\n options: RenderOptions | undefined,\n ctx: FnCtx,\n): string {\n if (tight) {\n let out = '';\n for (const child of children) {\n out +=\n child.type === 'paragraph'\n ? inlineRun(child.children, options, ctx)\n : renderBlockNode(child, options, ctx);\n }\n return out;\n }\n return renderBlocks(children, options, ctx);\n}\n\nfunction renderTable(\n node: Table,\n options: RenderOptions | undefined,\n ctx: FnCtx,\n): string {\n const align = node.align;\n const cellStyle = (col: number): string => {\n const a = align[col];\n return a ? ` style=\"text-align:${a}\"` : '';\n };\n\n const headCells = renderRow(node.header, 'th', cellStyle, options, ctx);\n const head = `<thead><tr>${headCells}</tr></thead>`;\n\n let bodyRows = '';\n for (const row of node.rows) {\n bodyRows += `<tr>${renderRow(row, 'td', cellStyle, options, ctx)}</tr>`;\n }\n const body = `<tbody>${bodyRows}</tbody>`;\n\n return `<table>${head}${body}</table>`;\n}\n\nfunction renderRow(\n cells: TableCell[],\n tag: 'th' | 'td',\n cellStyle: (col: number) => string,\n options: RenderOptions | undefined,\n ctx: FnCtx,\n): string {\n let out = '';\n for (let i = 0; i < cells.length; i++) {\n const cell = cells[i]!;\n out += `<${tag}${cellStyle(i)}>${inlineRun(cell.children, options, ctx)}</${tag}>`;\n }\n return out;\n}\n\n/* ------------------------------------------------------------------ *\n * Document\n * ------------------------------------------------------------------ */\n\n/** Every footnote definition in the document, in document order. */\nfunction collectFootnoteDefs(doc: Document): FootnoteDef[] {\n const defs: FootnoteDef[] = [];\n walk(doc, (n) => {\n if (n.type === 'footnoteDef') {\n defs.push(n);\n return false; // don't descend into a def's body while collecting\n }\n return true;\n });\n return defs;\n}\n\n/** Render a whole document to sanitized HTML. */\nexport function renderToHtml(doc: Document, options?: RenderOptions): string {\n const ctx = newFnCtx();\n let out = renderBlocks(doc.children, options, ctx);\n\n // Collect every footnote definition (from anywhere in the tree) and emit it\n // once, GitHub-style, as a trailing ordered list with a back-link per note.\n const defs = collectFootnoteDefs(doc);\n if (defs.length > 0) {\n let items = '';\n for (const def of defs) {\n const safe = escapeHtml(slugFootnoteId(def.id));\n items +=\n `<li id=\"fn-${safe}\">` +\n renderBlocks(def.children, options, ctx) +\n ` <a href=\"#fnref-${safe}\" class=\"tw-fn-back\">↩</a>` +\n `</li>`;\n }\n out += `<section class=\"tw-footnotes\"><ol>${items}</ol></section>`;\n }\n\n return out;\n}\n","/**\n * Unified (Obsidian-style live-preview) source-revealing logic.\n *\n * In `unified` mode the formatting renders inline, but the raw syntax markers\n * (a heading's `### `, an emphasis `*`, a link's `](url)`, …) are hidden UNLESS\n * the caret/selection is on top of them — then they reveal so you can edit the\n * source. This module is pure and offset-exact: it maps the AST to the set of\n * hideable marker ranges (`collectMarkers`) and decides which stay hidden for a\n * given selection (`hiddenMarkers`). It never mutates the tree or the string.\n */\n\nimport { walk } from './ast';\nimport type { Document, Pos } from './ast';\n\n/**\n * A hideable syntax-marker range: `[from, to)` with a `kind` tag.\n *\n * `kind` is an open string (not a closed union) so new marker families can be\n * added without a breaking type change. The kinds currently emitted are\n * `heading`, `emphasis`, `strong`, `strike`, `code`, `link`, `image`,\n * `listMarker`, `math`, `footnoteRef`, `fence` and `blockquote`.\n */\nexport interface Marker extends Pos {\n kind: string;\n}\n\n/**\n * Every hideable syntax-marker range in the document, in document order.\n *\n * Covers: heading `#… ` prefixes, the two emphasis/strong/strike delimiter runs\n * on each side, inline-code backtick fences, link `[`/`](`/url/`)` pieces, the\n * image `!` (plus its bracket/paren pieces), list-item markers, inline-math `$`\n * (or `$$`) delimiters, and footnote-reference `[^`/`]` brackets.\n *\n * When the original `source` string is supplied it additionally emits the\n * `fence` (opening + closing fenced-code lines) and `blockquote` (the leading\n * `>` run on each quoted line) markers — these need the raw text to be\n * offset-exact, so they are omitted when `source` is not passed (keeping the\n * source-free call identical to before). Always pure; never mutates.\n */\nexport function collectMarkers(doc: Document, source?: string): Marker[] {\n const markers: Marker[] = [];\n const push = (from: number, to: number, kind: string): void => {\n if (to > from) markers.push({ from, to, kind });\n };\n\n walk(doc, (node) => {\n switch (node.type) {\n case 'heading': {\n // '#… ' prefix up to the start of content.\n push(node.from, node.contentFrom, 'heading');\n break;\n }\n case 'emphasis':\n case 'strong':\n case 'strikethrough': {\n const kind = node.type === 'strikethrough' ? 'strike' : node.type;\n const kids = node.children;\n const first = kids[0];\n const last = kids[kids.length - 1];\n const innerFrom = first ? first.from : node.to;\n const innerTo = last ? last.to : node.from;\n push(node.from, innerFrom, kind); // opening delimiter run\n push(innerTo, node.to, kind); // closing delimiter run\n break;\n }\n case 'inlineCode': {\n const ticks = Math.max(1, node.ticks);\n const openTo = Math.min(node.from + ticks, node.to);\n const closeFrom = Math.max(node.to - ticks, openTo);\n push(node.from, openTo, 'code'); // opening backtick fence\n push(closeFrom, node.to, 'code'); // closing backtick fence\n break;\n }\n case 'link': {\n const kids = node.children;\n const last = kids[kids.length - 1];\n const textEnd = last ? last.to : node.from + 1;\n const midTo = Math.min(textEnd + 2, node.to);\n push(node.from, Math.min(node.from + 1, node.to), 'link'); // '['\n push(textEnd, midTo, 'link'); // ']('\n push(midTo, node.to - 1, 'link'); // url (+ optional title)\n push(Math.max(node.to - 1, node.from), node.to, 'link'); // ')'\n break;\n }\n case 'image': {\n const bracketOpen = node.from + 1;\n const altStart = bracketOpen + 1;\n const altEnd = Math.min(altStart + node.alt.length, node.to);\n const midTo = Math.min(altEnd + 2, node.to);\n push(node.from, Math.min(node.from + 1, node.to), 'image'); // '!'\n push(bracketOpen, Math.min(bracketOpen + 1, node.to), 'image'); // '['\n push(altEnd, midTo, 'image'); // ']('\n push(midTo, node.to - 1, 'image'); // url (+ optional title)\n push(Math.max(node.to - 1, node.from), node.to, 'image'); // ')'\n break;\n }\n case 'listItem': {\n // The list marker up to the start of item content (`- `, `1. `, `- [x] `).\n push(node.from, node.contentFrom, 'listMarker');\n break;\n }\n case 'math': {\n // The `$` (inline) / `$$` (display) fences on each side of the source.\n const delim = node.display ? 2 : 1;\n const openTo = Math.min(node.from + delim, node.to);\n const closeFrom = Math.max(node.to - delim, openTo);\n push(node.from, openTo, 'math'); // opening `$`/`$$`\n push(closeFrom, node.to, 'math'); // closing `$`/`$$`\n break;\n }\n case 'footnoteRef': {\n // `[^` opener and `]` closer; the id between them stays as content.\n const openTo = Math.min(node.from + 2, node.to);\n const closeFrom = Math.max(node.to - 1, openTo);\n push(node.from, openTo, 'footnoteRef'); // `[^`\n push(closeFrom, node.to, 'footnoteRef'); // `]`\n break;\n }\n case 'codeBlock': {\n // Only *fenced* blocks have marker lines (indented code has none), and\n // we need the raw text to locate the fence lines offset-exactly.\n if (!source || !node.fenced) break;\n // Opening fence line: the ``` `` ``/`~~~` run + info string, up to the\n // end of that first source line (the trailing newline is excluded).\n let openTo = source.indexOf('\\n', node.from);\n if (openTo === -1 || openTo > node.to) openTo = node.to;\n if (openTo > node.from && source[openTo - 1] === '\\r') openTo--;\n push(node.from, openTo, 'fence'); // opening fence line\n // Closing fence line: the block's last source line, emitted only when it\n // is a real closing fence. An unterminated fence's last line is content\n // (the parser would have closed on a genuine fence line), so the regex\n // check never false-fires; a container-nested close that does not sit at\n // the physical line start simply isn't emitted (never a wrong offset).\n const closeStart = source.lastIndexOf('\\n', node.to - 1) + 1;\n if (closeStart > node.from) {\n const closeText = source.slice(closeStart, node.to);\n const cm = /^( {0,3})(`{3,}|~{3,}) *$/.exec(closeText);\n const om = /^ {0,3}([`~])/.exec(source.slice(node.from, openTo));\n if (cm && om && cm[2]![0] === om[1]) push(closeStart, node.to, 'fence'); // closing fence line\n }\n break;\n }\n case 'blockquote': {\n if (!source) break;\n // Emit the leading `>` run per line only for a *root* blockquote whose\n // first line starts at a physical line boundary. For such a blockquote\n // every line in [from,to) begins with its quote run, which we can read\n // directly and offset-exactly. A blockquote nested inside another (its\n // `from` sits after an outer `>` prefix) is skipped — its prefixes are\n // already covered by the outer root's full per-line run.\n const lineStart = source.lastIndexOf('\\n', node.from - 1) + 1;\n if (lineStart !== node.from) break;\n let p = node.from;\n while (p < node.to) {\n let end = source.indexOf('\\n', p);\n if (end === -1 || end > node.to) end = node.to;\n // The stacked quote prefix on this line: `( {0,3}> ?)+`.\n const qm = /^(?: {0,3}> ?)+/.exec(source.slice(p, end));\n if (qm) push(p, p + qm[0].length, 'blockquote');\n p = end + 1; // step over the newline; exits when end === node.to\n }\n break;\n }\n }\n return true;\n });\n\n return markers;\n}\n\n/**\n * The markers that stay HIDDEN for a given selection: those whose `[from, to)`\n * does NOT intersect the selection widened by 1 on each side. Markers that DO\n * intersect are revealed (returned excluded), so the caret can edit the raw\n * syntax it sits on — the live-preview reveal rule.\n *\n * `source` is forwarded to {@link collectMarkers} so the fence/blockquote\n * markers participate in the reveal too; omit it to keep the source-free set.\n * The selection filter itself is unchanged.\n */\nexport function hiddenMarkers(\n doc: Document,\n sel: { from: number; to: number },\n source?: string,\n): Marker[] {\n const lo = Math.min(sel.from, sel.to) - 1;\n const hi = Math.max(sel.from, sel.to) + 1;\n // Half-open overlap of marker [from,to) with widened selection [lo,hi).\n const intersects = (m: Marker): boolean => m.from < hi && lo < m.to;\n return collectMarkers(doc, source).filter((m) => !intersects(m));\n}\n\n/**\n * Index into `doc.children` of the top-level block whose inclusive `[from, to]`\n * range contains `offset`, or -1 when the offset falls in a gap between blocks.\n */\nexport function activeBlockIndex(doc: Document, offset: number): number {\n const blocks = doc.children;\n for (let i = 0; i < blocks.length; i++) {\n const b = blocks[i];\n if (b && offset >= b.from && offset <= b.to) return i;\n }\n return -1;\n}\n","/**\n * Heading-based folding.\n *\n * A heading folds away everything from the end of its line down to (but not\n * including) the next heading of the same or higher level — the standard\n * \"collapse a section\" affordance. Pure and offset-exact.\n */\n\nimport type { Document } from './ast';\n\n/** A foldable region owned by a heading. `[from, to)` is the collapsible body. */\nexport interface FoldRange {\n /** Offset where the owning heading starts (its `#`). */\n headingFrom: number;\n /** The heading's level (1–6). */\n level: number;\n /** Start of the collapsible body — the end of the heading line. */\n from: number;\n /** End of the collapsible body — the next same-or-higher heading, or doc end. */\n to: number;\n}\n\n/**\n * One `FoldRange` per top-level heading: `from` is the heading node's `to` (end\n * of the heading line), `to` is the `from` of the next heading whose level is\n * `<=` this heading's level (or the document's `to` if there is none). Ranges\n * with an empty body (`to <= from`) are omitted.\n */\nexport function headingFoldRanges(doc: Document): FoldRange[] {\n const blocks = doc.children;\n const ranges: FoldRange[] = [];\n\n for (let i = 0; i < blocks.length; i++) {\n const h = blocks[i];\n if (!h || h.type !== 'heading') continue;\n\n let to = doc.to;\n for (let j = i + 1; j < blocks.length; j++) {\n const n = blocks[j];\n if (n && n.type === 'heading' && n.level <= h.level) {\n to = n.from;\n break;\n }\n }\n\n const from = h.to;\n if (to > from) {\n ranges.push({ headingFrom: h.from, level: h.level, from, to });\n }\n }\n\n return ranges;\n}\n","/**\n * Editing commands — pure transforms over `(text, selection)` used by the\n * formatting toolbar and keyboard shortcuts. Each returns the new text and the\n * new selection, so the caller (edit textarea / unified active block) can apply\n * it and restore the caret. Pure and framework-free — fully unit-testable.\n */\n\nexport type Command =\n | 'bold'\n | 'italic'\n | 'strikethrough'\n | 'inlineCode'\n | 'link'\n | 'heading1'\n | 'heading2'\n | 'heading3'\n | 'heading4'\n | 'heading5'\n | 'heading6'\n | 'bulletList'\n | 'orderedList'\n | 'taskList'\n | 'quote'\n | 'horizontalRule'\n | 'codeBlock'\n | 'table';\n\n/** Metadata describing a command for enumerable surfaces (toolbar, palette, keymap). */\nexport interface CommandMeta {\n id: Command;\n label: string;\n /** Display shortcut (e.g. `⌘B`) when one is bound; omitted otherwise. */\n kbd?: string;\n group: 'inline' | 'block' | 'insert';\n}\n\n/**\n * The single source of truth enumerating every command — consumed by the\n * formatting toolbar, the command palette, and the keymap. Plain data, no side\n * effects; one entry per `Command` id (kept exhaustive by the `applyCommand`\n * `never` guard, which forces new ids to exist before they can be listed here).\n */\nexport const COMMANDS: readonly CommandMeta[] = [\n { id: 'bold', label: 'Bold', kbd: '⌘B', group: 'inline' },\n { id: 'italic', label: 'Italic', kbd: '⌘I', group: 'inline' },\n { id: 'strikethrough', label: 'Strikethrough', group: 'inline' },\n { id: 'inlineCode', label: 'Inline Code', kbd: '⌘E', group: 'inline' },\n { id: 'link', label: 'Link', kbd: '⌘K', group: 'inline' },\n { id: 'heading1', label: 'Heading 1', group: 'block' },\n { id: 'heading2', label: 'Heading 2', group: 'block' },\n { id: 'heading3', label: 'Heading 3', group: 'block' },\n { id: 'heading4', label: 'Heading 4', group: 'block' },\n { id: 'heading5', label: 'Heading 5', group: 'block' },\n { id: 'heading6', label: 'Heading 6', group: 'block' },\n { id: 'bulletList', label: 'Bullet List', group: 'block' },\n { id: 'orderedList', label: 'Ordered List', group: 'block' },\n { id: 'taskList', label: 'Task List', group: 'block' },\n { id: 'quote', label: 'Quote', group: 'block' },\n { id: 'horizontalRule', label: 'Horizontal Rule', group: 'insert' },\n { id: 'codeBlock', label: 'Code Block', group: 'insert' },\n { id: 'table', label: 'Table', group: 'insert' },\n];\n\nexport interface Sel {\n from: number;\n to: number;\n}\n\nexport interface CommandResult {\n text: string;\n selection: Sel;\n}\n\nfunction norm(sel: Sel): Sel {\n return { from: Math.min(sel.from, sel.to), to: Math.max(sel.from, sel.to) };\n}\n\n/** Toggle-wrap the selection in a symmetric inline marker (e.g. `**`). */\nfunction toggleWrap(text: string, sel: Sel, marker: string): CommandResult {\n const len = marker.length;\n const { from, to } = norm(sel);\n\n // already wrapped just OUTSIDE the selection → unwrap\n if (from >= len && text.slice(from - len, from) === marker && text.slice(to, to + len) === marker) {\n const t = text.slice(0, from - len) + text.slice(from, to) + text.slice(to + len);\n return { text: t, selection: { from: from - len, to: to - len } };\n }\n\n const selected = text.slice(from, to);\n\n // already wrapped INSIDE the selection → unwrap\n if (selected.length >= 2 * len && selected.startsWith(marker) && selected.endsWith(marker)) {\n const inner = selected.slice(len, selected.length - len);\n const t = text.slice(0, from) + inner + text.slice(to);\n return { text: t, selection: { from, to: from + inner.length } };\n }\n\n // wrap\n const t = text.slice(0, from) + marker + selected + marker + text.slice(to);\n if (from === to) return { text: t, selection: { from: from + len, to: from + len } };\n return { text: t, selection: { from: from + len, to: to + len } };\n}\n\nfunction insertLink(text: string, sel: Sel): CommandResult {\n const { from, to } = norm(sel);\n const label = text.slice(from, to) || 'text';\n const url = 'https://';\n const inserted = `[${label}](${url})`;\n const t = text.slice(0, from) + inserted + text.slice(to);\n const urlStart = from + label.length + 3; // '[' + label + '](' = len + 3\n return { text: t, selection: { from: urlStart, to: urlStart + url.length } };\n}\n\nconst HEADING_RE = /^ {0,3}#{1,6}\\s+/;\nconst LIST_RE = /^ {0,3}(?:[-*+]\\s(?:\\[[ xX]\\]\\s)?|\\d+[.)]\\s)/;\nconst QUOTE_RE = /^ {0,3}>\\s?/;\n\ninterface LinePrefix {\n has: (line: string) => boolean;\n strip: (line: string) => string;\n add: (line: string, index: number) => string;\n}\n\nfunction applyLinePrefix(text: string, sel: Sel, p: LinePrefix): CommandResult {\n const { from, to } = norm(sel);\n const start = text.lastIndexOf('\\n', from - 1) + 1;\n const searchFrom = to > from ? to - 1 : to;\n let end = text.indexOf('\\n', searchFrom);\n if (end === -1) end = text.length;\n\n const lines = text.slice(start, end).split('\\n');\n const allHave = lines.every((l) => l.trim() === '' || p.has(l));\n const out = lines\n .map((l, i) => (l.trim() === '' ? l : allHave ? p.strip(l) : p.add(p.strip(l), i)))\n .join('\\n');\n\n const t = text.slice(0, start) + out + text.slice(end);\n return { text: t, selection: { from: start, to: start + out.length } };\n}\n\nfunction stripAllPrefixes(line: string): string {\n return line.replace(HEADING_RE, '').replace(LIST_RE, '').replace(QUOTE_RE, '');\n}\n\nfunction insertBlock(text: string, sel: Sel, block: string, selectInner?: [number, number]): CommandResult {\n const { from, to } = norm(sel);\n const before = text.slice(0, from);\n const after = text.slice(to);\n const lead = before === '' || before.endsWith('\\n\\n') ? '' : before.endsWith('\\n') ? '\\n' : '\\n\\n';\n const trail = after === '' || after.startsWith('\\n\\n') ? '' : after.startsWith('\\n') ? '\\n' : '\\n\\n';\n const insertedAt = from + lead.length;\n const t = before + lead + block + trail + after;\n const selection: Sel = selectInner\n ? { from: insertedAt + selectInner[0], to: insertedAt + selectInner[1] }\n : { from: insertedAt, to: insertedAt + block.length };\n return { text: t, selection };\n}\n\nexport function applyCommand(text: string, sel: Sel, cmd: Command): CommandResult {\n switch (cmd) {\n case 'bold':\n return toggleWrap(text, sel, '**');\n case 'italic':\n return toggleWrap(text, sel, '*');\n case 'strikethrough':\n return toggleWrap(text, sel, '~~');\n case 'inlineCode':\n return toggleWrap(text, sel, '`');\n case 'link':\n return insertLink(text, sel);\n case 'heading1':\n case 'heading2':\n case 'heading3':\n case 'heading4':\n case 'heading5':\n case 'heading6': {\n const level =\n cmd === 'heading1'\n ? 1\n : cmd === 'heading2'\n ? 2\n : cmd === 'heading3'\n ? 3\n : cmd === 'heading4'\n ? 4\n : cmd === 'heading5'\n ? 5\n : 6;\n const marker = '#'.repeat(level) + ' ';\n return applyLinePrefix(text, sel, {\n has: (l) => new RegExp(`^ {0,3}#{${level}}\\\\s`).test(l),\n strip: (l) => l.replace(HEADING_RE, ''),\n add: (l) => marker + l,\n });\n }\n case 'bulletList':\n return applyLinePrefix(text, sel, {\n has: (l) => /^ {0,3}[-*+]\\s/.test(l),\n strip: stripAllPrefixes,\n add: (l) => '- ' + l,\n });\n case 'orderedList':\n return applyLinePrefix(text, sel, {\n has: (l) => /^ {0,3}\\d+[.)]\\s/.test(l),\n strip: stripAllPrefixes,\n add: (l, i) => `${i + 1}. ` + l,\n });\n case 'taskList':\n return applyLinePrefix(text, sel, {\n has: (l) => /^ {0,3}[-*+]\\s\\[[ xX]\\]\\s/.test(l),\n strip: stripAllPrefixes,\n add: (l) => '- [ ] ' + l,\n });\n case 'quote':\n return applyLinePrefix(text, sel, {\n has: (l) => QUOTE_RE.test(l),\n strip: (l) => l.replace(QUOTE_RE, ''),\n add: (l) => '> ' + l,\n });\n case 'horizontalRule':\n return insertBlock(text, sel, '---');\n case 'codeBlock': {\n const selected = text.slice(norm(sel).from, norm(sel).to);\n const block = '```\\n' + selected + '\\n```';\n // place caret after the opening fence when empty\n return insertBlock(text, sel, block, selected ? undefined : [4, 4]);\n }\n case 'table': {\n const block = '| Column | Column |\\n| --- | --- |\\n| Cell | Cell |';\n return insertBlock(text, sel, block, [2, 8]); // select first header word\n }\n default: {\n const _exhaustive: never = cmd;\n return { text, selection: norm(sel) };\n }\n }\n}\n","/**\n * Document model — an immutable text container with transaction-based edits and\n * position mapping. The string is the source of truth (SPEC.md §4.1): every edit\n * is a `{from, to, insert}` change, applying one returns a NEW `TextDoc`, and\n * offsets can be mapped across a change so decorations / anchors survive edits.\n */\n\nexport interface Change {\n /** Inclusive start offset of the replaced range. */\n from: number;\n /** Exclusive end offset of the replaced range. */\n to: number;\n /** Text inserted in place of `[from, to)`. */\n insert: string;\n}\n\nexport interface LineInfo {\n /** 1-based line number. */\n number: number;\n /** Offset of the first character of the line. */\n from: number;\n /** Offset just past the last character (before the newline). */\n to: number;\n /** The line's text (without the trailing newline). */\n text: string;\n}\n\nexport interface Position {\n /** 1-based line. */\n line: number;\n /** 1-based column (UTF-16 units within the line). */\n column: number;\n}\n\nexport class TextDoc {\n readonly text: string;\n private _lineStarts: number[] | null = null;\n\n constructor(text = '') {\n this.text = text;\n }\n\n get length(): number {\n return this.text.length;\n }\n\n /** Apply one change, returning a new document. */\n apply(change: Change): TextDoc {\n const { from, to, insert } = normalize(change, this.text.length);\n return new TextDoc(this.text.slice(0, from) + insert + this.text.slice(to));\n }\n\n /**\n * Apply several changes, returning a new document. Changes are given in\n * document coordinates of THIS doc; they are applied right-to-left so earlier\n * offsets stay valid.\n */\n applyAll(changes: Change[]): TextDoc {\n const sorted = [...changes].sort((a, b) => b.from - a.from);\n let text = this.text;\n for (const c of sorted) {\n const { from, to, insert } = normalize(c, text.length);\n text = text.slice(0, from) + insert + text.slice(to);\n }\n return new TextDoc(text);\n }\n\n private lineStarts(): number[] {\n if (this._lineStarts) return this._lineStarts;\n const starts = [0];\n for (let i = 0; i < this.text.length; i++) {\n if (this.text.charCodeAt(i) === 10 /* \\n */) starts.push(i + 1);\n }\n this._lineStarts = starts;\n return starts;\n }\n\n /** Total number of lines (a trailing newline yields an extra empty line). */\n get lines(): number {\n return this.lineStarts().length;\n }\n\n /** The line (1-based) containing `offset`. */\n lineAt(offset: number): LineInfo {\n const off = clamp(offset, 0, this.text.length);\n const starts = this.lineStarts();\n // binary search for the last start <= off\n let lo = 0;\n let hi = starts.length - 1;\n while (lo < hi) {\n const mid = (lo + hi + 1) >> 1;\n if (starts[mid]! <= off) lo = mid;\n else hi = mid - 1;\n }\n const from = starts[lo]!;\n const nextStart = starts[lo + 1];\n const to = nextStart === undefined ? this.text.length : nextStart - 1;\n return { number: lo + 1, from, to, text: this.text.slice(from, to) };\n }\n\n /** Line/column (both 1-based) for an offset. */\n positionAt(offset: number): Position {\n const line = this.lineAt(offset);\n return { line: line.number, column: clamp(offset, 0, this.text.length) - line.from + 1 };\n }\n\n /** Offset for a 1-based line/column. */\n offsetAt(line: number, column: number): number {\n const starts = this.lineStarts();\n const idx = clamp(line, 1, starts.length) - 1;\n const from = starts[idx]!;\n const nextStart = starts[idx + 1];\n const to = nextStart === undefined ? this.text.length : nextStart - 1;\n return clamp(from + (column - 1), from, to);\n }\n\n /**\n * Map an offset from this document's coordinates to the coordinates AFTER the\n * given change(s). `assoc` controls which side of an insertion at the offset\n * the mapped position sticks to: -1 = before (default), 1 = after.\n */\n mapOffset(offset: number, changes: Change | Change[], assoc: -1 | 1 = -1): number {\n const list = Array.isArray(changes) ? changes : [changes];\n // apply in document order; each change shifts offsets after it\n const ordered = [...list].sort((a, b) => a.from - b.from);\n let result = offset;\n for (const c of ordered) {\n const { from, to, insert } = normalize(c, Number.MAX_SAFE_INTEGER);\n const delta = insert.length - (to - from);\n if (result < from) continue;\n if (result > to) {\n result += delta;\n } else if (result === from && assoc < 0) {\n // stays at from\n } else if (result === to && assoc > 0) {\n result += delta;\n } else {\n // inside the replaced range: collapse toward the edit boundary\n result = assoc < 0 ? from : from + insert.length;\n }\n }\n return result;\n }\n\n toString(): string {\n return this.text;\n }\n}\n\nfunction normalize(change: Change, len: number): Change {\n let from = clamp(Math.min(change.from, change.to), 0, len);\n let to = clamp(Math.max(change.from, change.to), 0, len);\n return { from, to, insert: change.insert };\n}\n\nfunction clamp(n: number, lo: number, hi: number): number {\n return n < lo ? lo : n > hi ? hi : n;\n}\n","/**\n * Native, zero-dependency syntax highlighter.\n *\n * {@link highlightToHtml} turns a fenced code block's source into an HTML\n * string with tokens wrapped in `<span class=\"tw-tok-KIND\">…</span>`. The\n * tokenizers are small, hand-written, single-pass line/char scanners — NOT\n * full grammars. They recognise the shapes that carry the most colour signal:\n * keywords, strings (including template literals), line + block comments,\n * numbers, punctuation, and a light dusting of function / type / property\n * classification.\n *\n * Safety is the load-bearing invariant: **every** character that reaches the\n * output — token content and the gaps between tokens alike — is HTML-escaped\n * through the local {@link escapeHtml}. A `<script>` (or `<img onerror=…>`)\n * embedded in the code therefore always appears inert/escaped, never as live\n * markup. This mirrors the sanitizing contract of `render.ts` so the\n * highlighter can be handed straight to the renderer without widening the\n * attack surface.\n *\n * Complexity is O(n) in the source length. There are no unbounded-backtracking\n * regexes; scanning advances the cursor monotonically, so pathological input\n * (huge whitespace runs, unterminated strings/comments) is safe.\n */\n\n/** The token classes we emit. `KIND` in `tw-tok-KIND`. */\ntype TokenKind =\n | 'keyword'\n | 'string'\n | 'comment'\n | 'number'\n | 'punct'\n | 'fn'\n | 'type'\n | 'prop';\n\n/* ------------------------------------------------------------------ *\n * Escaping + span emission\n * ------------------------------------------------------------------ */\n\n/**\n * Escape the four characters that matter in HTML text / double-quoted attrs\n * (`&`, `<`, `>`, `\"`). This is the security boundary: nothing leaves this\n * module without passing through here.\n */\nfunction escapeHtml(value: string): string {\n let out = '';\n for (let i = 0; i < value.length; i++) {\n const ch = value.charCodeAt(i);\n switch (ch) {\n case 38 /* & */:\n out += '&';\n break;\n case 60 /* < */:\n out += '<';\n break;\n case 62 /* > */:\n out += '>';\n break;\n case 34 /* \" */:\n out += '"';\n break;\n default:\n out += value.charAt(i);\n }\n }\n return out;\n}\n\n/** Wrap escaped `text` in a token span. */\nfunction span(kind: TokenKind, text: string): string {\n return `<span class=\"tw-tok-${kind}\">${escapeHtml(text)}</span>`;\n}\n\n/* ------------------------------------------------------------------ *\n * Character predicates (charCode based, O(1))\n * ------------------------------------------------------------------ */\n\nfunction isDigit(ch: number): boolean {\n return ch >= 48 && ch <= 57;\n}\n\nfunction isIdentStart(ch: number): boolean {\n return (\n (ch >= 65 && ch <= 90) || // A-Z\n (ch >= 97 && ch <= 122) || // a-z\n ch === 95 || // _\n ch === 36 // $\n );\n}\n\nfunction isIdentPart(ch: number): boolean {\n return isIdentStart(ch) || isDigit(ch);\n}\n\n/** Chars that may appear inside a numeric literal (hex/oct/bin/float/sep). */\nfunction isNumberPart(ch: number): boolean {\n return (\n isDigit(ch) ||\n ch === 46 || // .\n ch === 95 || // _ separator\n ch === 120 || // x\n ch === 88 || // X\n ch === 111 || // o\n ch === 79 || // O\n ch === 98 || // b\n ch === 66 || // B\n (ch >= 97 && ch <= 102) || // a-f (hex + exponent 'e')\n (ch >= 65 && ch <= 70) // A-F (hex + exponent 'E')\n );\n}\n\n/** Punctuation we colour in C-like languages. */\nfunction isPunct(ch: number): boolean {\n switch (ch) {\n case 123: // {\n case 125: // }\n case 40: // (\n case 41: // )\n case 91: // [\n case 93: // ]\n case 60: // <\n case 62: // >\n case 61: // =\n case 43: // +\n case 45: // -\n case 42: // *\n case 47: // /\n case 37: // %\n case 33: // !\n case 63: // ?\n case 58: // :\n case 59: // ;\n case 44: // ,\n case 46: // .\n case 38: // &\n case 124: // |\n case 94: // ^\n case 126: // ~\n case 64: // @\n return true;\n default:\n return false;\n }\n}\n\n/**\n * Scan back from `i-1` to the first non-whitespace char code (0 if none).\n * Amortised O(n) across a scan because each gap is walked at most once.\n */\nfunction prevNonSpace(code: string, i: number): number {\n let k = i - 1;\n while (k >= 0) {\n const c = code.charCodeAt(k);\n if (c === 32 || c === 9 || c === 10 || c === 13) {\n k--;\n continue;\n }\n return c;\n }\n return 0;\n}\n\n/**\n * Consume a quoted string starting at `start` (the opening quote). Backslash\n * escapes are skipped. Non-template strings terminate at an unescaped newline\n * (so an unterminated `\"` can't swallow the rest of the file). Returns the\n * exclusive end index.\n */\nfunction consumeString(code: string, start: number, quote: number): number {\n const n = code.length;\n let j = start + 1;\n while (j < n) {\n const c = code.charCodeAt(j);\n if (c === 92 /* \\ */) {\n j += 2;\n continue;\n }\n if (c === quote) {\n return j + 1;\n }\n if (quote !== 96 /* ` */ && c === 10 /* \\n */) {\n return j; // unterminated: stop before the newline\n }\n j++;\n }\n return n;\n}\n\n/* ------------------------------------------------------------------ *\n * Keyword / type tables\n * ------------------------------------------------------------------ */\n\n// prettier-ignore\nconst JS_KEYWORDS = new Set([\n 'abstract', 'any', 'as', 'asserts', 'async', 'await', 'break', 'case',\n 'catch', 'class', 'const', 'continue', 'debugger', 'declare', 'default',\n 'delete', 'do', 'else', 'enum', 'export', 'extends', 'false', 'finally',\n 'for', 'from', 'function', 'get', 'if', 'implements', 'import', 'in',\n 'infer', 'instanceof', 'interface', 'is', 'keyof', 'let', 'namespace',\n 'new', 'null', 'of', 'override', 'package', 'private', 'protected',\n 'public', 'readonly', 'return', 'satisfies', 'set', 'static', 'super',\n 'switch', 'this', 'throw', 'true', 'try', 'type', 'typeof', 'undefined',\n 'var', 'void', 'while', 'with', 'yield',\n]);\n\n// prettier-ignore\nconst TS_TYPES = new Set([\n 'string', 'number', 'boolean', 'object', 'symbol', 'bigint', 'unknown',\n 'never', 'Array', 'Record', 'Promise', 'Partial', 'Required', 'Readonly',\n 'Pick', 'Omit', 'Map', 'Set', 'WeakMap', 'WeakSet', 'Date', 'RegExp',\n 'Error',\n]);\n\n// prettier-ignore\nconst PY_KEYWORDS = new Set([\n 'and', 'as', 'assert', 'async', 'await', 'break', 'case', 'class',\n 'continue', 'def', 'del', 'elif', 'else', 'except', 'False', 'finally',\n 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'match',\n 'None', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'True', 'try',\n 'while', 'with', 'yield',\n]);\n\n// prettier-ignore\nconst BASH_KEYWORDS = new Set([\n 'if', 'then', 'else', 'elif', 'fi', 'for', 'while', 'until', 'do', 'done',\n 'case', 'esac', 'in', 'function', 'select', 'time', 'return', 'break',\n 'continue', 'echo', 'cd', 'export', 'local', 'read', 'printf', 'source',\n 'exit', 'set', 'unset', 'test', 'eval', 'exec', 'trap', 'shift',\n]);\n\n// prettier-ignore\nconst SQL_KEYWORDS = new Set([\n 'add', 'all', 'alter', 'and', 'as', 'asc', 'auto_increment', 'begin',\n 'between', 'by', 'case', 'column', 'commit', 'constraint', 'create',\n 'cross', 'default', 'delete', 'desc', 'distinct', 'drop', 'else', 'end',\n 'exists', 'foreign', 'from', 'full', 'group', 'having', 'if', 'in',\n 'index', 'inner', 'insert', 'into', 'is', 'join', 'key', 'left', 'like',\n 'limit', 'not', 'null', 'offset', 'on', 'or', 'order', 'outer', 'primary',\n 'references', 'right', 'rollback', 'select', 'set', 'table', 'then',\n 'union', 'unique', 'update', 'values', 'view', 'when', 'where', 'with',\n // common types / functions\n 'int', 'integer', 'bigint', 'smallint', 'decimal', 'numeric', 'float',\n 'real', 'double', 'char', 'varchar', 'text', 'boolean', 'bool', 'date',\n 'datetime', 'timestamp', 'count', 'sum', 'avg', 'min', 'max', 'coalesce',\n]);\n\n/* ------------------------------------------------------------------ *\n * C-like (javascript / typescript / jsx / tsx)\n * ------------------------------------------------------------------ */\n\nfunction highlightCLike(code: string): string {\n const n = code.length;\n let out = '';\n let i = 0;\n let prevWord = '';\n\n while (i < n) {\n const ch = code.charCodeAt(i);\n\n // line comment //\n if (ch === 47 /* / */ && code.charCodeAt(i + 1) === 47) {\n let j = i + 2;\n while (j < n && code.charCodeAt(j) !== 10) j++;\n out += span('comment', code.slice(i, j));\n i = j;\n continue;\n }\n\n // block comment /* */\n if (ch === 47 && code.charCodeAt(i + 1) === 42 /* * */) {\n let j = i + 2;\n while (\n j < n &&\n !(code.charCodeAt(j) === 42 && code.charCodeAt(j + 1) === 47)\n ) {\n j++;\n }\n j = Math.min(n, j + 2);\n out += span('comment', code.slice(i, j));\n i = j;\n continue;\n }\n\n // strings: \" ' `\n if (ch === 34 || ch === 39 || ch === 96) {\n const end = consumeString(code, i, ch);\n out += span('string', code.slice(i, end));\n i = end;\n continue;\n }\n\n // number\n if (isDigit(ch) || (ch === 46 && isDigit(code.charCodeAt(i + 1)))) {\n let j = i + 1;\n while (j < n && isNumberPart(code.charCodeAt(j))) j++;\n out += span('number', code.slice(i, j));\n i = j;\n prevWord = '';\n continue;\n }\n\n // identifier / keyword / type / fn / prop\n if (isIdentStart(ch)) {\n let j = i + 1;\n while (j < n && isIdentPart(code.charCodeAt(j))) j++;\n const word = code.slice(i, j);\n if (JS_KEYWORDS.has(word)) {\n out += span('keyword', word);\n } else if (TS_TYPES.has(word)) {\n out += span('type', word);\n } else {\n // look ahead past spaces for a call paren\n let k = j;\n while (k < n) {\n const c = code.charCodeAt(k);\n if (c === 32 || c === 9) {\n k++;\n continue;\n }\n break;\n }\n const isCall = code.charCodeAt(k) === 40; // (\n if (prevNonSpace(code, i) === 46 /* . */) {\n out += span('prop', word);\n } else if (prevWord === 'class' || prevWord === 'interface') {\n out += span('type', word);\n } else if (isCall || prevWord === 'function') {\n out += span('fn', word);\n } else {\n out += escapeHtml(word);\n }\n }\n prevWord = word;\n i = j;\n continue;\n }\n\n // punctuation\n if (isPunct(ch)) {\n out += span('punct', code.charAt(i));\n i++;\n continue;\n }\n\n // whitespace / anything else\n out += escapeHtml(code.charAt(i));\n i++;\n }\n\n return out;\n}\n\n/* ------------------------------------------------------------------ *\n * JSON\n * ------------------------------------------------------------------ */\n\nfunction highlightJson(code: string): string {\n const n = code.length;\n let out = '';\n let i = 0;\n\n while (i < n) {\n const ch = code.charCodeAt(i);\n\n // string — key (followed by ':') vs value\n if (ch === 34 /* \" */) {\n const end = consumeString(code, i, 34);\n const text = code.slice(i, end);\n // peek past whitespace for a colon\n let k = end;\n while (k < n) {\n const c = code.charCodeAt(k);\n if (c === 32 || c === 9 || c === 10 || c === 13) {\n k++;\n continue;\n }\n break;\n }\n out += span(code.charCodeAt(k) === 58 /* : */ ? 'prop' : 'string', text);\n i = end;\n continue;\n }\n\n // number (with optional leading -)\n if (isDigit(ch) || (ch === 45 && isDigit(code.charCodeAt(i + 1)))) {\n let j = i + 1;\n while (j < n && isNumberPart(code.charCodeAt(j))) j++;\n out += span('number', code.slice(i, j));\n i = j;\n continue;\n }\n\n // literals true / false / null\n if (isIdentStart(ch)) {\n let j = i + 1;\n while (j < n && isIdentPart(code.charCodeAt(j))) j++;\n const word = code.slice(i, j);\n if (word === 'true' || word === 'false' || word === 'null') {\n out += span('keyword', word);\n } else {\n out += escapeHtml(word);\n }\n i = j;\n continue;\n }\n\n if (isPunct(ch)) {\n out += span('punct', code.charAt(i));\n i++;\n continue;\n }\n\n out += escapeHtml(code.charAt(i));\n i++;\n }\n\n return out;\n}\n\n/* ------------------------------------------------------------------ *\n * CSS\n * ------------------------------------------------------------------ */\n\nfunction highlightCss(code: string): string {\n const n = code.length;\n let out = '';\n let i = 0;\n let depth = 0;\n let beforeColon = true; // property-name position inside a block\n\n while (i < n) {\n const ch = code.charCodeAt(i);\n\n // block comment /* */\n if (ch === 47 && code.charCodeAt(i + 1) === 42) {\n let j = i + 2;\n while (\n j < n &&\n !(code.charCodeAt(j) === 42 && code.charCodeAt(j + 1) === 47)\n ) {\n j++;\n }\n j = Math.min(n, j + 2);\n out += span('comment', code.slice(i, j));\n i = j;\n continue;\n }\n\n // strings\n if (ch === 34 || ch === 39) {\n const end = consumeString(code, i, ch);\n out += span('string', code.slice(i, end));\n i = end;\n continue;\n }\n\n // at-rule\n if (ch === 64 /* @ */) {\n let j = i + 1;\n while (j < n && isIdentPart(code.charCodeAt(j))) j++;\n out += span('keyword', code.slice(i, j));\n i = j;\n continue;\n }\n\n // structural punctuation controlling the prop/value state machine\n if (ch === 123 /* { */) {\n out += span('punct', '{');\n depth++;\n beforeColon = true;\n i++;\n continue;\n }\n if (ch === 125 /* } */) {\n out += span('punct', '}');\n if (depth > 0) depth--;\n beforeColon = true;\n i++;\n continue;\n }\n if (ch === 59 /* ; */) {\n out += span('punct', ';');\n beforeColon = true;\n i++;\n continue;\n }\n if (ch === 58 /* : */) {\n out += span('punct', ':');\n beforeColon = false;\n i++;\n continue;\n }\n\n // number (+ trailing unit stays plain)\n if (isDigit(ch) || (ch === 46 && isDigit(code.charCodeAt(i + 1)))) {\n let j = i + 1;\n while (j < n && isNumberPart(code.charCodeAt(j))) j++;\n out += span('number', code.slice(i, j));\n i = j;\n continue;\n }\n\n // identifier-ish run (property, value keyword, selector fragment)\n if (isIdentStart(ch) || ch === 45 /* - */) {\n let j = i + 1;\n while (\n j < n &&\n (isIdentPart(code.charCodeAt(j)) || code.charCodeAt(j) === 45)\n ) {\n j++;\n }\n const word = code.slice(i, j);\n if (depth > 0 && beforeColon) {\n out += span('prop', word);\n } else {\n out += escapeHtml(word);\n }\n i = j;\n continue;\n }\n\n if (isPunct(ch)) {\n out += span('punct', code.charAt(i));\n i++;\n continue;\n }\n\n out += escapeHtml(code.charAt(i));\n i++;\n }\n\n return out;\n}\n\n/* ------------------------------------------------------------------ *\n * HTML\n * ------------------------------------------------------------------ */\n\nfunction isTagChar(ch: number): boolean {\n return isIdentPart(ch) || ch === 45 /* - */ || ch === 58 /* : */;\n}\n\nfunction highlightHtml(code: string): string {\n const n = code.length;\n let out = '';\n let i = 0;\n\n while (i < n) {\n const ch = code.charCodeAt(i);\n\n // comment <!-- -->\n if (ch === 60 && code.startsWith('<!--', i)) {\n const idx = code.indexOf('-->', i + 4);\n const j = idx === -1 ? n : idx + 3;\n out += span('comment', code.slice(i, j));\n i = j;\n continue;\n }\n\n // tag\n if (ch === 60 /* < */) {\n let j = i + 1;\n if (code.charCodeAt(j) === 47 /* / */) j++;\n out += span('punct', code.slice(i, j));\n // tag name\n const nameStart = j;\n while (j < n && isTagChar(code.charCodeAt(j))) j++;\n if (j > nameStart) out += span('keyword', code.slice(nameStart, j));\n // attributes up to '>'\n while (j < n && code.charCodeAt(j) !== 62 /* > */) {\n const c = code.charCodeAt(j);\n if (c === 34 || c === 39) {\n const end = consumeString(code, j, c);\n out += span('string', code.slice(j, end));\n j = end;\n continue;\n }\n if (c === 61 /* = */) {\n out += span('punct', '=');\n j++;\n continue;\n }\n if (isTagChar(c)) {\n const a = j;\n while (j < n && isTagChar(code.charCodeAt(j))) j++;\n out += span('prop', code.slice(a, j));\n continue;\n }\n out += escapeHtml(code.charAt(j));\n j++;\n }\n if (j < n && code.charCodeAt(j) === 62) {\n out += span('punct', '>');\n j++;\n }\n i = j;\n continue;\n }\n\n // entity &name; / {\n if (ch === 38 /* & */) {\n let j = i + 1;\n while (\n j < n &&\n j - i < 12 &&\n code.charCodeAt(j) !== 59 &&\n (isIdentPart(code.charCodeAt(j)) || code.charCodeAt(j) === 35)\n ) {\n j++;\n }\n if (j < n && code.charCodeAt(j) === 59) {\n out += span('type', code.slice(i, j + 1));\n i = j + 1;\n continue;\n }\n }\n\n out += escapeHtml(code.charAt(i));\n i++;\n }\n\n return out;\n}\n\n/* ------------------------------------------------------------------ *\n * Markdown\n * ------------------------------------------------------------------ */\n\nfunction highlightMarkdownLine(line: string): string {\n const n = line.length;\n let out = '';\n let i = 0;\n\n // leading whitespace\n while (i < n && (line.charCodeAt(i) === 32 || line.charCodeAt(i) === 9)) {\n out += line.charAt(i);\n i++;\n }\n\n // heading marker: #{1,6} followed by space\n if (line.charCodeAt(i) === 35 /* # */) {\n let h = i;\n while (h < n && line.charCodeAt(h) === 35) h++;\n if (h - i <= 6 && (h >= n || line.charCodeAt(h) === 32)) {\n out += span('keyword', line.slice(i, h));\n i = h;\n }\n } else if (line.charCodeAt(i) === 62 /* > */) {\n // blockquote marker\n out += span('keyword', '>');\n i++;\n } else {\n // list marker: - + * or `N.`\n const c = line.charCodeAt(i);\n if ((c === 45 || c === 43 || c === 42) && line.charCodeAt(i + 1) === 32) {\n out += span('punct', line.charAt(i));\n i++;\n }\n }\n\n // inline scan of the remainder\n while (i < n) {\n const ch = line.charCodeAt(i);\n\n // inline code `…`\n if (ch === 96 /* ` */) {\n let j = i + 1;\n while (j < n && line.charCodeAt(j) !== 96) j++;\n j = Math.min(n, j + 1);\n out += span('string', line.slice(i, j));\n i = j;\n continue;\n }\n\n // emphasis markers ** * _ ~~\n if (ch === 42 /* * */ || ch === 95 /* _ */ || ch === 126 /* ~ */) {\n let j = i;\n while (j < n && line.charCodeAt(j) === ch) j++;\n out += span('punct', line.slice(i, j));\n i = j;\n continue;\n }\n\n // link / image punctuation\n if (ch === 91 || ch === 93 || ch === 40 || ch === 41) {\n out += span('punct', line.charAt(i));\n i++;\n continue;\n }\n\n out += escapeHtml(line.charAt(i));\n i++;\n }\n\n return out;\n}\n\nfunction highlightMarkdown(code: string): string {\n const lines = code.split('\\n');\n let out = '';\n for (let i = 0; i < lines.length; i++) {\n if (i > 0) out += '\\n';\n out += highlightMarkdownLine(lines[i] ?? '');\n }\n return out;\n}\n\n/* ------------------------------------------------------------------ *\n * Python\n * ------------------------------------------------------------------ */\n\nfunction highlightPython(code: string): string {\n const n = code.length;\n let out = '';\n let i = 0;\n let prevWord = '';\n\n while (i < n) {\n const ch = code.charCodeAt(i);\n\n // comment # …\n if (ch === 35 /* # */) {\n let j = i + 1;\n while (j < n && code.charCodeAt(j) !== 10) j++;\n out += span('comment', code.slice(i, j));\n i = j;\n continue;\n }\n\n // triple-quoted string\n if (\n (ch === 34 || ch === 39) &&\n code.charCodeAt(i + 1) === ch &&\n code.charCodeAt(i + 2) === ch\n ) {\n const marker = code.slice(i, i + 3);\n const idx = code.indexOf(marker, i + 3);\n const j = idx === -1 ? n : idx + 3;\n out += span('string', code.slice(i, j));\n i = j;\n prevWord = '';\n continue;\n }\n\n // single/double string\n if (ch === 34 || ch === 39) {\n const end = consumeString(code, i, ch);\n out += span('string', code.slice(i, end));\n i = end;\n prevWord = '';\n continue;\n }\n\n // decorator @name\n if (ch === 64 /* @ */ && isIdentStart(code.charCodeAt(i + 1))) {\n let j = i + 1;\n while (j < n && isIdentPart(code.charCodeAt(j))) j++;\n out += span('keyword', code.slice(i, j));\n i = j;\n continue;\n }\n\n // number\n if (isDigit(ch) || (ch === 46 && isDigit(code.charCodeAt(i + 1)))) {\n let j = i + 1;\n while (j < n && isNumberPart(code.charCodeAt(j))) j++;\n out += span('number', code.slice(i, j));\n i = j;\n prevWord = '';\n continue;\n }\n\n // identifier / keyword / fn\n if (isIdentStart(ch)) {\n let j = i + 1;\n while (j < n && isIdentPart(code.charCodeAt(j))) j++;\n const word = code.slice(i, j);\n if (PY_KEYWORDS.has(word)) {\n out += span('keyword', word);\n } else if (prevWord === 'def') {\n out += span('fn', word);\n } else if (prevWord === 'class') {\n out += span('type', word);\n } else {\n // call?\n let k = j;\n while (k < n && (code.charCodeAt(k) === 32 || code.charCodeAt(k) === 9))\n k++;\n out +=\n code.charCodeAt(k) === 40 ? span('fn', word) : escapeHtml(word);\n }\n prevWord = word;\n i = j;\n continue;\n }\n\n if (isPunct(ch)) {\n out += span('punct', code.charAt(i));\n i++;\n continue;\n }\n\n out += escapeHtml(code.charAt(i));\n i++;\n }\n\n return out;\n}\n\n/* ------------------------------------------------------------------ *\n * Bash\n * ------------------------------------------------------------------ */\n\nfunction highlightBash(code: string): string {\n const n = code.length;\n let out = '';\n let i = 0;\n\n while (i < n) {\n const ch = code.charCodeAt(i);\n\n // comment # … (only when the '#' begins a word)\n if (ch === 35 /* # */) {\n const prev = i > 0 ? code.charCodeAt(i - 1) : 10;\n if (\n i === 0 ||\n prev === 32 ||\n prev === 9 ||\n prev === 10 ||\n prev === 13 ||\n prev === 59 /* ; */\n ) {\n let j = i + 1;\n while (j < n && code.charCodeAt(j) !== 10) j++;\n out += span('comment', code.slice(i, j));\n i = j;\n continue;\n }\n }\n\n // strings\n if (ch === 34 || ch === 39) {\n const end = consumeString(code, i, ch);\n out += span('string', code.slice(i, end));\n i = end;\n continue;\n }\n\n // variable $name / ${name} / $1\n if (ch === 36 /* $ */) {\n let j = i + 1;\n if (code.charCodeAt(j) === 123 /* { */) {\n while (j < n && code.charCodeAt(j) !== 125 /* } */) j++;\n j = Math.min(n, j + 1);\n } else {\n while (j < n && isIdentPart(code.charCodeAt(j))) j++;\n }\n out += span('prop', code.slice(i, j));\n i = j;\n continue;\n }\n\n // number\n if (isDigit(ch)) {\n let j = i + 1;\n while (j < n && isNumberPart(code.charCodeAt(j))) j++;\n out += span('number', code.slice(i, j));\n i = j;\n continue;\n }\n\n // word / keyword\n if (isIdentStart(ch)) {\n let j = i + 1;\n while (j < n && isIdentPart(code.charCodeAt(j))) j++;\n const word = code.slice(i, j);\n out += BASH_KEYWORDS.has(word)\n ? span('keyword', word)\n : escapeHtml(word);\n i = j;\n continue;\n }\n\n if (isPunct(ch)) {\n out += span('punct', code.charAt(i));\n i++;\n continue;\n }\n\n out += escapeHtml(code.charAt(i));\n i++;\n }\n\n return out;\n}\n\n/* ------------------------------------------------------------------ *\n * SQL\n * ------------------------------------------------------------------ */\n\nfunction highlightSql(code: string): string {\n const n = code.length;\n let out = '';\n let i = 0;\n\n while (i < n) {\n const ch = code.charCodeAt(i);\n\n // line comment -- …\n if (ch === 45 /* - */ && code.charCodeAt(i + 1) === 45) {\n let j = i + 2;\n while (j < n && code.charCodeAt(j) !== 10) j++;\n out += span('comment', code.slice(i, j));\n i = j;\n continue;\n }\n\n // block comment /* */\n if (ch === 47 && code.charCodeAt(i + 1) === 42) {\n let j = i + 2;\n while (\n j < n &&\n !(code.charCodeAt(j) === 42 && code.charCodeAt(j + 1) === 47)\n ) {\n j++;\n }\n j = Math.min(n, j + 2);\n out += span('comment', code.slice(i, j));\n i = j;\n continue;\n }\n\n // strings (single-quoted values, double-quoted identifiers)\n if (ch === 39 || ch === 34) {\n const end = consumeString(code, i, ch);\n out += span('string', code.slice(i, end));\n i = end;\n continue;\n }\n\n // number\n if (isDigit(ch) || (ch === 46 && isDigit(code.charCodeAt(i + 1)))) {\n let j = i + 1;\n while (j < n && isNumberPart(code.charCodeAt(j))) j++;\n out += span('number', code.slice(i, j));\n i = j;\n continue;\n }\n\n // keyword (case-insensitive) / identifier\n if (isIdentStart(ch)) {\n let j = i + 1;\n while (j < n && isIdentPart(code.charCodeAt(j))) j++;\n const word = code.slice(i, j);\n out += SQL_KEYWORDS.has(word.toLowerCase())\n ? span('keyword', word)\n : escapeHtml(word);\n i = j;\n continue;\n }\n\n if (isPunct(ch)) {\n out += span('punct', code.charAt(i));\n i++;\n continue;\n }\n\n out += escapeHtml(code.charAt(i));\n i++;\n }\n\n return out;\n}\n\n/* ------------------------------------------------------------------ *\n * Language resolution + dispatch\n * ------------------------------------------------------------------ */\n\n/**\n * Alias map → canonical tokenizer key. Anything absent here (and from\n * {@link TOKENIZERS}) is treated as plain text, e.g. `yaml`/`yml`.\n */\nconst ALIASES: Record<string, string> = {\n js: 'javascript',\n jsx: 'javascript',\n javascript: 'javascript',\n mjs: 'javascript',\n cjs: 'javascript',\n ts: 'typescript',\n tsx: 'typescript',\n typescript: 'typescript',\n json: 'json',\n jsonc: 'json',\n json5: 'json',\n css: 'css',\n html: 'html',\n htm: 'html',\n xml: 'html',\n md: 'markdown',\n markdown: 'markdown',\n py: 'python',\n python: 'python',\n sh: 'bash',\n bash: 'bash',\n shell: 'bash',\n zsh: 'bash',\n sql: 'sql',\n};\n\nconst TOKENIZERS: Record<string, (code: string) => string> = {\n javascript: highlightCLike,\n typescript: highlightCLike,\n json: highlightJson,\n css: highlightCss,\n html: highlightHtml,\n markdown: highlightMarkdown,\n python: highlightPython,\n bash: highlightBash,\n sql: highlightSql,\n};\n\n/**\n * Highlight `code` for the given fence `info` string.\n *\n * `info` is the WHOLE fence info (e.g. `\"js {1,3}\"` or `\"ts title=foo\"`); the\n * language is the first whitespace-delimited token, lowercased, run through\n * {@link ALIASES}. Unknown / empty / unsupported languages return the escaped\n * source with no spans, so the output is always safe to inject.\n *\n * @param lang the fence info string (language + any attributes)\n * @param code the raw code block source\n * @returns HTML with `<span class=\"tw-tok-KIND\">` tokens; fully HTML-escaped.\n */\nexport function highlightToHtml(lang: string, code: string): string {\n const info = typeof lang === 'string' ? lang : '';\n const first = info.trim().split(/\\s+/)[0] ?? '';\n const key = first.toLowerCase();\n const resolved = ALIASES[key] ?? key;\n const tokenizer = TOKENIZERS[resolved];\n if (!tokenizer) return escapeHtml(code);\n return tokenizer(code);\n}\n","/**\n * Comment-anchor maintenance (plan-TW-0002 Phase A2).\n *\n * A comment thread is anchored to a text range `{from, to}`. Every time the\n * document is edited we must move that range so the highlight keeps covering\n * the same words — or drop the anchor (return `null`) when the words it pointed\n * at have been deleted. This is the first real consumer of `TextDoc.mapOffset`\n * (previously dead code) — it is built directly on top of that primitive rather\n * than re-deriving the position math here.\n */\nimport { TextDoc, type Change } from './text';\n\n/**\n * `mapOffset` is a pure function of `(offset, change, assoc)` — it never reads\n * the document text (it normalizes changes against `Number.MAX_SAFE_INTEGER`,\n * see text.ts:122-143), so a single shared empty doc is a valid host for the\n * call and we avoid allocating a `TextDoc` per invocation.\n */\nconst MAPPER = new TextDoc();\n\n/**\n * Association for the two anchor ends, in `mapOffset`'s convention\n * (text.ts:117-121): `assoc = -1` keeps the mapped offset *before* text\n * inserted exactly at it (the offset value is unchanged); `assoc = +1` pushes\n * it to *after* the inserted text (offset value += inserted length).\n *\n * We want a comment highlight to behave like a mark with a NON-inclusive start\n * and an INCLUSIVE end. Working that through the semantics above (verified\n * against the mapOffset branches):\n *\n * • `from` → +1: text typed exactly at the anchor start maps the start\n * *past* that insert, so the inserted text lands OUTSIDE the highlight —\n * \"insert exactly at 'from' stays outside\".\n * • `to` → +1: text typed exactly at the anchor end maps the end *past*\n * that insert, so the inserted text lands INSIDE the highlight —\n * \"insert exactly at 'to' extends the anchor\".\n *\n * Note the convention subtlety: under text.ts's semantics it is the +1\n * (\"after\") association — not -1 — that makes a boundary insert at `from` stay\n * *outside* the range (with -1 the start would sit before the insert and\n * swallow it). Both ends therefore map with +1: the start slides off a\n * boundary insert while the end absorbs it.\n */\nconst ASSOC_FROM: -1 | 1 = 1;\nconst ASSOC_TO: -1 | 1 = 1;\n\n/**\n * Re-anchor a comment range across a single document `change`.\n *\n * @returns the mapped `{from, to}` (always `from <= to`), or `null` when the\n * change deleted the entire anchored range.\n */\nexport function mapAnchor(\n anchor: { from: number; to: number },\n change: Change,\n): { from: number; to: number } | null {\n const from = MAPPER.mapOffset(anchor.from, change, ASSOC_FROM);\n const to = MAPPER.mapOffset(anchor.to, change, ASSOC_TO);\n\n // The anchored text is gone when the ends collapsed onto a single point AND\n // the change's deleted span `[change.from, change.to)` covered the whole\n // original anchor. The coverage guard keeps a plain boundary insert (which\n // can also make the ends equal for a zero-length anchor) from nulling out.\n const collapsed = from === to;\n const deletedWholeRange =\n change.to > change.from && change.from <= anchor.from && change.to >= anchor.to;\n if (collapsed && deletedWholeRange) return null;\n\n // mapOffset is monotonic for a fixed change/assoc, so from <= to already;\n // min/max is a cheap defensive guard.\n return { from: Math.min(from, to), to: Math.max(from, to) };\n}\n","/**\n * Pure table-editing helpers (Phase F1 of plan-TW-0002).\n *\n * These are the headless layer under the in-place table grid: no DOM, no React,\n * just string → string transforms over the offset-exact {@link Table} AST that\n * `./parser` produces. Every mutation keeps the Markdown *canonical* — a GFM\n * pipe table with a delimiter row — so `parse → mutate → parse` round-trips to\n * the same structure.\n *\n * Two edit shapes, matching the plan:\n * - **Single-cell** edits are scoped: {@link cellSourceRange} hands back a\n * cell's *exact* source range so the caller can splice only that slice.\n * - **Structural** ops (add/remove row/column, set alignment) re-serialize the\n * whole table block and return a full-block splice over `[table.from, table.to]`.\n *\n * Addressing convention (documented once, used everywhere):\n * - Rows use a **grid index**: row `0` is the header, rows `1..N` are body rows\n * (this mirrors the rendered grid, where the header is the top row).\n * - Columns are 0-based.\n *\n * The AST contract these helpers lean on (see `src/core/ast.ts:144-156`):\n * - `TableCell extends Pos` — every cell carries exact `{from,to}` UTF-16\n * offsets of its *trimmed* content (`splitRow`, `parser.ts:447-459`).\n * - `Table { from; to; align: CellAlign[]; header: TableCell[]; rows: TableCell[][] }`.\n * The delimiter row has no node of its own, so alignment edits (like every\n * structural op) re-serialize the block rather than splicing that row in place.\n */\n\nimport type { CellAlign, Pos, Table, TableCell } from './ast';\n\n/** Result of a structural (whole-block) table edit. */\nexport interface TableEdit {\n /** The full new document text after the splice. */\n text: string;\n /** A sensible caret offset into {@link text} after the edit. */\n selection: number;\n}\n\nconst clampInt = (n: number, lo: number, hi: number): number =>\n n < lo ? lo : n > hi ? hi : n;\n\n/** Canonical delimiter cell for an alignment (`---`, `:---`, `:---:`, `---:`). */\nfunction delimCell(align: CellAlign): string {\n switch (align) {\n case 'left':\n return ':---';\n case 'center':\n return ':---:';\n case 'right':\n return '---:';\n default:\n return '---';\n }\n}\n\n/**\n * A normalized, string-only view of a table: header, per-column alignment, and\n * body rows, every row widened/truncated to the header's column count. Editing\n * happens on this, then it is serialized back to canonical GFM.\n */\ninterface Grid {\n header: string[];\n align: CellAlign[];\n rows: string[][];\n}\n\nconst cellText = (text: string, cell: TableCell): string =>\n text.slice(cell.from, cell.to);\n\nconst emptyRow = (ncols: number): string[] =>\n Array.from({ length: ncols }, () => '');\n\n/** Build a rectangular {@link Grid} from a parsed table, reading raw cell source. */\nfunction tableToGrid(text: string, table: Table): Grid {\n const ncols = Math.max(1, table.header.length);\n const header = table.header.map((c) => cellText(text, c));\n while (header.length < ncols) header.push('');\n\n const align: CellAlign[] = [];\n for (let i = 0; i < ncols; i++) align.push(table.align[i] ?? null);\n\n const rows = table.rows.map((row) => {\n const cells = row.map((c) => cellText(text, c));\n while (cells.length < ncols) cells.push('');\n cells.length = ncols;\n return cells;\n });\n\n return { header, align, rows };\n}\n\n/** The cell strings that make up a given serialized line (0 header, 1 delim, ≥2 body). */\nfunction cellsForLine(grid: Grid, lineIdx: number): string[] {\n const ncols = grid.header.length;\n if (lineIdx === 0) return grid.header;\n if (lineIdx === 1) {\n const a: string[] = [];\n for (let i = 0; i < ncols; i++) a.push(delimCell(grid.align[i] ?? null));\n return a;\n }\n return grid.rows[lineIdx - 2] ?? grid.header;\n}\n\n/** Serialize the grid to canonical GFM lines: header, delimiter, then body rows. */\nfunction gridLines(grid: Grid): string[] {\n const ncols = grid.header.length;\n const rowLine = (cells: string[]): string => {\n const out = cells.slice(0, ncols);\n while (out.length < ncols) out.push('');\n return `| ${out.join(' | ')} |`;\n };\n const delim: string[] = [];\n for (let i = 0; i < ncols; i++) delim.push(delimCell(grid.align[i] ?? null));\n\n const lines = [rowLine(grid.header), `| ${delim.join(' | ')} |`];\n for (const r of grid.rows) lines.push(rowLine(r));\n return lines;\n}\n\n/** Offset of the first char of `lineIdx` within the joined serialization. */\nfunction lineStart(lines: string[], lineIdx: number): number {\n let off = 0;\n for (const l of lines.slice(0, lineIdx)) off += l.length + 1; // +1 for '\\n'\n return off;\n}\n\n/** Content-start offset of column `col` within a canonical `| c0 | c1 | … |` row. */\nfunction colOffsetInLine(cells: string[], col: number): number {\n let off = 2; // leading \"| \"\n for (const c of cells.slice(0, col)) off += c.length + 3; // \"cell\" + \" | \"\n return off;\n}\n\n/**\n * Serialize `grid`, splice it over `[table.from, table.to]`, and place the caret\n * at the start of `(lineIdx, col)` in the new block.\n */\nfunction commit(\n text: string,\n table: Table,\n grid: Grid,\n lineIdx: number,\n col: number,\n): TableEdit {\n const lines = gridLines(grid);\n const block = lines.join('\\n');\n const inBlock =\n lineStart(lines, lineIdx) + colOffsetInLine(cellsForLine(grid, lineIdx), col);\n const newText = text.slice(0, table.from) + block + text.slice(table.to);\n return { text: newText, selection: table.from + inBlock };\n}\n\n/* ------------------------------------------------------------------ *\n * Public helpers\n * ------------------------------------------------------------------ */\n\n/**\n * Exact source range of a single cell's (trimmed) text, for scoped single-cell\n * splices. Row `0` is the header; rows `1..N` are body rows. Returns `null` when\n * the coordinate is out of bounds.\n */\nexport function cellSourceRange(\n table: Table,\n row: number,\n col: number,\n): Pos | null {\n const cell: TableCell | undefined =\n row === 0 ? table.header[col] : table.rows[row - 1]?.[col];\n if (!cell) return null;\n return { from: cell.from, to: cell.to };\n}\n\n/**\n * Insert a new empty body row so it lands at grid position `atRow`\n * (clamped into the body range). Re-serializes the whole block.\n */\nexport function addRow(text: string, table: Table, atRow: number): TableEdit {\n const grid = tableToGrid(text, table);\n const bodyIdx = clampInt(atRow - 1, 0, grid.rows.length);\n grid.rows.splice(bodyIdx, 0, emptyRow(grid.header.length));\n return commit(text, table, grid, 2 + bodyIdx, 0);\n}\n\n/**\n * Insert a new empty column at index `atCol` (clamped), widening the header,\n * the alignment row, and every body row. Re-serializes the whole block.\n */\nexport function addColumn(text: string, table: Table, atCol: number): TableEdit {\n const grid = tableToGrid(text, table);\n const idx = clampInt(atCol, 0, grid.header.length);\n grid.header.splice(idx, 0, '');\n grid.align.splice(idx, 0, null);\n for (const r of grid.rows) r.splice(idx, 0, '');\n return commit(text, table, grid, 0, idx);\n}\n\n/**\n * Remove the body row at grid position `atRow` (row `0`, the header, and\n * out-of-range indices are no-ops). Re-serializes the whole block.\n */\nexport function removeRow(text: string, table: Table, atRow: number): TableEdit {\n const grid = tableToGrid(text, table);\n const bodyIdx = atRow - 1;\n if (bodyIdx >= 0 && bodyIdx < grid.rows.length) grid.rows.splice(bodyIdx, 1);\n\n const lineIdx =\n grid.rows.length === 0 ? 0 : 2 + clampInt(bodyIdx, 0, grid.rows.length - 1);\n return commit(text, table, grid, lineIdx, 0);\n}\n\n/**\n * Remove the column at index `atCol` from the header, alignment row, and every\n * body row. The last remaining column is never removed (a GFM table needs ≥1\n * column), and out-of-range indices are no-ops. Re-serializes the whole block.\n */\nexport function removeColumn(\n text: string,\n table: Table,\n atCol: number,\n): TableEdit {\n const grid = tableToGrid(text, table);\n if (grid.header.length > 1 && atCol >= 0 && atCol < grid.header.length) {\n grid.header.splice(atCol, 1);\n grid.align.splice(atCol, 1);\n for (const r of grid.rows) r.splice(atCol, 1);\n }\n const caretCol = clampInt(atCol, 0, grid.header.length - 1);\n return commit(text, table, grid, 0, caretCol);\n}\n\n/**\n * Set column `col`'s alignment and rewrite the delimiter row (via a canonical\n * re-serialization of the whole block). Out-of-range `col` is a no-op.\n */\nexport function setAlignment(\n text: string,\n table: Table,\n col: number,\n align: CellAlign,\n): TableEdit {\n const grid = tableToGrid(text, table);\n if (col >= 0 && col < grid.align.length) grid.align[col] = align;\n const caretCol = clampInt(col, 0, grid.align.length - 1);\n return commit(text, table, grid, 1, caretCol);\n}\n","/**\n * `typewright/core` — the headless, framework-agnostic engine.\n *\n * Status: PRE-ALPHA SCAFFOLD. The from-scratch document model, incremental\n * block-structured parser, and virtualized DOM view described in SPEC.md are\n * not yet implemented. This module defines the public surface those internals\n * will fulfil so integrators can build against a stable contract.\n */\n\nimport type {\n DocChange,\n DocSelection,\n EditorConfig,\n EditorEvents,\n} from '../types';\n\nexport * from '../types';\n\n/* Headless engine surface — parser, renderer, unified-mode, folding, doc model. */\nexport { parse, parseIncremental } from './parser';\nexport { renderToHtml, renderInline, renderNode, safeUrl } from './render';\nexport type { RenderOptions } from './render';\nexport { collectMarkers, hiddenMarkers, activeBlockIndex } from './unified';\nexport type { Marker } from './unified';\nexport { headingFoldRanges } from './fold';\nexport type { FoldRange } from './fold';\nexport { applyCommand, COMMANDS } from './commands';\nexport type { Command, Sel, CommandResult } from './commands';\nexport { TextDoc } from './text';\nexport type { Change, LineInfo, Position } from './text';\n/* Syntax highlighting (native, zero-dep), comment-anchor + table helpers. */\nexport { highlightToHtml } from './highlight';\nexport { mapAnchor } from './comments';\nexport {\n cellSourceRange,\n addRow,\n addColumn,\n removeRow,\n removeColumn,\n setAlignment,\n} from './table';\nexport type { TableEdit } from './table';\n/* ParseOptions and the AST node types are re-exported here too. */\nexport * from './ast';\n\nexport interface EditorViewOptions extends EditorConfig, EditorEvents {\n /** Element the editor mounts into. */\n parent: HTMLElement;\n}\n\n/**\n * PRE-ALPHA SCAFFOLD — not yet implemented. Constructing an `EditorView`\n * throws: the stateful mounted engine (document string, incremental parse tree,\n * decoration set, virtualized viewport) described in SPEC.md is still to come.\n * This class only reserves the eventual public surface.\n *\n * To edit or render Markdown today, use the functional headless API exported\n * from this module — {@link parse}, {@link parseIncremental}, {@link renderToHtml} —\n * or the React `TypewrightEditor` component in `typewright`.\n */\nexport class EditorView {\n readonly dom: HTMLElement;\n\n constructor(options: EditorViewOptions) {\n this.dom = options.parent;\n throw new Error(\n 'typewright/core: engine not yet implemented (pre-alpha scaffold). ' +\n 'See SPEC.md for the architecture and roadmap.',\n );\n }\n\n /** Current document string. */\n get doc(): string {\n return '';\n }\n\n /** Apply an edit. */\n dispatch(_change: DocChange): void {\n /* not implemented */\n }\n\n setSelection(_selection: DocSelection): void {\n /* not implemented */\n }\n\n destroy(): void {\n /* not implemented */\n }\n}\n"]}
|