@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/source.cjs CHANGED
@@ -1208,6 +1208,8 @@ function findTableEnd(lines, start) {
1208
1208
  }
1209
1209
 
1210
1210
  // source/tokenize.ts
1211
+ var QUOTE_PREFIX = /^ {0,3}>(?: ?>)* ?/;
1212
+ var QUOTED_JSON_FENCE_LANGS = /* @__PURE__ */ new Set(["", "json", "jsonc", "json5"]);
1211
1213
  var NOT_WHITESPACE = /\S/;
1212
1214
  var DIRECTIVE_OPEN = /^(:{2,})([A-Za-z][\w-]*)/;
1213
1215
  var MKDOCS_OPEN = /^(!!!|\?\?\?\+?)[ \t]+([A-Za-z][\w-]*)/;
@@ -1697,6 +1699,8 @@ var Tokenizer = class {
1697
1699
  if (indent <= 3 && !listNested && t.startsWith(">")) {
1698
1700
  const callout = this.callout(p, li, t);
1699
1701
  if (callout) return callout;
1702
+ const lifted = this.quotedJsonFence(p, li, seg);
1703
+ if (lifted) return lifted;
1700
1704
  }
1701
1705
  if (atParaStart && indent <= 3 && t.startsWith("[^")) {
1702
1706
  const footnote = this.footnoteDefinition(p, li, t);
@@ -1892,6 +1896,42 @@ var Tokenizer = class {
1892
1896
  streaming: this.streaming
1893
1897
  };
1894
1898
  }
1899
+ /**
1900
+ * A JSON-family fence (unlabelled, json, jsonc, json5) opening on a quoted line. The renderer LIFTS it out
1901
+ * of the quote (matrx-frontend V1, never-raw law): the quote prefix is removed from every line of the
1902
+ * region, so the region is an ordinary top-level fence — drawn as code up to its own closer, which may sit on
1903
+ * a line that carries no `>` at all. The editor must lock at least what the renderer draws, so the island
1904
+ * runs from the quoted opener line to that closer (found on the lines with their quote prefix removed).
1905
+ */
1906
+ quotedJsonFence(p, li, seg) {
1907
+ const m = QUOTE_PREFIX.exec(seg);
1908
+ if (!m) return null;
1909
+ const opener = fenceOpenerOf(seg.slice(m[0].length));
1910
+ if (!opener || opener.char !== "`" || !QUOTED_JSON_FENCE_LANGS.has(opener.lang.toLowerCase())) return null;
1911
+ const base = this.fenceLines;
1912
+ const lines = {
1913
+ ...base,
1914
+ line: (k) => {
1915
+ const text = base.line(k);
1916
+ if (text === null) return null;
1917
+ const q = QUOTE_PREFIX.exec(text);
1918
+ return q ? text.slice(q[0].length) : text;
1919
+ }
1920
+ };
1921
+ let first = li;
1922
+ while (first > 0 && li - first < 400 && QUOTE_PREFIX.test(this.lineText(first - 1))) first--;
1923
+ for (let k = first; k < li; k++) {
1924
+ const o = fenceOpenerOf(lines.line(k) ?? "");
1925
+ if (!o || o.char !== "`" || QUOTED_JSON_FENCE_LANGS.has(o.lang.toLowerCase())) continue;
1926
+ const c = closeFence(lines, k, o);
1927
+ if (!c.closed || c.line >= li) return null;
1928
+ k = c.line;
1929
+ }
1930
+ const end = closeFence(lines, li, opener);
1931
+ const meta = { fence: "`", ticks: opener.ticks, lang: opener.lang };
1932
+ if (end.closed) return this.island("fence", p, this.contentEnds[end.line], true, meta);
1933
+ return this.island("fence", p, this.n, false, meta);
1934
+ }
1895
1935
  /**
1896
1936
  * Backtick fence — THE one closer (`closeFence`, source/code-ranges.ts): the
1897
1937
  * nested-fence rule for markdown fences with the strict-CommonMark retry, the
@@ -1924,44 +1964,14 @@ var Tokenizer = class {
1924
1964
  if (normalized && SPECIAL_CODE_LANGUAGES.has(normalized)) meta.special = normalized;
1925
1965
  const close = closeFence(this.fenceLines, li, opener);
1926
1966
  if (close.closed) {
1927
- const tildeEnd = this.contentEnds[close.line];
1928
- const end = this.rendererOverflow(li + 1, close.line, tildeEnd);
1929
- return this.island("fence", p, end, end === this.n ? this.overflowComplete : true, meta);
1967
+ return this.island("fence", p, this.contentEnds[close.line], true, meta);
1930
1968
  }
1931
1969
  return this.island("fence", p, this.n, false, meta);
1932
1970
  }
1933
- /** Completion of the last `rendererOverflow` that ran to the end of the text. */
1934
- overflowComplete = true;
1935
- /**
1936
- * The renderer's splitter does not know ~~~ fences: it reads the lines inside
1937
- * one as ordinary lines, so a ```` ``` ```` fence (or an XML section, a JSON
1938
- * block…) that STARTS inside the tilde fence can run past its closer. The
1939
- * editor must lock at least what the renderer draws (verify-RC-B3 residual
1940
- * R5), so a tilde island extends over every block the renderer would detect
1941
- * starting inside it. Returns the island's end.
1942
- */
1943
- rendererOverflow(firstLine, closeLine, tildeEnd) {
1944
- let end = tildeEnd;
1945
- this.overflowComplete = true;
1946
- for (let j = firstLine; j <= closeLine && j < this.lineCount; j++) {
1947
- const start = this.lineStarts[j];
1948
- if (this.lineIsBlank(j)) continue;
1949
- if (fenceOpenerOf(this.lineText(j))?.char === "~") continue;
1950
- const inner = this.detectBlockUncached(start, j, false);
1951
- if (!inner) continue;
1952
- if (this.streaming && inner.end >= tildeEnd && this.paragraphMayGrow(inner.end)) {
1953
- this.overflowComplete = false;
1954
- return this.n;
1955
- }
1956
- if (inner.end > end) {
1957
- end = inner.end;
1958
- this.overflowComplete = inner.complete;
1959
- }
1960
- const lastLine = this.lineOf(Math.max(start, inner.end - 1));
1961
- if (lastLine > j) j = lastLine;
1962
- }
1963
- return end;
1964
- }
1971
+ // A tilde island ends at its closer. The renderer's splitter treats `~~~` as a real fence since
1972
+ // matrx-frontend A4 (2026-09-30): the lines inside are code, so nothing that starts inside one runs
1973
+ // past the closer (the 0.14.2 "overflow" assumed the renderer did not know ~~~ and, kept, swallowed the
1974
+ // next fence's opener into the tilde island: a ````md block after a ~~~ block was left unlocked).
1965
1975
  /**
1966
1976
  * A line-leading `$$` that OPENS a math pair (source/math-pairs.ts — the
1967
1977
  * core's rule). A closer, an unpaired `$$`, or a prose pair is never a block: