@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/index.js CHANGED
@@ -5801,6 +5801,7 @@ var IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_]*$/;
5801
5801
  var MATH_SUFFIX = /^(?:s|es|th|st|nd|rd)$/i;
5802
5802
  function isVariableChain(content, after) {
5803
5803
  if (/^\{[A-Za-z_][\w.]*\}$/.test(content)) return true;
5804
+ if (/^\(\(.*\)\)$/.test(content) || /^_[.[]/.test(content)) return true;
5804
5805
  if (!after) return false;
5805
5806
  if (after[0] === "{") return IDENTIFIER.test(content);
5806
5807
  const run = /^[A-Za-z0-9_]+/.exec(after)?.[0];
@@ -6372,6 +6373,16 @@ var Tokenizer = class {
6372
6373
  holdUndecidedTail() {
6373
6374
  const last = this.lineStarts.length - 1;
6374
6375
  if (last < 0) return;
6376
+ if (this.provisionalFrom < this.n) {
6377
+ for (let b = 0; b < this.blocks.length; b++) {
6378
+ const block = this.blocks[b];
6379
+ if (block.end <= this.provisionalFrom) continue;
6380
+ if (block.kind === "prose") block.inlines = block.inlines.filter((inline) => inline.end <= this.provisionalFrom);
6381
+ else if (block.island?.fromParagraph && block.start < this.provisionalFrom) {
6382
+ this.blocks[b] = { kind: "prose", start: block.start, end: block.end, island: null, inlines: [] };
6383
+ }
6384
+ }
6385
+ }
6375
6386
  if (this.isOpenTail(last)) {
6376
6387
  let b = this.blocks.length - 1;
6377
6388
  while (b >= 0 && this.blocks[b].kind === "gap") b--;
@@ -6669,6 +6680,9 @@ var Tokenizer = class {
6669
6680
  }
6670
6681
  if (this.isOpenTail(k)) return this.heldFootnote(p, open[1]);
6671
6682
  if (FOOTNOTE_DEF.test(line.trimStart())) break;
6683
+ if (this.streaming && TREE_GLYPHS.test(line) && this.connectorRunReachesEnd(k)) {
6684
+ return this.heldFootnote(p, open[1]);
6685
+ }
6672
6686
  const block = this.detectBlock(this.lineStarts[k], k, false);
6673
6687
  if (block && this.mayDissolve(block)) return this.heldFootnote(p, open[1]);
6674
6688
  if (block) break;
@@ -6676,8 +6690,22 @@ var Tokenizer = class {
6676
6690
  }
6677
6691
  const end = this.contentEnds[last];
6678
6692
  if (this.paragraphMayGrow(end)) return this.heldFootnote(p, open[1]);
6693
+ if (this.streaming && end > this.provisionalFrom) return this.heldFootnote(p, open[1]);
6679
6694
  return this.island("footnote_def", p, end, true, { id: open[1] });
6680
6695
  }
6696
+ /** Every line from `k` to the end is a connector line or blank (a tree may still form there). */
6697
+ connectorRunReachesEnd(k) {
6698
+ if (this.lastNonConnectorLine === void 0) {
6699
+ let j = this.lineCount - 1;
6700
+ for (; j >= 0; j--) {
6701
+ this.tick(1);
6702
+ if (!this.lineIsBlank(j) && !TREE_GLYPHS.test(this.lineText(j))) break;
6703
+ }
6704
+ this.lastNonConnectorLine = j;
6705
+ }
6706
+ return k > this.lastNonConnectorLine;
6707
+ }
6708
+ lastNonConnectorLine = void 0;
6681
6709
  /** A footnote whose continuation is still arriving: open to the end of the text. */
6682
6710
  heldFootnote(p, id) {
6683
6711
  return this.island("footnote_def", p, this.n, false, { id });
@@ -6942,7 +6970,6 @@ var Tokenizer = class {
6942
6970
  if (isRecognizedJsonHead(this.text.slice(tp, tp + 512))) {
6943
6971
  return this.island("json", p, this.n, false, jsonMeta(this.text.slice(tp)));
6944
6972
  }
6945
- this.provisionalFrom = Math.min(this.provisionalFrom, p);
6946
6973
  return null;
6947
6974
  }
6948
6975
  if (net !== 0) return null;