@ai-matrx/content-ir 0.19.2 → 0.19.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/source.d.cts CHANGED
@@ -622,7 +622,8 @@ declare function pairDisplayMath(text: string): Map<number, number>;
622
622
  * - A table starts at a header holding an unescaped pipe whose NEXT line is a
623
623
  * delimiter row (`--- | :-:`, edge pipes optional); a header without a leading
624
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).
625
+ * line that starts another block (`- x`, `> y`, `# z`, `1.`, a fence, a rule);
626
+ * every other line is a row, with or without a pipe (spec example 202).
626
627
  *
627
628
  * Pure TS, no dependencies.
628
629
  */
@@ -638,7 +639,12 @@ declare function isGfmDelimiterRow(line: string): boolean;
638
639
  declare function isPipeLedRow(line: string): boolean;
639
640
  /** True when `header` + `delimiter` open a table whose header has NO leading pipe. */
640
641
  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
+ /**
643
+ * A line that continues an open table — GFM's rule (spec example 202): the table
644
+ * runs to the first blank line or the first line that starts another block; any
645
+ * other line is a row, even one without a pipe (`bar` → a one-cell row) and a
646
+ * lone `|` (an empty row). verify-RC-B4 R7-2.
647
+ */
642
648
  declare function continuesTable(line: string): boolean;
643
649
  /** Line `index` opens a table: a pipe-led row, or a pipe-less GFM header over its delimiter row. */
644
650
  declare function opensTable(lines: readonly string[], index: number): boolean;
package/dist/source.d.ts CHANGED
@@ -622,7 +622,8 @@ declare function pairDisplayMath(text: string): Map<number, number>;
622
622
  * - A table starts at a header holding an unescaped pipe whose NEXT line is a
623
623
  * delimiter row (`--- | :-:`, edge pipes optional); a header without a leading
624
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).
625
+ * line that starts another block (`- x`, `> y`, `# z`, `1.`, a fence, a rule);
626
+ * every other line is a row, with or without a pipe (spec example 202).
626
627
  *
627
628
  * Pure TS, no dependencies.
628
629
  */
@@ -638,7 +639,12 @@ declare function isGfmDelimiterRow(line: string): boolean;
638
639
  declare function isPipeLedRow(line: string): boolean;
639
640
  /** True when `header` + `delimiter` open a table whose header has NO leading pipe. */
640
641
  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
+ /**
643
+ * A line that continues an open table — GFM's rule (spec example 202): the table
644
+ * runs to the first blank line or the first line that starts another block; any
645
+ * other line is a row, even one without a pipe (`bar` → a one-cell row) and a
646
+ * lone `|` (an empty row). verify-RC-B4 R7-2.
647
+ */
642
648
  declare function continuesTable(line: string): boolean;
643
649
  /** Line `index` opens a table: a pipe-led row, or a pipe-less GFM header over its delimiter row. */
644
650
  declare function opensTable(lines: readonly string[], index: number): boolean;
package/dist/source.js CHANGED
@@ -745,6 +745,7 @@ var IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;
745
745
  var MATH_SUFFIX = /^(?:s|es|th|st|nd|rd)$/i;
746
746
  function isVariableChain(content, after) {
747
747
  if (/^\{[A-Za-z_][\w.]*\}$/.test(content)) return true;
748
+ if (/^\(\(.*\)\)$/.test(content) || /^_[.[]/.test(content)) return true;
748
749
  if (!after) return false;
749
750
  if (after[0] === "{") return IDENTIFIER.test(content);
750
751
  const run = /^[A-Za-z0-9_]+/.exec(after)?.[0];
@@ -1316,6 +1317,16 @@ var Tokenizer = class {
1316
1317
  holdUndecidedTail() {
1317
1318
  const last = this.lineStarts.length - 1;
1318
1319
  if (last < 0) return;
1320
+ if (this.provisionalFrom < this.n) {
1321
+ for (let b = 0; b < this.blocks.length; b++) {
1322
+ const block = this.blocks[b];
1323
+ if (block.end <= this.provisionalFrom) continue;
1324
+ if (block.kind === "prose") block.inlines = block.inlines.filter((inline) => inline.end <= this.provisionalFrom);
1325
+ else if (block.island?.fromParagraph && block.start < this.provisionalFrom) {
1326
+ this.blocks[b] = { kind: "prose", start: block.start, end: block.end, island: null, inlines: [] };
1327
+ }
1328
+ }
1329
+ }
1319
1330
  if (this.isOpenTail(last)) {
1320
1331
  let b = this.blocks.length - 1;
1321
1332
  while (b >= 0 && this.blocks[b].kind === "gap") b--;
@@ -1613,6 +1624,9 @@ var Tokenizer = class {
1613
1624
  }
1614
1625
  if (this.isOpenTail(k)) return this.heldFootnote(p, open[1]);
1615
1626
  if (FOOTNOTE_DEF.test(line.trimStart())) break;
1627
+ if (this.streaming && TREE_GLYPHS.test(line) && this.connectorRunReachesEnd(k)) {
1628
+ return this.heldFootnote(p, open[1]);
1629
+ }
1616
1630
  const block = this.detectBlock(this.lineStarts[k], k, false);
1617
1631
  if (block && this.mayDissolve(block)) return this.heldFootnote(p, open[1]);
1618
1632
  if (block) break;
@@ -1620,8 +1634,22 @@ var Tokenizer = class {
1620
1634
  }
1621
1635
  const end = this.contentEnds[last];
1622
1636
  if (this.paragraphMayGrow(end)) return this.heldFootnote(p, open[1]);
1637
+ if (this.streaming && end > this.provisionalFrom) return this.heldFootnote(p, open[1]);
1623
1638
  return this.island("footnote_def", p, end, true, { id: open[1] });
1624
1639
  }
1640
+ /** Every line from `k` to the end is a connector line or blank (a tree may still form there). */
1641
+ connectorRunReachesEnd(k) {
1642
+ if (this.lastNonConnectorLine === void 0) {
1643
+ let j = this.lineCount - 1;
1644
+ for (; j >= 0; j--) {
1645
+ this.tick(1);
1646
+ if (!this.lineIsBlank(j) && !TREE_GLYPHS.test(this.lineText(j))) break;
1647
+ }
1648
+ this.lastNonConnectorLine = j;
1649
+ }
1650
+ return k > this.lastNonConnectorLine;
1651
+ }
1652
+ lastNonConnectorLine = void 0;
1625
1653
  /** A footnote whose continuation is still arriving: open to the end of the text. */
1626
1654
  heldFootnote(p, id) {
1627
1655
  return this.island("footnote_def", p, this.n, false, { id });
@@ -1886,7 +1914,6 @@ var Tokenizer = class {
1886
1914
  if (isRecognizedJsonHead(this.text.slice(tp, tp + 512))) {
1887
1915
  return this.island("json", p, this.n, false, jsonMeta(this.text.slice(tp)));
1888
1916
  }
1889
- this.provisionalFrom = Math.min(this.provisionalFrom, p);
1890
1917
  return null;
1891
1918
  }
1892
1919
  if (net !== 0) return null;
@@ -2607,8 +2634,7 @@ function startsPipelessTable(header, delimiter) {
2607
2634
  function continuesTable(line) {
2608
2635
  const trimmed = line.trim();
2609
2636
  if (!trimmed) return false;
2610
- if (trimmed.startsWith("|")) return trimmed.includes("|", 1);
2611
- return splitRowSegments(trimmed).length > 1 && !BLOCK_START.test(trimmed);
2637
+ return trimmed.startsWith("|") || !BLOCK_START.test(trimmed);
2612
2638
  }
2613
2639
  function opensTable(lines, index) {
2614
2640
  const line = lines[index] ?? "";