@ai-matrx/content-ir 0.14.0 → 0.14.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.cjs CHANGED
@@ -266,6 +266,7 @@ function isMathShape(content) {
266
266
  const words = content.match(/[A-Za-z]+/g);
267
267
  if (!words) return false;
268
268
  if (!words.every((w) => w.length === 1 || FUNCTION_NAMES.has(w))) return false;
269
+ if (/[A-Za-z]'+[A-Za-z]/.test(content) || /(?:^|[\s(,])[A-Za-z]\.(?:[A-Za-z]\.|\s|$)/.test(content)) return false;
269
270
  return /[A-Za-z]'*\(|[A-Za-z]'|\b[A-Za-z]\s+[A-Za-z]\b|\([^)]*[A-Za-z][^)]*\)/.test(content);
270
271
  }
271
272
  function isSingleDollarMath(content, after) {
@@ -1031,11 +1032,41 @@ var Tokenizer = class {
1031
1032
  for (let k = li + 1; k < this.lineCount; k++) {
1032
1033
  if (this.isOpenTail(k)) continue;
1033
1034
  if (close.test(this.lineText(k))) {
1034
- return this.island("fence", p, this.contentEnds[k], true, meta);
1035
+ const tildeEnd = this.contentEnds[k];
1036
+ const end = this.rendererOverflow(li + 1, k, tildeEnd);
1037
+ return this.island("fence", p, end, end === this.n ? this.overflowComplete : true, meta);
1035
1038
  }
1036
1039
  }
1037
1040
  return this.island("fence", p, this.n, false, meta);
1038
1041
  }
1042
+ /** Completion of the last `rendererOverflow` that ran to the end of the text. */
1043
+ overflowComplete = true;
1044
+ /**
1045
+ * The renderer's splitter does not know ~~~ fences: it reads the lines inside
1046
+ * one as ordinary lines, so a ```` ``` ```` fence (or an XML section, a JSON
1047
+ * block…) that STARTS inside the tilde fence can run past its closer. The
1048
+ * editor must lock at least what the renderer draws (verify-RC-B3 residual
1049
+ * R5), so a tilde island extends over every block the renderer would detect
1050
+ * starting inside it. Returns the island's end.
1051
+ */
1052
+ rendererOverflow(firstLine, closeLine, tildeEnd) {
1053
+ let end = tildeEnd;
1054
+ this.overflowComplete = true;
1055
+ for (let j = firstLine; j <= closeLine && j < this.lineCount; j++) {
1056
+ const start = this.lineStarts[j];
1057
+ if (this.lineIsBlank(j)) continue;
1058
+ if (this.lineText(j).trimStart().startsWith("~~~")) continue;
1059
+ const inner = this.detectBlockUncached(start, j, false);
1060
+ if (!inner) continue;
1061
+ if (inner.end > end) {
1062
+ end = inner.end;
1063
+ this.overflowComplete = inner.complete;
1064
+ }
1065
+ const lastLine = this.lineOf(Math.max(start, inner.end - 1));
1066
+ if (lastLine > j) j = lastLine;
1067
+ }
1068
+ return end;
1069
+ }
1039
1070
  /**
1040
1071
  * A line-leading `$$` that OPENS a math pair (source/math-pairs.ts — the
1041
1072
  * core's rule). A closer, an unpaired `$$`, or a prose pair is never a block: