@ai-matrx/content-ir 0.19.9 → 0.19.10

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
@@ -630,9 +630,11 @@ declare function pairDisplayMath(text: string): Map<number, number>;
630
630
  * boundary). Code spans get no special treatment: GFM splits rows before
631
631
  * inline parsing, so an unescaped `|` inside backticks is a boundary too.
632
632
  * - A cell's `\|` shows as `|` — inside code spans too (spec example 200).
633
- * - A table starts at a header holding an unescaped pipe whose NEXT line is a
634
- * delimiter row (`--- | :-:`, edge pipes optional); a header without a leading
635
- * pipe must match the delimiter row's width. It runs to a blank line, a
633
+ * - A table starts at a header line whose NEXT line is a delimiter row (`--- |
634
+ * :-:`, edge pipes optional, never a list item such as `- | -`) of the SAME
635
+ * width; the header needs no pipe of its own (`Notes` over `|---|` is a
636
+ * one-column table), is not indented code, and is not a lazy continuation of a
637
+ * list item's or quote's paragraph. It runs to a blank line, a
636
638
  * line that starts another block (`- x`, `> y`, `# z`, `1.`, a fence, a rule,
637
639
  * an HTML block — CommonMark 4.6's seven start conditions), or a line indented
638
640
  * four or more columns past the table's container (indented code); every other
@@ -663,7 +665,11 @@ declare function tableContainerIndent(lines: readonly string[], start: number):
663
665
  declare function isGfmDelimiterRow(line: string): boolean;
664
666
  /** A pipe-led row: `|` first, and another `|` after it. */
665
667
  declare function isPipeLedRow(line: string): boolean;
666
- /** True when `header` + `delimiter` open a table whose header has NO leading pipe. */
668
+ /**
669
+ * True when `header` + `delimiter` open a table whose header is NOT a pipe-led
670
+ * row: `a | b` (no edge pipes), `| a` (one pipe), or even `Notes` (no pipe — a
671
+ * one-column table over `|---|`). The delimiter must match the header's width.
672
+ */
667
673
  declare function startsPipelessTable(header: string, delimiter: string | undefined): boolean;
668
674
  /**
669
675
  * A line that continues an open table — GFM's rule (spec example 202): the table
package/dist/source.d.ts CHANGED
@@ -630,9 +630,11 @@ declare function pairDisplayMath(text: string): Map<number, number>;
630
630
  * boundary). Code spans get no special treatment: GFM splits rows before
631
631
  * inline parsing, so an unescaped `|` inside backticks is a boundary too.
632
632
  * - A cell's `\|` shows as `|` — inside code spans too (spec example 200).
633
- * - A table starts at a header holding an unescaped pipe whose NEXT line is a
634
- * delimiter row (`--- | :-:`, edge pipes optional); a header without a leading
635
- * pipe must match the delimiter row's width. It runs to a blank line, a
633
+ * - A table starts at a header line whose NEXT line is a delimiter row (`--- |
634
+ * :-:`, edge pipes optional, never a list item such as `- | -`) of the SAME
635
+ * width; the header needs no pipe of its own (`Notes` over `|---|` is a
636
+ * one-column table), is not indented code, and is not a lazy continuation of a
637
+ * list item's or quote's paragraph. It runs to a blank line, a
636
638
  * line that starts another block (`- x`, `> y`, `# z`, `1.`, a fence, a rule,
637
639
  * an HTML block — CommonMark 4.6's seven start conditions), or a line indented
638
640
  * four or more columns past the table's container (indented code); every other
@@ -663,7 +665,11 @@ declare function tableContainerIndent(lines: readonly string[], start: number):
663
665
  declare function isGfmDelimiterRow(line: string): boolean;
664
666
  /** A pipe-led row: `|` first, and another `|` after it. */
665
667
  declare function isPipeLedRow(line: string): boolean;
666
- /** True when `header` + `delimiter` open a table whose header has NO leading pipe. */
668
+ /**
669
+ * True when `header` + `delimiter` open a table whose header is NOT a pipe-led
670
+ * row: `a | b` (no edge pipes), `| a` (one pipe), or even `Notes` (no pipe — a
671
+ * one-column table over `|---|`). The delimiter must match the header's width.
672
+ */
667
673
  declare function startsPipelessTable(header: string, delimiter: string | undefined): boolean;
668
674
  /**
669
675
  * A line that continues an open table — GFM's rule (spec example 202): the table
package/dist/source.js CHANGED
@@ -2691,11 +2691,14 @@ function isPipeLedRow(line) {
2691
2691
  const trimmed = line.trim();
2692
2692
  return trimmed.startsWith("|") && trimmed.includes("|", 1);
2693
2693
  }
2694
+ function isTableDelimiter(line) {
2695
+ if (line === void 0 || !isGfmDelimiterRow(line)) return false;
2696
+ return !BLOCK_START.test(line.trim());
2697
+ }
2694
2698
  function startsPipelessTable(header, delimiter) {
2695
2699
  const head = header.trim();
2696
- if (!head || head.startsWith("|") || startsBlock(head)) return false;
2697
- if (splitRowSegments(head).length < 2) return false;
2698
- if (delimiter === void 0 || !isGfmDelimiterRow(delimiter)) return false;
2700
+ if (!head || isPipeLedRow(head) || !head.startsWith("|") && startsBlock(head)) return false;
2701
+ if (!isTableDelimiter(delimiter)) return false;
2699
2702
  return rowCells(head).length === rowCells(delimiter.trim()).length;
2700
2703
  }
2701
2704
  function continuesTable(line, containerIndent = 0) {
@@ -2736,7 +2739,11 @@ function isLazyContinuation(lines, index) {
2736
2739
  return lineIndent(header) < tableContainerIndentOf(lines, first, true);
2737
2740
  }
2738
2741
  function tableStartsAt(lines, index) {
2739
- return opensTable(lines, index) && isGfmDelimiterRow(lines[index + 1] ?? "");
2742
+ const header = lines[index] ?? "";
2743
+ const delimiter = lines[index + 1];
2744
+ if (!opensTable(lines, index) || !isTableDelimiter(delimiter)) return false;
2745
+ if (rowCells(header).length !== rowCells(delimiter).length) return false;
2746
+ return lineIndent(header) - tableContainerIndent(lines, index) < 4;
2740
2747
  }
2741
2748
  function findTableStart(lines, from = 0) {
2742
2749
  for (let i = Math.max(0, from); i < lines.length; i += 1) if (opensTable(lines, i)) return i;