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