@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/index.js
CHANGED
|
@@ -5481,9 +5481,9 @@ function fenceOpenerOf(content) {
|
|
|
5481
5481
|
function opensStrictFence(line) {
|
|
5482
5482
|
return fenceOpenerOf(line) !== null;
|
|
5483
5483
|
}
|
|
5484
|
+
var LINE_START = { inString: false, escaped: false };
|
|
5484
5485
|
var FenceReader = class {
|
|
5485
5486
|
opener;
|
|
5486
|
-
state = { inString: false, escaped: false };
|
|
5487
5487
|
depth = 0;
|
|
5488
5488
|
/** A nested fence was opened at some point. */
|
|
5489
5489
|
sawNested = false;
|
|
@@ -5504,17 +5504,8 @@ var FenceReader = class {
|
|
|
5504
5504
|
if (this.tildeCloser) return this.tildeCloser.test(line);
|
|
5505
5505
|
const trimmedLine = trimFenceLine(line);
|
|
5506
5506
|
const at = line.indexOf("```");
|
|
5507
|
-
if (at === -1)
|
|
5508
|
-
|
|
5509
|
-
return false;
|
|
5510
|
-
}
|
|
5511
|
-
if (this.isJson) {
|
|
5512
|
-
const probe = jsonStringState(line, 0, at, this.state);
|
|
5513
|
-
if (probe.inString) {
|
|
5514
|
-
this.state = jsonStringState(line, at, line.length, probe);
|
|
5515
|
-
return false;
|
|
5516
|
-
}
|
|
5517
|
-
}
|
|
5507
|
+
if (at === -1) return false;
|
|
5508
|
+
if (this.isJson && jsonStringState(line, 0, at, LINE_START).inString) return false;
|
|
5518
5509
|
if (trimmedLine.startsWith("```")) {
|
|
5519
5510
|
const kind = classifyInnerFenceLine(trimmedLine, this.opener.ticks, this.nesting, this.depth);
|
|
5520
5511
|
if (kind === "close-outer") return true;
|
|
@@ -5528,7 +5519,6 @@ var FenceReader = class {
|
|
|
5528
5519
|
const after = trimFenceLine(line.slice(at + closeTicks));
|
|
5529
5520
|
if (closeTicks >= this.opener.ticks && after === "" && this.depth === 0) return true;
|
|
5530
5521
|
}
|
|
5531
|
-
if (this.isJson) this.state = jsonStringState(line, 0, line.length, this.state);
|
|
5532
5522
|
return false;
|
|
5533
5523
|
}
|
|
5534
5524
|
};
|
|
@@ -6412,6 +6402,8 @@ function findTableEnd(lines, start) {
|
|
|
6412
6402
|
}
|
|
6413
6403
|
|
|
6414
6404
|
// source/tokenize.ts
|
|
6405
|
+
var QUOTE_PREFIX = /^ {0,3}>(?: ?>)* ?/;
|
|
6406
|
+
var QUOTED_JSON_FENCE_LANGS = /* @__PURE__ */ new Set(["", "json", "jsonc", "json5"]);
|
|
6415
6407
|
var NOT_WHITESPACE = /\S/;
|
|
6416
6408
|
var DIRECTIVE_OPEN = /^(:{2,})([A-Za-z][\w-]*)/;
|
|
6417
6409
|
var MKDOCS_OPEN = /^(!!!|\?\?\?\+?)[ \t]+([A-Za-z][\w-]*)/;
|
|
@@ -6901,6 +6893,8 @@ var Tokenizer = class {
|
|
|
6901
6893
|
if (indent <= 3 && !listNested && t.startsWith(">")) {
|
|
6902
6894
|
const callout = this.callout(p, li, t);
|
|
6903
6895
|
if (callout) return callout;
|
|
6896
|
+
const lifted = this.quotedJsonFence(p, li, seg);
|
|
6897
|
+
if (lifted) return lifted;
|
|
6904
6898
|
}
|
|
6905
6899
|
if (atParaStart && indent <= 3 && t.startsWith("[^")) {
|
|
6906
6900
|
const footnote = this.footnoteDefinition(p, li, t);
|
|
@@ -7096,6 +7090,42 @@ var Tokenizer = class {
|
|
|
7096
7090
|
streaming: this.streaming
|
|
7097
7091
|
};
|
|
7098
7092
|
}
|
|
7093
|
+
/**
|
|
7094
|
+
* A JSON-family fence (unlabelled, json, jsonc, json5) opening on a quoted line. The renderer LIFTS it out
|
|
7095
|
+
* of the quote (matrx-frontend V1, never-raw law): the quote prefix is removed from every line of the
|
|
7096
|
+
* region, so the region is an ordinary top-level fence — drawn as code up to its own closer, which may sit on
|
|
7097
|
+
* a line that carries no `>` at all. The editor must lock at least what the renderer draws, so the island
|
|
7098
|
+
* runs from the quoted opener line to that closer (found on the lines with their quote prefix removed).
|
|
7099
|
+
*/
|
|
7100
|
+
quotedJsonFence(p, li, seg) {
|
|
7101
|
+
const m = QUOTE_PREFIX.exec(seg);
|
|
7102
|
+
if (!m) return null;
|
|
7103
|
+
const opener = fenceOpenerOf(seg.slice(m[0].length));
|
|
7104
|
+
if (!opener || opener.char !== "`" || !QUOTED_JSON_FENCE_LANGS.has(opener.lang.toLowerCase())) return null;
|
|
7105
|
+
const base2 = this.fenceLines;
|
|
7106
|
+
const lines = {
|
|
7107
|
+
...base2,
|
|
7108
|
+
line: (k) => {
|
|
7109
|
+
const text = base2.line(k);
|
|
7110
|
+
if (text === null) return null;
|
|
7111
|
+
const q = QUOTE_PREFIX.exec(text);
|
|
7112
|
+
return q ? text.slice(q[0].length) : text;
|
|
7113
|
+
}
|
|
7114
|
+
};
|
|
7115
|
+
let first = li;
|
|
7116
|
+
while (first > 0 && li - first < 400 && QUOTE_PREFIX.test(this.lineText(first - 1))) first--;
|
|
7117
|
+
for (let k = first; k < li; k++) {
|
|
7118
|
+
const o = fenceOpenerOf(lines.line(k) ?? "");
|
|
7119
|
+
if (!o || o.char !== "`" || QUOTED_JSON_FENCE_LANGS.has(o.lang.toLowerCase())) continue;
|
|
7120
|
+
const c = closeFence(lines, k, o);
|
|
7121
|
+
if (!c.closed || c.line >= li) return null;
|
|
7122
|
+
k = c.line;
|
|
7123
|
+
}
|
|
7124
|
+
const end = closeFence(lines, li, opener);
|
|
7125
|
+
const meta = { fence: "`", ticks: opener.ticks, lang: opener.lang };
|
|
7126
|
+
if (end.closed) return this.island("fence", p, this.contentEnds[end.line], true, meta);
|
|
7127
|
+
return this.island("fence", p, this.n, false, meta);
|
|
7128
|
+
}
|
|
7099
7129
|
/**
|
|
7100
7130
|
* Backtick fence — THE one closer (`closeFence`, source/code-ranges.ts): the
|
|
7101
7131
|
* nested-fence rule for markdown fences with the strict-CommonMark retry, the
|
|
@@ -7128,44 +7158,14 @@ var Tokenizer = class {
|
|
|
7128
7158
|
if (normalized && SPECIAL_CODE_LANGUAGES.has(normalized)) meta.special = normalized;
|
|
7129
7159
|
const close = closeFence(this.fenceLines, li, opener);
|
|
7130
7160
|
if (close.closed) {
|
|
7131
|
-
|
|
7132
|
-
const end = this.rendererOverflow(li + 1, close.line, tildeEnd);
|
|
7133
|
-
return this.island("fence", p, end, end === this.n ? this.overflowComplete : true, meta);
|
|
7161
|
+
return this.island("fence", p, this.contentEnds[close.line], true, meta);
|
|
7134
7162
|
}
|
|
7135
7163
|
return this.island("fence", p, this.n, false, meta);
|
|
7136
7164
|
}
|
|
7137
|
-
|
|
7138
|
-
|
|
7139
|
-
|
|
7140
|
-
|
|
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
|
-
}
|
|
7165
|
+
// A tilde island ends at its closer. The renderer's splitter treats `~~~` as a real fence since
|
|
7166
|
+
// matrx-frontend A4 (2026-09-30): the lines inside are code, so nothing that starts inside one runs
|
|
7167
|
+
// past the closer (the 0.14.2 "overflow" assumed the renderer did not know ~~~ and, kept, swallowed the
|
|
7168
|
+
// next fence's opener into the tilde island: a ````md block after a ~~~ block was left unlocked).
|
|
7169
7169
|
/**
|
|
7170
7170
|
* A line-leading `$$` that OPENS a math pair (source/math-pairs.ts — the
|
|
7171
7171
|
* core's rule). A closer, an unpaired `$$`, or a prose pair is never a block:
|