@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/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.14.2 — 2026-09-25
4
+
5
+ **`/source` — a tilde fence locks what the renderer draws inside it**
6
+ (verify-RC-B3 residual R5). The renderer's splitter does not know `~~~`
7
+ fences, so a ```` ``` ```` fence (or an XML section, a JSON block) that starts
8
+ inside one can run past the tilde closer — and the tokenizer had left that
9
+ overflow as editable prose. A tilde island now extends over every block the
10
+ renderer would detect starting inside it (the union of both readings). Found
11
+ by matrx-frontend's new `source-covers-renderer` property test (every fenced
12
+ block the renderer draws must sit inside one tokenizer island; red on 0.14.1,
13
+ green on 0.14.2 over 80k generated documents with tilde, nested-markdown,
14
+ CRLF and exotic-whitespace fences). Guard here: 3 cases in
15
+ `__tests__/source-verify-findings.test.ts`.
16
+
17
+ **Consumer action:** none.
18
+
3
19
  ## 0.14.1 — 2026-09-25
4
20
 
5
21
  **Single-dollar math: an adversarial review of the widened rule** (RC-B2's
package/dist/index.cjs CHANGED
@@ -6005,11 +6005,41 @@ var Tokenizer = class {
6005
6005
  for (let k = li + 1; k < this.lineCount; k++) {
6006
6006
  if (this.isOpenTail(k)) continue;
6007
6007
  if (close.test(this.lineText(k))) {
6008
- return this.island("fence", p, this.contentEnds[k], true, meta);
6008
+ const tildeEnd = this.contentEnds[k];
6009
+ const end = this.rendererOverflow(li + 1, k, tildeEnd);
6010
+ return this.island("fence", p, end, end === this.n ? this.overflowComplete : true, meta);
6009
6011
  }
6010
6012
  }
6011
6013
  return this.island("fence", p, this.n, false, meta);
6012
6014
  }
6015
+ /** Completion of the last `rendererOverflow` that ran to the end of the text. */
6016
+ overflowComplete = true;
6017
+ /**
6018
+ * The renderer's splitter does not know ~~~ fences: it reads the lines inside
6019
+ * one as ordinary lines, so a ```` ``` ```` fence (or an XML section, a JSON
6020
+ * block…) that STARTS inside the tilde fence can run past its closer. The
6021
+ * editor must lock at least what the renderer draws (verify-RC-B3 residual
6022
+ * R5), so a tilde island extends over every block the renderer would detect
6023
+ * starting inside it. Returns the island's end.
6024
+ */
6025
+ rendererOverflow(firstLine, closeLine, tildeEnd) {
6026
+ let end = tildeEnd;
6027
+ this.overflowComplete = true;
6028
+ for (let j = firstLine; j <= closeLine && j < this.lineCount; j++) {
6029
+ const start = this.lineStarts[j];
6030
+ if (this.lineIsBlank(j)) continue;
6031
+ if (this.lineText(j).trimStart().startsWith("~~~")) continue;
6032
+ const inner = this.detectBlockUncached(start, j, false);
6033
+ if (!inner) continue;
6034
+ if (inner.end > end) {
6035
+ end = inner.end;
6036
+ this.overflowComplete = inner.complete;
6037
+ }
6038
+ const lastLine = this.lineOf(Math.max(start, inner.end - 1));
6039
+ if (lastLine > j) j = lastLine;
6040
+ }
6041
+ return end;
6042
+ }
6013
6043
  /**
6014
6044
  * A line-leading `$$` that OPENS a math pair (source/math-pairs.ts — the
6015
6045
  * core's rule). A closer, an unpaired `$$`, or a prose pair is never a block: