@ai-matrx/content-ir 0.21.0 → 0.21.1

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
@@ -6412,6 +6412,8 @@ function findTableEnd(lines, start) {
6412
6412
  }
6413
6413
 
6414
6414
  // source/tokenize.ts
6415
+ var QUOTE_PREFIX = /^ {0,3}>(?: ?>)* ?/;
6416
+ var QUOTED_JSON_FENCE_LANGS = /* @__PURE__ */ new Set(["", "json", "jsonc", "json5"]);
6415
6417
  var NOT_WHITESPACE = /\S/;
6416
6418
  var DIRECTIVE_OPEN = /^(:{2,})([A-Za-z][\w-]*)/;
6417
6419
  var MKDOCS_OPEN = /^(!!!|\?\?\?\+?)[ \t]+([A-Za-z][\w-]*)/;
@@ -6901,6 +6903,8 @@ var Tokenizer = class {
6901
6903
  if (indent <= 3 && !listNested && t.startsWith(">")) {
6902
6904
  const callout = this.callout(p, li, t);
6903
6905
  if (callout) return callout;
6906
+ const lifted = this.quotedJsonFence(p, li, seg);
6907
+ if (lifted) return lifted;
6904
6908
  }
6905
6909
  if (atParaStart && indent <= 3 && t.startsWith("[^")) {
6906
6910
  const footnote = this.footnoteDefinition(p, li, t);
@@ -7096,6 +7100,42 @@ var Tokenizer = class {
7096
7100
  streaming: this.streaming
7097
7101
  };
7098
7102
  }
7103
+ /**
7104
+ * A JSON-family fence (unlabelled, json, jsonc, json5) opening on a quoted line. The renderer LIFTS it out
7105
+ * of the quote (matrx-frontend V1, never-raw law): the quote prefix is removed from every line of the
7106
+ * region, so the region is an ordinary top-level fence — drawn as code up to its own closer, which may sit on
7107
+ * a line that carries no `>` at all. The editor must lock at least what the renderer draws, so the island
7108
+ * runs from the quoted opener line to that closer (found on the lines with their quote prefix removed).
7109
+ */
7110
+ quotedJsonFence(p, li, seg) {
7111
+ const m = QUOTE_PREFIX.exec(seg);
7112
+ if (!m) return null;
7113
+ const opener = fenceOpenerOf(seg.slice(m[0].length));
7114
+ if (!opener || opener.char !== "`" || !QUOTED_JSON_FENCE_LANGS.has(opener.lang.toLowerCase())) return null;
7115
+ const base2 = this.fenceLines;
7116
+ const lines = {
7117
+ ...base2,
7118
+ line: (k) => {
7119
+ const text = base2.line(k);
7120
+ if (text === null) return null;
7121
+ const q = QUOTE_PREFIX.exec(text);
7122
+ return q ? text.slice(q[0].length) : text;
7123
+ }
7124
+ };
7125
+ let first = li;
7126
+ while (first > 0 && li - first < 400 && QUOTE_PREFIX.test(this.lineText(first - 1))) first--;
7127
+ for (let k = first; k < li; k++) {
7128
+ const o = fenceOpenerOf(lines.line(k) ?? "");
7129
+ if (!o || o.char !== "`" || QUOTED_JSON_FENCE_LANGS.has(o.lang.toLowerCase())) continue;
7130
+ const c = closeFence(lines, k, o);
7131
+ if (!c.closed || c.line >= li) return null;
7132
+ k = c.line;
7133
+ }
7134
+ const end = closeFence(lines, li, opener);
7135
+ const meta = { fence: "`", ticks: opener.ticks, lang: opener.lang };
7136
+ if (end.closed) return this.island("fence", p, this.contentEnds[end.line], true, meta);
7137
+ return this.island("fence", p, this.n, false, meta);
7138
+ }
7099
7139
  /**
7100
7140
  * Backtick fence — THE one closer (`closeFence`, source/code-ranges.ts): the
7101
7141
  * nested-fence rule for markdown fences with the strict-CommonMark retry, the
@@ -7128,44 +7168,14 @@ var Tokenizer = class {
7128
7168
  if (normalized && SPECIAL_CODE_LANGUAGES.has(normalized)) meta.special = normalized;
7129
7169
  const close = closeFence(this.fenceLines, li, opener);
7130
7170
  if (close.closed) {
7131
- const tildeEnd = this.contentEnds[close.line];
7132
- const end = this.rendererOverflow(li + 1, close.line, tildeEnd);
7133
- return this.island("fence", p, end, end === this.n ? this.overflowComplete : true, meta);
7171
+ return this.island("fence", p, this.contentEnds[close.line], true, meta);
7134
7172
  }
7135
7173
  return this.island("fence", p, this.n, false, meta);
7136
7174
  }
7137
- /** Completion of the last `rendererOverflow` that ran to the end of the text. */
7138
- overflowComplete = true;
7139
- /**
7140
- * The renderer's splitter does not know ~~~ fences: it reads the lines inside
7141
- * one as ordinary lines, so a ```` ``` ```` fence (or an XML section, a JSON
7142
- * block…) that STARTS inside the tilde fence can run past its closer. The
7143
- * editor must lock at least what the renderer draws (verify-RC-B3 residual
7144
- * R5), so a tilde island extends over every block the renderer would detect
7145
- * starting inside it. Returns the island's end.
7146
- */
7147
- rendererOverflow(firstLine, closeLine, tildeEnd) {
7148
- let end = tildeEnd;
7149
- this.overflowComplete = true;
7150
- for (let j = firstLine; j <= closeLine && j < this.lineCount; j++) {
7151
- const start = this.lineStarts[j];
7152
- if (this.lineIsBlank(j)) continue;
7153
- if (fenceOpenerOf(this.lineText(j))?.char === "~") continue;
7154
- const inner = this.detectBlockUncached(start, j, false);
7155
- if (!inner) continue;
7156
- if (this.streaming && inner.end >= tildeEnd && this.paragraphMayGrow(inner.end)) {
7157
- this.overflowComplete = false;
7158
- return this.n;
7159
- }
7160
- if (inner.end > end) {
7161
- end = inner.end;
7162
- this.overflowComplete = inner.complete;
7163
- }
7164
- const lastLine = this.lineOf(Math.max(start, inner.end - 1));
7165
- if (lastLine > j) j = lastLine;
7166
- }
7167
- return end;
7168
- }
7175
+ // A tilde island ends at its closer. The renderer's splitter treats `~~~` as a real fence since
7176
+ // matrx-frontend A4 (2026-09-30): the lines inside are code, so nothing that starts inside one runs
7177
+ // past the closer (the 0.14.2 "overflow" assumed the renderer did not know ~~~ and, kept, swallowed the
7178
+ // next fence's opener into the tilde island: a ````md block after a ~~~ block was left unlocked).
7169
7179
  /**
7170
7180
  * A line-leading `$$` that OPENS a math pair (source/math-pairs.ts — the
7171
7181
  * core's rule). A closer, an unpaired `$$`, or a prose pair is never a block: