@ai-matrx/content-ir 0.21.0 → 0.21.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 +30 -0
- package/dist/index.cjs +48 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +48 -48
- package/dist/index.js.map +1 -1
- package/dist/source.cjs +48 -48
- package/dist/source.cjs.map +1 -1
- package/dist/source.d.cts +0 -12
- package/dist/source.d.ts +0 -12
- package/dist/source.js +48 -48
- package/dist/source.js.map +1 -1
- package/package.json +1 -1
package/dist/source.cjs
CHANGED
|
@@ -277,9 +277,9 @@ function fenceOpenerOf(content) {
|
|
|
277
277
|
function opensStrictFence(line) {
|
|
278
278
|
return fenceOpenerOf(line) !== null;
|
|
279
279
|
}
|
|
280
|
+
var LINE_START = { inString: false, escaped: false };
|
|
280
281
|
var FenceReader = class {
|
|
281
282
|
opener;
|
|
282
|
-
state = { inString: false, escaped: false };
|
|
283
283
|
depth = 0;
|
|
284
284
|
/** A nested fence was opened at some point. */
|
|
285
285
|
sawNested = false;
|
|
@@ -300,17 +300,8 @@ var FenceReader = class {
|
|
|
300
300
|
if (this.tildeCloser) return this.tildeCloser.test(line);
|
|
301
301
|
const trimmedLine = trimFenceLine(line);
|
|
302
302
|
const at = line.indexOf("```");
|
|
303
|
-
if (at === -1)
|
|
304
|
-
|
|
305
|
-
return false;
|
|
306
|
-
}
|
|
307
|
-
if (this.isJson) {
|
|
308
|
-
const probe = jsonStringState(line, 0, at, this.state);
|
|
309
|
-
if (probe.inString) {
|
|
310
|
-
this.state = jsonStringState(line, at, line.length, probe);
|
|
311
|
-
return false;
|
|
312
|
-
}
|
|
313
|
-
}
|
|
303
|
+
if (at === -1) return false;
|
|
304
|
+
if (this.isJson && jsonStringState(line, 0, at, LINE_START).inString) return false;
|
|
314
305
|
if (trimmedLine.startsWith("```")) {
|
|
315
306
|
const kind = classifyInnerFenceLine(trimmedLine, this.opener.ticks, this.nesting, this.depth);
|
|
316
307
|
if (kind === "close-outer") return true;
|
|
@@ -324,7 +315,6 @@ var FenceReader = class {
|
|
|
324
315
|
const after = trimFenceLine(line.slice(at + closeTicks));
|
|
325
316
|
if (closeTicks >= this.opener.ticks && after === "" && this.depth === 0) return true;
|
|
326
317
|
}
|
|
327
|
-
if (this.isJson) this.state = jsonStringState(line, 0, line.length, this.state);
|
|
328
318
|
return false;
|
|
329
319
|
}
|
|
330
320
|
};
|
|
@@ -1208,6 +1198,8 @@ function findTableEnd(lines, start) {
|
|
|
1208
1198
|
}
|
|
1209
1199
|
|
|
1210
1200
|
// source/tokenize.ts
|
|
1201
|
+
var QUOTE_PREFIX = /^ {0,3}>(?: ?>)* ?/;
|
|
1202
|
+
var QUOTED_JSON_FENCE_LANGS = /* @__PURE__ */ new Set(["", "json", "jsonc", "json5"]);
|
|
1211
1203
|
var NOT_WHITESPACE = /\S/;
|
|
1212
1204
|
var DIRECTIVE_OPEN = /^(:{2,})([A-Za-z][\w-]*)/;
|
|
1213
1205
|
var MKDOCS_OPEN = /^(!!!|\?\?\?\+?)[ \t]+([A-Za-z][\w-]*)/;
|
|
@@ -1697,6 +1689,8 @@ var Tokenizer = class {
|
|
|
1697
1689
|
if (indent <= 3 && !listNested && t.startsWith(">")) {
|
|
1698
1690
|
const callout = this.callout(p, li, t);
|
|
1699
1691
|
if (callout) return callout;
|
|
1692
|
+
const lifted = this.quotedJsonFence(p, li, seg);
|
|
1693
|
+
if (lifted) return lifted;
|
|
1700
1694
|
}
|
|
1701
1695
|
if (atParaStart && indent <= 3 && t.startsWith("[^")) {
|
|
1702
1696
|
const footnote = this.footnoteDefinition(p, li, t);
|
|
@@ -1892,6 +1886,42 @@ var Tokenizer = class {
|
|
|
1892
1886
|
streaming: this.streaming
|
|
1893
1887
|
};
|
|
1894
1888
|
}
|
|
1889
|
+
/**
|
|
1890
|
+
* A JSON-family fence (unlabelled, json, jsonc, json5) opening on a quoted line. The renderer LIFTS it out
|
|
1891
|
+
* of the quote (matrx-frontend V1, never-raw law): the quote prefix is removed from every line of the
|
|
1892
|
+
* region, so the region is an ordinary top-level fence — drawn as code up to its own closer, which may sit on
|
|
1893
|
+
* a line that carries no `>` at all. The editor must lock at least what the renderer draws, so the island
|
|
1894
|
+
* runs from the quoted opener line to that closer (found on the lines with their quote prefix removed).
|
|
1895
|
+
*/
|
|
1896
|
+
quotedJsonFence(p, li, seg) {
|
|
1897
|
+
const m = QUOTE_PREFIX.exec(seg);
|
|
1898
|
+
if (!m) return null;
|
|
1899
|
+
const opener = fenceOpenerOf(seg.slice(m[0].length));
|
|
1900
|
+
if (!opener || opener.char !== "`" || !QUOTED_JSON_FENCE_LANGS.has(opener.lang.toLowerCase())) return null;
|
|
1901
|
+
const base = this.fenceLines;
|
|
1902
|
+
const lines = {
|
|
1903
|
+
...base,
|
|
1904
|
+
line: (k) => {
|
|
1905
|
+
const text = base.line(k);
|
|
1906
|
+
if (text === null) return null;
|
|
1907
|
+
const q = QUOTE_PREFIX.exec(text);
|
|
1908
|
+
return q ? text.slice(q[0].length) : text;
|
|
1909
|
+
}
|
|
1910
|
+
};
|
|
1911
|
+
let first = li;
|
|
1912
|
+
while (first > 0 && li - first < 400 && QUOTE_PREFIX.test(this.lineText(first - 1))) first--;
|
|
1913
|
+
for (let k = first; k < li; k++) {
|
|
1914
|
+
const o = fenceOpenerOf(lines.line(k) ?? "");
|
|
1915
|
+
if (!o || o.char !== "`" || QUOTED_JSON_FENCE_LANGS.has(o.lang.toLowerCase())) continue;
|
|
1916
|
+
const c = closeFence(lines, k, o);
|
|
1917
|
+
if (!c.closed || c.line >= li) return null;
|
|
1918
|
+
k = c.line;
|
|
1919
|
+
}
|
|
1920
|
+
const end = closeFence(lines, li, opener);
|
|
1921
|
+
const meta = { fence: "`", ticks: opener.ticks, lang: opener.lang };
|
|
1922
|
+
if (end.closed) return this.island("fence", p, this.contentEnds[end.line], true, meta);
|
|
1923
|
+
return this.island("fence", p, this.n, false, meta);
|
|
1924
|
+
}
|
|
1895
1925
|
/**
|
|
1896
1926
|
* Backtick fence — THE one closer (`closeFence`, source/code-ranges.ts): the
|
|
1897
1927
|
* nested-fence rule for markdown fences with the strict-CommonMark retry, the
|
|
@@ -1924,44 +1954,14 @@ var Tokenizer = class {
|
|
|
1924
1954
|
if (normalized && SPECIAL_CODE_LANGUAGES.has(normalized)) meta.special = normalized;
|
|
1925
1955
|
const close = closeFence(this.fenceLines, li, opener);
|
|
1926
1956
|
if (close.closed) {
|
|
1927
|
-
|
|
1928
|
-
const end = this.rendererOverflow(li + 1, close.line, tildeEnd);
|
|
1929
|
-
return this.island("fence", p, end, end === this.n ? this.overflowComplete : true, meta);
|
|
1957
|
+
return this.island("fence", p, this.contentEnds[close.line], true, meta);
|
|
1930
1958
|
}
|
|
1931
1959
|
return this.island("fence", p, this.n, false, meta);
|
|
1932
1960
|
}
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
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
|
-
}
|
|
1961
|
+
// A tilde island ends at its closer. The renderer's splitter treats `~~~` as a real fence since
|
|
1962
|
+
// matrx-frontend A4 (2026-09-30): the lines inside are code, so nothing that starts inside one runs
|
|
1963
|
+
// past the closer (the 0.14.2 "overflow" assumed the renderer did not know ~~~ and, kept, swallowed the
|
|
1964
|
+
// next fence's opener into the tilde island: a ````md block after a ~~~ block was left unlocked).
|
|
1965
1965
|
/**
|
|
1966
1966
|
* A line-leading `$$` that OPENS a math pair (source/math-pairs.ts — the
|
|
1967
1967
|
* core's rule). A closer, an unpaired `$$`, or a prose pair is never a block:
|