@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/index.js CHANGED
@@ -5233,6 +5233,7 @@ function isMathShape(content) {
5233
5233
  const words = content.match(/[A-Za-z]+/g);
5234
5234
  if (!words) return false;
5235
5235
  if (!words.every((w) => w.length === 1 || FUNCTION_NAMES.has(w))) return false;
5236
+ if (/[A-Za-z]'+[A-Za-z]/.test(content) || /(?:^|[\s(,])[A-Za-z]\.(?:[A-Za-z]\.|\s|$)/.test(content)) return false;
5236
5237
  return /[A-Za-z]'*\(|[A-Za-z]'|\b[A-Za-z]\s+[A-Za-z]\b|\([^)]*[A-Za-z][^)]*\)/.test(content);
5237
5238
  }
5238
5239
  function isSingleDollarMath(content, after) {
@@ -5998,11 +5999,41 @@ var Tokenizer = class {
5998
5999
  for (let k = li + 1; k < this.lineCount; k++) {
5999
6000
  if (this.isOpenTail(k)) continue;
6000
6001
  if (close.test(this.lineText(k))) {
6001
- return this.island("fence", p, this.contentEnds[k], true, meta);
6002
+ const tildeEnd = this.contentEnds[k];
6003
+ const end = this.rendererOverflow(li + 1, k, tildeEnd);
6004
+ return this.island("fence", p, end, end === this.n ? this.overflowComplete : true, meta);
6002
6005
  }
6003
6006
  }
6004
6007
  return this.island("fence", p, this.n, false, meta);
6005
6008
  }
6009
+ /** Completion of the last `rendererOverflow` that ran to the end of the text. */
6010
+ overflowComplete = true;
6011
+ /**
6012
+ * The renderer's splitter does not know ~~~ fences: it reads the lines inside
6013
+ * one as ordinary lines, so a ```` ``` ```` fence (or an XML section, a JSON
6014
+ * block…) that STARTS inside the tilde fence can run past its closer. The
6015
+ * editor must lock at least what the renderer draws (verify-RC-B3 residual
6016
+ * R5), so a tilde island extends over every block the renderer would detect
6017
+ * starting inside it. Returns the island's end.
6018
+ */
6019
+ rendererOverflow(firstLine, closeLine, tildeEnd) {
6020
+ let end = tildeEnd;
6021
+ this.overflowComplete = true;
6022
+ for (let j = firstLine; j <= closeLine && j < this.lineCount; j++) {
6023
+ const start = this.lineStarts[j];
6024
+ if (this.lineIsBlank(j)) continue;
6025
+ if (this.lineText(j).trimStart().startsWith("~~~")) continue;
6026
+ const inner = this.detectBlockUncached(start, j, false);
6027
+ if (!inner) continue;
6028
+ if (inner.end > end) {
6029
+ end = inner.end;
6030
+ this.overflowComplete = inner.complete;
6031
+ }
6032
+ const lastLine = this.lineOf(Math.max(start, inner.end - 1));
6033
+ if (lastLine > j) j = lastLine;
6034
+ }
6035
+ return end;
6036
+ }
6006
6037
  /**
6007
6038
  * A line-leading `$$` that OPENS a math pair (source/math-pairs.ts — the
6008
6039
  * core's rule). A closer, an unpaired `$$`, or a prose pair is never a block: