@ai-matrx/content-ir 0.19.0 → 0.19.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 +7 -0
- package/dist/index.cjs +14 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -22
- package/dist/index.js.map +1 -1
- package/dist/source.cjs +14 -22
- package/dist/source.cjs.map +1 -1
- package/dist/source.js +14 -22
- package/dist/source.js.map +1 -1
- package/package.json +1 -1
package/dist/source.cjs
CHANGED
|
@@ -588,7 +588,7 @@ function pendingCodeSpanStart(text) {
|
|
|
588
588
|
const n = text.length;
|
|
589
589
|
if (n === 0 || /\n[ \t]*\n[ \t]*$/.test(text)) return -1;
|
|
590
590
|
const lastLine = text.slice(text.lastIndexOf("\n") + 1);
|
|
591
|
-
if (lastLine && /^(?: {0,3}>[ \t]?)*[ \t]*$/.test(lastLine)) return pendingCodeSpanStart(`${text}x`);
|
|
591
|
+
if (lastLine && /^(?: {0,3}>[ \t]?)*[ \t\r]*$/.test(lastLine)) return pendingCodeSpanStart(`${text}x`);
|
|
592
592
|
const s = scan(text);
|
|
593
593
|
const para = s.pendingPara;
|
|
594
594
|
if (s.endsInFence || para === -1) return -1;
|
|
@@ -752,7 +752,7 @@ function isVariableChain(content, after) {
|
|
|
752
752
|
const run = /^[A-Za-z0-9_]+/.exec(after)?.[0];
|
|
753
753
|
if (!run) return false;
|
|
754
754
|
if (after.length === 1) return false;
|
|
755
|
-
if (/^[A-Za-z_][A-Za-z0-9_]*[.@-]$/.test(content)) return true;
|
|
755
|
+
if (/^[A-Za-z_][A-Za-z0-9_]*(?:[.@-]|->|::)$/.test(content)) return true;
|
|
756
756
|
return IDENTIFIER.test(content) && !MATH_SUFFIX.test(run);
|
|
757
757
|
}
|
|
758
758
|
var FUNCTION_NAMES = /* @__PURE__ */ new Set([
|
|
@@ -1157,7 +1157,7 @@ var Tokenizer = class {
|
|
|
1157
1157
|
if (close >= span) this.provisionalFrom = Math.min(this.provisionalFrom, open);
|
|
1158
1158
|
}
|
|
1159
1159
|
}
|
|
1160
|
-
for (const pad of ["`", "``", "```", "~~~"]) {
|
|
1160
|
+
for (const pad of ["`", "``", "```", "~~~", "$"]) {
|
|
1161
1161
|
const alt = pairDisplayMath(text + pad);
|
|
1162
1162
|
for (const [open, close] of this.mathPairs) {
|
|
1163
1163
|
if (alt.get(open) !== close) this.provisionalFrom = Math.min(this.provisionalFrom, open);
|
|
@@ -1189,19 +1189,6 @@ var Tokenizer = class {
|
|
|
1189
1189
|
provisionalFrom = Number.POSITIVE_INFINITY;
|
|
1190
1190
|
/** Streaming: the text ends in a lone CR whose LF has not arrived yet. */
|
|
1191
1191
|
pendingCR = false;
|
|
1192
|
-
/**
|
|
1193
|
-
* Streaming: an open last line that begins with `{` is undecided — each new
|
|
1194
|
-
* byte can balance or unbalance its braces and flip the whole line between
|
|
1195
|
-
* prose and a JSON island — so it is provisional until it ends (G5).
|
|
1196
|
-
* (A lone HTML tag on that line is held by {@link holdUndecidedTail}.)
|
|
1197
|
-
*/
|
|
1198
|
-
markOpenJsonTail() {
|
|
1199
|
-
const last = this.lineStarts.length - 1;
|
|
1200
|
-
if (!this.isOpenTail(last)) return;
|
|
1201
|
-
if (this.lineText(last).trim().startsWith("{")) {
|
|
1202
|
-
this.provisionalFrom = Math.min(this.provisionalFrom, this.lineStarts[last]);
|
|
1203
|
-
}
|
|
1204
|
-
}
|
|
1205
1192
|
/**
|
|
1206
1193
|
* `text.indexOf(needle, from)` in O(log k): the first query for a needle
|
|
1207
1194
|
* indexes all of its occurrences once, so repeated searches for a closer
|
|
@@ -1236,7 +1223,7 @@ var Tokenizer = class {
|
|
|
1236
1223
|
const rest = this.n - pe;
|
|
1237
1224
|
if (rest === 0) return true;
|
|
1238
1225
|
const tail = this.text.slice(pe);
|
|
1239
|
-
return /^(?:\r\n|\r|\n)[ \t]*$/.test(tail);
|
|
1226
|
+
return /^(?:\r\n|\r|\n)[ \t\r]*$/.test(tail);
|
|
1240
1227
|
}
|
|
1241
1228
|
/**
|
|
1242
1229
|
* Streaming: an open block that may still turn back into prose — a `$$`
|
|
@@ -1245,7 +1232,9 @@ var Tokenizer = class {
|
|
|
1245
1232
|
* or any opener that is itself still arriving on the open last line.
|
|
1246
1233
|
*/
|
|
1247
1234
|
mayDissolve(block) {
|
|
1248
|
-
if (!this.streaming
|
|
1235
|
+
if (!this.streaming) return false;
|
|
1236
|
+
if (block.start >= this.provisionalFrom) return true;
|
|
1237
|
+
if (block.complete) return false;
|
|
1249
1238
|
if (block.type === "math_block" || block.type === "json") return true;
|
|
1250
1239
|
return this.isOpenTail(this.lineOf(block.start));
|
|
1251
1240
|
}
|
|
@@ -1284,7 +1273,6 @@ var Tokenizer = class {
|
|
|
1284
1273
|
return this.text.slice(this.lineStarts[li], this.contentEnds[li]);
|
|
1285
1274
|
}
|
|
1286
1275
|
run() {
|
|
1287
|
-
if (this.streaming) this.markOpenJsonTail();
|
|
1288
1276
|
let pos = 0;
|
|
1289
1277
|
while (pos < this.n) {
|
|
1290
1278
|
const li = this.lineOf(pos);
|
|
@@ -1522,7 +1510,7 @@ var Tokenizer = class {
|
|
|
1522
1510
|
return { type, start, end, complete, meta };
|
|
1523
1511
|
}
|
|
1524
1512
|
frontMatter(li, t) {
|
|
1525
|
-
const fence = this.lineText(li);
|
|
1513
|
+
const fence = this.lineText(li).replace(/^\uFEFF/, "");
|
|
1526
1514
|
if (fence !== "---" && fence !== "+++" || t !== fence) return null;
|
|
1527
1515
|
const toml = fence === "+++";
|
|
1528
1516
|
let sawContent = false;
|
|
@@ -1533,9 +1521,13 @@ var Tokenizer = class {
|
|
|
1533
1521
|
}
|
|
1534
1522
|
if (!NOT_WHITESPACE.test(line)) continue;
|
|
1535
1523
|
const shaped = toml ? /^\s*(?:[A-Za-z0-9_."-]+\s*=|\[|#)/.test(line) : /^(?:[A-Za-z0-9_"'-][^:]*:(?:\s|$)|\s+\S|-\s|#)/.test(line);
|
|
1536
|
-
if (!shaped)
|
|
1524
|
+
if (!shaped) {
|
|
1525
|
+
if (this.isOpenTail(k)) break;
|
|
1526
|
+
return null;
|
|
1527
|
+
}
|
|
1537
1528
|
sawContent = true;
|
|
1538
1529
|
}
|
|
1530
|
+
if (this.streaming) return this.island("front_matter", 0, this.n, false, { format: toml ? "toml" : "yaml" });
|
|
1539
1531
|
return null;
|
|
1540
1532
|
}
|
|
1541
1533
|
/**
|
|
@@ -1936,7 +1928,7 @@ var Tokenizer = class {
|
|
|
1936
1928
|
const block = this.detectBlock(this.lineStarts[k], k, false);
|
|
1937
1929
|
if (block) {
|
|
1938
1930
|
breakLine = k;
|
|
1939
|
-
if (this.mayDissolve(block)
|
|
1931
|
+
if (this.mayDissolve(block)) {
|
|
1940
1932
|
this.undecidedBreaks.add(end);
|
|
1941
1933
|
}
|
|
1942
1934
|
break;
|