@ai-matrx/content-ir 0.14.1 → 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
@@ -5999,11 +5999,41 @@ var Tokenizer = class {
5999
5999
  for (let k = li + 1; k < this.lineCount; k++) {
6000
6000
  if (this.isOpenTail(k)) continue;
6001
6001
  if (close.test(this.lineText(k))) {
6002
- 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);
6003
6005
  }
6004
6006
  }
6005
6007
  return this.island("fence", p, this.n, false, meta);
6006
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
+ }
6007
6037
  /**
6008
6038
  * A line-leading `$$` that OPENS a math pair (source/math-pairs.ts — the
6009
6039
  * core's rule). A closer, an unpaired `$$`, or a prose pair is never a block: