@ai-matrx/content-ir 0.19.2 → 0.19.3

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.cjs CHANGED
@@ -747,6 +747,7 @@ var IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;
747
747
  var MATH_SUFFIX = /^(?:s|es|th|st|nd|rd)$/i;
748
748
  function isVariableChain(content, after) {
749
749
  if (/^\{[A-Za-z_][\w.]*\}$/.test(content)) return true;
750
+ if (/^\(\(.*\)\)$/.test(content) || /^_[.[]/.test(content)) return true;
750
751
  if (!after) return false;
751
752
  if (after[0] === "{") return IDENTIFIER.test(content);
752
753
  const run = /^[A-Za-z0-9_]+/.exec(after)?.[0];
@@ -1318,6 +1319,16 @@ var Tokenizer = class {
1318
1319
  holdUndecidedTail() {
1319
1320
  const last = this.lineStarts.length - 1;
1320
1321
  if (last < 0) return;
1322
+ if (this.provisionalFrom < this.n) {
1323
+ for (let b = 0; b < this.blocks.length; b++) {
1324
+ const block = this.blocks[b];
1325
+ if (block.end <= this.provisionalFrom) continue;
1326
+ if (block.kind === "prose") block.inlines = block.inlines.filter((inline) => inline.end <= this.provisionalFrom);
1327
+ else if (block.island?.fromParagraph && block.start < this.provisionalFrom) {
1328
+ this.blocks[b] = { kind: "prose", start: block.start, end: block.end, island: null, inlines: [] };
1329
+ }
1330
+ }
1331
+ }
1321
1332
  if (this.isOpenTail(last)) {
1322
1333
  let b = this.blocks.length - 1;
1323
1334
  while (b >= 0 && this.blocks[b].kind === "gap") b--;
@@ -1615,6 +1626,9 @@ var Tokenizer = class {
1615
1626
  }
1616
1627
  if (this.isOpenTail(k)) return this.heldFootnote(p, open[1]);
1617
1628
  if (FOOTNOTE_DEF.test(line.trimStart())) break;
1629
+ if (this.streaming && TREE_GLYPHS.test(line) && this.connectorRunReachesEnd(k)) {
1630
+ return this.heldFootnote(p, open[1]);
1631
+ }
1618
1632
  const block = this.detectBlock(this.lineStarts[k], k, false);
1619
1633
  if (block && this.mayDissolve(block)) return this.heldFootnote(p, open[1]);
1620
1634
  if (block) break;
@@ -1622,8 +1636,22 @@ var Tokenizer = class {
1622
1636
  }
1623
1637
  const end = this.contentEnds[last];
1624
1638
  if (this.paragraphMayGrow(end)) return this.heldFootnote(p, open[1]);
1639
+ if (this.streaming && end > this.provisionalFrom) return this.heldFootnote(p, open[1]);
1625
1640
  return this.island("footnote_def", p, end, true, { id: open[1] });
1626
1641
  }
1642
+ /** Every line from `k` to the end is a connector line or blank (a tree may still form there). */
1643
+ connectorRunReachesEnd(k) {
1644
+ if (this.lastNonConnectorLine === void 0) {
1645
+ let j = this.lineCount - 1;
1646
+ for (; j >= 0; j--) {
1647
+ this.tick(1);
1648
+ if (!this.lineIsBlank(j) && !TREE_GLYPHS.test(this.lineText(j))) break;
1649
+ }
1650
+ this.lastNonConnectorLine = j;
1651
+ }
1652
+ return k > this.lastNonConnectorLine;
1653
+ }
1654
+ lastNonConnectorLine = void 0;
1627
1655
  /** A footnote whose continuation is still arriving: open to the end of the text. */
1628
1656
  heldFootnote(p, id) {
1629
1657
  return this.island("footnote_def", p, this.n, false, { id });
@@ -1888,7 +1916,6 @@ var Tokenizer = class {
1888
1916
  if (isRecognizedJsonHead(this.text.slice(tp, tp + 512))) {
1889
1917
  return this.island("json", p, this.n, false, jsonMeta(this.text.slice(tp)));
1890
1918
  }
1891
- this.provisionalFrom = Math.min(this.provisionalFrom, p);
1892
1919
  return null;
1893
1920
  }
1894
1921
  if (net !== 0) return null;