@ai-matrx/content-ir 0.19.1 → 0.19.2

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/dist/source.d.cts CHANGED
@@ -607,4 +607,46 @@ declare function pendingDisplayMathOpener(text: string): number;
607
607
  /** Map of `$$` opener offset → closer offset for every pair the renderer shows as math. */
608
608
  declare function pairDisplayMath(text: string): Map<number, number>;
609
609
 
610
- export { AFTER_WINDOW, BacktickRuns, type BlockIslandType, CALLOUT_NAMES, type CodePointIndex, type CodeRange, type DisturbedIsland, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, type FenceEnd, type FenceLineKind, type FenceLines, type FenceOpener, FenceReader, type InlineIslandType, type InnerFenceLine, type IslandMeta, type IslandType, type MapOptions, type MappedPosition, type MappedRange, NESTING_FENCE_LANGUAGES, type ReadXmlTag, type SourceBlock, type SourceBlockKind, type SourceChange, type SourceEdit, type SourceIsland, type SourceSpan, SourceSpliceError, type SourceSpliceErrorCode, type SpliceIntegrity, type SpliceOptions, type SpliceResult, type TokenizeOptions, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, closeFence, codeSpanText, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, findCodeRanges, isEscapedBracketMath, isMathPlaceholder, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, looksLikeOpenInlineMath, mapCodeRanges, mapPosition, mapRange, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, singleDollarAfter, singleDollarMathEnd, spliceSave, splitsSurrogatePair, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine };
610
+ /**
611
+ * THE GFM table rule — one splitter, one cell-pipe rule, one "where does a
612
+ * table start and run" — for every surface that reads a markdown table: the
613
+ * chat splitter and live stream, the table renderers and editors, the rich
614
+ * editor's writer, the print package, and (by shared vectors) the Python block
615
+ * detector. verify-RC-B4 R4/R5/R6.
616
+ *
617
+ * - A `|` is a cell boundary unless an ODD run of backslashes precedes it
618
+ * (`\|` is a pipe inside the cell; `\\|` is an escaped backslash and then a
619
+ * boundary). Code spans get no special treatment: GFM splits rows before
620
+ * inline parsing, so an unescaped `|` inside backticks is a boundary too.
621
+ * - A cell's `\|` shows as `|` — inside code spans too (spec example 200).
622
+ * - A table starts at a header holding an unescaped pipe whose NEXT line is a
623
+ * delimiter row (`--- | :-:`, edge pipes optional); a header without a leading
624
+ * pipe must match the delimiter row's width. It runs to a blank line or a
625
+ * line that starts another block (`- x`, `> y`, `# z`, `1.`, a fence, a rule).
626
+ *
627
+ * Pure TS, no dependencies.
628
+ */
629
+ /** The row's bytes between boundaries (edge segments included). */
630
+ declare function splitRowSegments(line: string): string[];
631
+ /** A row's cell texts as GFM reads them (source bytes, trimmed; edge pipes dropped). */
632
+ declare function rowCells(line: string): string[];
633
+ /** GFM's table-level unescape: a cell's `\|` is a pipe, in code spans too. */
634
+ declare function unescapeCellPipes(cell: string): string;
635
+ /** A GFM delimiter row: every cell `---`, `:--`, `--:` or `:-:`, with at least one pipe. */
636
+ declare function isGfmDelimiterRow(line: string): boolean;
637
+ /** A pipe-led row: `|` first, and another `|` after it. */
638
+ declare function isPipeLedRow(line: string): boolean;
639
+ /** True when `header` + `delimiter` open a table whose header has NO leading pipe. */
640
+ declare function startsPipelessTable(header: string, delimiter: string | undefined): boolean;
641
+ /** A line that continues an open table: a pipe-led row, or a pipe-less line with an unescaped pipe that starts no block. */
642
+ declare function continuesTable(line: string): boolean;
643
+ /** Line `index` opens a table: a pipe-led row, or a pipe-less GFM header over its delimiter row. */
644
+ declare function opensTable(lines: readonly string[], index: number): boolean;
645
+ /** A WHOLE table header at `index`: a table opens here AND its next line is a GFM delimiter row. */
646
+ declare function tableStartsAt(lines: readonly string[], index: number): boolean;
647
+ /** Index of the first line at or after `from` that opens a table; -1 when none. */
648
+ declare function findTableStart(lines: readonly string[], from?: number): number;
649
+ /** Index just past the table whose header is at `start` (header, delimiter, then continuation rows). */
650
+ declare function findTableEnd(lines: readonly string[], start: number): number;
651
+
652
+ export { AFTER_WINDOW, BacktickRuns, type BlockIslandType, CALLOUT_NAMES, type CodePointIndex, type CodeRange, type DisturbedIsland, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, type FenceEnd, type FenceLineKind, type FenceLines, type FenceOpener, FenceReader, type InlineIslandType, type InnerFenceLine, type IslandMeta, type IslandType, type MapOptions, type MappedPosition, type MappedRange, NESTING_FENCE_LANGUAGES, type ReadXmlTag, type SourceBlock, type SourceBlockKind, type SourceChange, type SourceEdit, type SourceIsland, type SourceSpan, SourceSpliceError, type SourceSpliceErrorCode, type SpliceIntegrity, type SpliceOptions, type SpliceResult, type TokenizeOptions, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, closeFence, codeSpanText, continuesTable, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, findCodeRanges, findTableEnd, findTableStart, isEscapedBracketMath, isGfmDelimiterRow, isMathPlaceholder, isPipeLedRow, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, looksLikeOpenInlineMath, mapCodeRanges, mapPosition, mapRange, opensTable, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, rowCells, singleDollarAfter, singleDollarMathEnd, spliceSave, splitRowSegments, splitsSurrogatePair, startsPipelessTable, tableStartsAt, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine, unescapeCellPipes };
package/dist/source.d.ts CHANGED
@@ -607,4 +607,46 @@ declare function pendingDisplayMathOpener(text: string): number;
607
607
  /** Map of `$$` opener offset → closer offset for every pair the renderer shows as math. */
608
608
  declare function pairDisplayMath(text: string): Map<number, number>;
609
609
 
610
- export { AFTER_WINDOW, BacktickRuns, type BlockIslandType, CALLOUT_NAMES, type CodePointIndex, type CodeRange, type DisturbedIsland, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, type FenceEnd, type FenceLineKind, type FenceLines, type FenceOpener, FenceReader, type InlineIslandType, type InnerFenceLine, type IslandMeta, type IslandType, type MapOptions, type MappedPosition, type MappedRange, NESTING_FENCE_LANGUAGES, type ReadXmlTag, type SourceBlock, type SourceBlockKind, type SourceChange, type SourceEdit, type SourceIsland, type SourceSpan, SourceSpliceError, type SourceSpliceErrorCode, type SpliceIntegrity, type SpliceOptions, type SpliceResult, type TokenizeOptions, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, closeFence, codeSpanText, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, findCodeRanges, isEscapedBracketMath, isMathPlaceholder, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, looksLikeOpenInlineMath, mapCodeRanges, mapPosition, mapRange, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, singleDollarAfter, singleDollarMathEnd, spliceSave, splitsSurrogatePair, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine };
610
+ /**
611
+ * THE GFM table rule — one splitter, one cell-pipe rule, one "where does a
612
+ * table start and run" — for every surface that reads a markdown table: the
613
+ * chat splitter and live stream, the table renderers and editors, the rich
614
+ * editor's writer, the print package, and (by shared vectors) the Python block
615
+ * detector. verify-RC-B4 R4/R5/R6.
616
+ *
617
+ * - A `|` is a cell boundary unless an ODD run of backslashes precedes it
618
+ * (`\|` is a pipe inside the cell; `\\|` is an escaped backslash and then a
619
+ * boundary). Code spans get no special treatment: GFM splits rows before
620
+ * inline parsing, so an unescaped `|` inside backticks is a boundary too.
621
+ * - A cell's `\|` shows as `|` — inside code spans too (spec example 200).
622
+ * - A table starts at a header holding an unescaped pipe whose NEXT line is a
623
+ * delimiter row (`--- | :-:`, edge pipes optional); a header without a leading
624
+ * pipe must match the delimiter row's width. It runs to a blank line or a
625
+ * line that starts another block (`- x`, `> y`, `# z`, `1.`, a fence, a rule).
626
+ *
627
+ * Pure TS, no dependencies.
628
+ */
629
+ /** The row's bytes between boundaries (edge segments included). */
630
+ declare function splitRowSegments(line: string): string[];
631
+ /** A row's cell texts as GFM reads them (source bytes, trimmed; edge pipes dropped). */
632
+ declare function rowCells(line: string): string[];
633
+ /** GFM's table-level unescape: a cell's `\|` is a pipe, in code spans too. */
634
+ declare function unescapeCellPipes(cell: string): string;
635
+ /** A GFM delimiter row: every cell `---`, `:--`, `--:` or `:-:`, with at least one pipe. */
636
+ declare function isGfmDelimiterRow(line: string): boolean;
637
+ /** A pipe-led row: `|` first, and another `|` after it. */
638
+ declare function isPipeLedRow(line: string): boolean;
639
+ /** True when `header` + `delimiter` open a table whose header has NO leading pipe. */
640
+ declare function startsPipelessTable(header: string, delimiter: string | undefined): boolean;
641
+ /** A line that continues an open table: a pipe-led row, or a pipe-less line with an unescaped pipe that starts no block. */
642
+ declare function continuesTable(line: string): boolean;
643
+ /** Line `index` opens a table: a pipe-led row, or a pipe-less GFM header over its delimiter row. */
644
+ declare function opensTable(lines: readonly string[], index: number): boolean;
645
+ /** A WHOLE table header at `index`: a table opens here AND its next line is a GFM delimiter row. */
646
+ declare function tableStartsAt(lines: readonly string[], index: number): boolean;
647
+ /** Index of the first line at or after `from` that opens a table; -1 when none. */
648
+ declare function findTableStart(lines: readonly string[], from?: number): number;
649
+ /** Index just past the table whose header is at `start` (header, delimiter, then continuation rows). */
650
+ declare function findTableEnd(lines: readonly string[], start: number): number;
651
+
652
+ export { AFTER_WINDOW, BacktickRuns, type BlockIslandType, CALLOUT_NAMES, type CodePointIndex, type CodeRange, type DisturbedIsland, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, type FenceEnd, type FenceLineKind, type FenceLines, type FenceOpener, FenceReader, type InlineIslandType, type InnerFenceLine, type IslandMeta, type IslandType, type MapOptions, type MappedPosition, type MappedRange, NESTING_FENCE_LANGUAGES, type ReadXmlTag, type SourceBlock, type SourceBlockKind, type SourceChange, type SourceEdit, type SourceIsland, type SourceSpan, SourceSpliceError, type SourceSpliceErrorCode, type SpliceIntegrity, type SpliceOptions, type SpliceResult, type TokenizeOptions, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, closeFence, codeSpanText, continuesTable, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, findCodeRanges, findTableEnd, findTableStart, isEscapedBracketMath, isGfmDelimiterRow, isMathPlaceholder, isPipeLedRow, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, looksLikeOpenInlineMath, mapCodeRanges, mapPosition, mapRange, opensTable, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, rowCells, singleDollarAfter, singleDollarMathEnd, spliceSave, splitRowSegments, splitsSurrogatePair, startsPipelessTable, tableStartsAt, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine, unescapeCellPipes };
package/dist/source.js CHANGED
@@ -2557,6 +2557,76 @@ function mapRange(changes, start, end, unit = "utf16") {
2557
2557
  return { start: newStart, end: newEnd, touched, collapsed: newEnd === newStart && end > start };
2558
2558
  }
2559
2559
 
2560
- export { AFTER_WINDOW, BacktickRuns, CALLOUT_NAMES, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, FenceReader, NESTING_FENCE_LANGUAGES, SourceSpliceError, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, closeFence, codeSpanText, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, findCodeRanges, isEscapedBracketMath, isMathPlaceholder, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, looksLikeOpenInlineMath, mapCodeRanges, mapPosition, mapRange, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, singleDollarAfter, singleDollarMathEnd, spliceSave, splitsSurrogatePair, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine };
2560
+ // source/gfm-table.ts
2561
+ function splitRowSegments(line) {
2562
+ const segments = [];
2563
+ let start = 0;
2564
+ for (let i = 0; i < line.length; i += 1) {
2565
+ const ch = line[i];
2566
+ if (ch === "\\") {
2567
+ i += 1;
2568
+ continue;
2569
+ }
2570
+ if (ch === "|") {
2571
+ segments.push(line.slice(start, i));
2572
+ start = i + 1;
2573
+ }
2574
+ }
2575
+ segments.push(line.slice(start));
2576
+ return segments;
2577
+ }
2578
+ function rowCells(line) {
2579
+ const cells = splitRowSegments(line).map((cell) => cell.trim());
2580
+ if (cells.length > 1 && cells[0] === "") cells.shift();
2581
+ if (cells.length > 1 && cells[cells.length - 1] === "") cells.pop();
2582
+ else if (cells.length === 1 && cells[0] === "") cells.pop();
2583
+ return cells;
2584
+ }
2585
+ function unescapeCellPipes(cell) {
2586
+ return cell.replace(/\\\|/g, "|");
2587
+ }
2588
+ var BLOCK_START = /^(?:[-+*](?:\s|$)|\d{1,9}[.)](?:\s|$)|>|#{1,6}(?:\s|$)|```|~~~|(?:-\s*){3,}$|(?:\*\s*){3,}$|(?:_\s*){3,}$)/;
2589
+ var DELIMITER_CELL = /^:?-+:?$/;
2590
+ function isGfmDelimiterRow(line) {
2591
+ const trimmed = line.trim();
2592
+ if (!trimmed.includes("|")) return false;
2593
+ const cells = rowCells(trimmed);
2594
+ return cells.length > 0 && cells.every((cell) => DELIMITER_CELL.test(cell));
2595
+ }
2596
+ function isPipeLedRow(line) {
2597
+ const trimmed = line.trim();
2598
+ return trimmed.startsWith("|") && trimmed.includes("|", 1);
2599
+ }
2600
+ function startsPipelessTable(header, delimiter) {
2601
+ const head = header.trim();
2602
+ if (!head || head.startsWith("|") || BLOCK_START.test(head)) return false;
2603
+ if (splitRowSegments(head).length < 2) return false;
2604
+ if (delimiter === void 0 || !isGfmDelimiterRow(delimiter)) return false;
2605
+ return rowCells(head).length === rowCells(delimiter.trim()).length;
2606
+ }
2607
+ function continuesTable(line) {
2608
+ const trimmed = line.trim();
2609
+ if (!trimmed) return false;
2610
+ if (trimmed.startsWith("|")) return trimmed.includes("|", 1);
2611
+ return splitRowSegments(trimmed).length > 1 && !BLOCK_START.test(trimmed);
2612
+ }
2613
+ function opensTable(lines, index) {
2614
+ const line = lines[index] ?? "";
2615
+ return isPipeLedRow(line) || startsPipelessTable(line, lines[index + 1]);
2616
+ }
2617
+ function tableStartsAt(lines, index) {
2618
+ return opensTable(lines, index) && isGfmDelimiterRow(lines[index + 1] ?? "");
2619
+ }
2620
+ function findTableStart(lines, from = 0) {
2621
+ for (let i = Math.max(0, from); i < lines.length; i += 1) if (opensTable(lines, i)) return i;
2622
+ return -1;
2623
+ }
2624
+ function findTableEnd(lines, start) {
2625
+ let end = Math.min(lines.length, start + 2);
2626
+ while (end < lines.length && continuesTable(lines[end] ?? "")) end += 1;
2627
+ return end;
2628
+ }
2629
+
2630
+ export { AFTER_WINDOW, BacktickRuns, CALLOUT_NAMES, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, FenceReader, NESTING_FENCE_LANGUAGES, SourceSpliceError, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, closeFence, codeSpanText, continuesTable, fenceLineKinds, fenceNestsInnerFences, fenceOpenerOf, fenceParts, findCodeRanges, findTableEnd, findTableStart, isEscapedBracketMath, isGfmDelimiterRow, isMathPlaceholder, isPipeLedRow, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, looksLikeOpenInlineMath, mapCodeRanges, mapPosition, mapRange, opensTable, pairDisplayMath, parseFenceOpener, pendingDisplayMathOpener, readXmlTag, rowCells, singleDollarAfter, singleDollarMathEnd, spliceSave, splitRowSegments, splitsSurrogatePair, startsPipelessTable, tableStartsAt, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine, unescapeCellPipes };
2561
2631
  //# sourceMappingURL=source.js.map
2562
2632
  //# sourceMappingURL=source.js.map