@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/source.cjs CHANGED
@@ -1032,11 +1032,41 @@ var Tokenizer = class {
1032
1032
  for (let k = li + 1; k < this.lineCount; k++) {
1033
1033
  if (this.isOpenTail(k)) continue;
1034
1034
  if (close.test(this.lineText(k))) {
1035
- 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);
1036
1038
  }
1037
1039
  }
1038
1040
  return this.island("fence", p, this.n, false, meta);
1039
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
+ }
1040
1070
  /**
1041
1071
  * A line-leading `$$` that OPENS a math pair (source/math-pairs.ts — the
1042
1072
  * core's rule). A closer, an unpaired `$$`, or a prose pair is never a block: