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