@ai-matrx/content-ir 0.14.2 → 0.15.0
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 +44 -0
- package/dist/index.cjs +70 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +68 -5
- package/dist/index.js.map +1 -1
- package/dist/source.cjs +70 -4
- package/dist/source.cjs.map +1 -1
- package/dist/source.d.cts +24 -1
- package/dist/source.d.ts +24 -1
- package/dist/source.js +68 -5
- package/dist/source.js.map +1 -1
- package/package.json +1 -1
package/dist/source.cjs
CHANGED
|
@@ -222,6 +222,24 @@ function trimFenceLine(line) {
|
|
|
222
222
|
while (end > start && isFenceWhitespace(line[end - 1])) end--;
|
|
223
223
|
return start === 0 && end === line.length ? line : line.slice(start, end);
|
|
224
224
|
}
|
|
225
|
+
var FENCE_OPENER_WHITESPACE = " \n\v\f\r \xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF";
|
|
226
|
+
function isOpenerWhitespace(ch) {
|
|
227
|
+
return ch !== void 0 && ch !== "" && FENCE_OPENER_WHITESPACE.includes(ch);
|
|
228
|
+
}
|
|
229
|
+
function parseFenceOpener(line) {
|
|
230
|
+
let start = 0;
|
|
231
|
+
let end = line.length;
|
|
232
|
+
while (start < end && isOpenerWhitespace(line[start])) start++;
|
|
233
|
+
while (end > start && isOpenerWhitespace(line[end - 1])) end--;
|
|
234
|
+
let ticks = 0;
|
|
235
|
+
while (start + ticks < end && line[start + ticks] === "`") ticks++;
|
|
236
|
+
if (ticks < 3) return null;
|
|
237
|
+
let infoStart = start + ticks;
|
|
238
|
+
while (infoStart < end && isOpenerWhitespace(line[infoStart])) infoStart++;
|
|
239
|
+
let langEnd = infoStart;
|
|
240
|
+
while (langEnd < end && !isOpenerWhitespace(line[langEnd])) langEnd++;
|
|
241
|
+
return { ticks, lang: line.slice(infoStart, langEnd) };
|
|
242
|
+
}
|
|
225
243
|
function classifyInnerFenceLine(trimmed, openTicks, nests, nestedDepth) {
|
|
226
244
|
let ticks = 0;
|
|
227
245
|
while (ticks < trimmed.length && trimmed[ticks] === "`") ticks++;
|
|
@@ -514,6 +532,37 @@ var NOT_WHITESPACE = /\S/;
|
|
|
514
532
|
var DIRECTIVE_OPEN = /^(:{2,})([A-Za-z][\w-]*)/;
|
|
515
533
|
var MKDOCS_OPEN = /^(!!!|\?\?\?\+?)[ \t]+([A-Za-z][\w-]*)/;
|
|
516
534
|
var CALLOUT_OPEN = /^>[ \t]*\[!([A-Za-z][\w-]*)\]([+-])?/;
|
|
535
|
+
var CALLOUT_NAMES = /* @__PURE__ */ new Set([
|
|
536
|
+
"note",
|
|
537
|
+
"seealso",
|
|
538
|
+
"example",
|
|
539
|
+
"tip",
|
|
540
|
+
"hint",
|
|
541
|
+
"important",
|
|
542
|
+
"warning",
|
|
543
|
+
"warn",
|
|
544
|
+
"attention",
|
|
545
|
+
"caution",
|
|
546
|
+
"danger",
|
|
547
|
+
"error",
|
|
548
|
+
"failure",
|
|
549
|
+
"fail",
|
|
550
|
+
"missing",
|
|
551
|
+
"bug",
|
|
552
|
+
"info",
|
|
553
|
+
"abstract",
|
|
554
|
+
"summary",
|
|
555
|
+
"tldr",
|
|
556
|
+
"todo",
|
|
557
|
+
"success",
|
|
558
|
+
"check",
|
|
559
|
+
"done",
|
|
560
|
+
"question",
|
|
561
|
+
"help",
|
|
562
|
+
"faq",
|
|
563
|
+
"quote",
|
|
564
|
+
"cite"
|
|
565
|
+
]);
|
|
517
566
|
var FOOTNOTE_DEF = /^\[\^([^\]\s]+)\]:/;
|
|
518
567
|
function countStructuralBraces(source) {
|
|
519
568
|
let opens = 0;
|
|
@@ -907,7 +956,7 @@ var Tokenizer = class {
|
|
|
907
956
|
/** A blockquote whose first line is `> [!TYPE]…` — every following `>` line belongs to it. */
|
|
908
957
|
callout(p, li, t) {
|
|
909
958
|
const open = CALLOUT_OPEN.exec(t);
|
|
910
|
-
if (!open) return null;
|
|
959
|
+
if (!open || !CALLOUT_NAMES.has(open[1].toLowerCase())) return null;
|
|
911
960
|
let last = li;
|
|
912
961
|
for (let k = li + 1; k < this.lineCount; k++) {
|
|
913
962
|
if (!/^ {0,3}>/.test(this.lineText(k))) break;
|
|
@@ -951,8 +1000,7 @@ var Tokenizer = class {
|
|
|
951
1000
|
*/
|
|
952
1001
|
backtickFence(p, li, t) {
|
|
953
1002
|
const openTicks = backtickRunLength(t, 0);
|
|
954
|
-
const
|
|
955
|
-
const lang = info.split(/\s/)[0] ?? "";
|
|
1003
|
+
const lang = parseFenceOpener(t)?.lang ?? "";
|
|
956
1004
|
const isJson = lang === "json";
|
|
957
1005
|
const normalized = normalizeFenceLanguage(lang);
|
|
958
1006
|
const meta = { fence: "`", ticks: openTicks, lang };
|
|
@@ -1082,6 +1130,7 @@ var Tokenizer = class {
|
|
|
1082
1130
|
const endLine = this.lineOf(close);
|
|
1083
1131
|
const endCe = this.contentEnds[endLine];
|
|
1084
1132
|
if (endLine !== li && !this.isBlank(end, endCe)) return null;
|
|
1133
|
+
if (this.isOpenTail(endLine)) return this.island("math_block", p, this.n, false, { delimiter: "$$" });
|
|
1085
1134
|
return this.island("math_block", p, end, true, { delimiter: "$$" });
|
|
1086
1135
|
}
|
|
1087
1136
|
/** `<artifact …>`, `<decision …>`, … at the start of a line. */
|
|
@@ -1411,7 +1460,7 @@ var Tokenizer = class {
|
|
|
1411
1460
|
continue;
|
|
1412
1461
|
}
|
|
1413
1462
|
const end = singleDollarMathEnd(text, i, pe);
|
|
1414
|
-
if (end > 0) {
|
|
1463
|
+
if (end > 0 && !(this.streaming && end === this.n)) {
|
|
1415
1464
|
inlines.push(this.island("math_inline", i, end, true, { delimiter: "$" }));
|
|
1416
1465
|
i = end;
|
|
1417
1466
|
continue;
|
|
@@ -1821,11 +1870,17 @@ function spliceSave(original, edits, options = {}) {
|
|
|
1821
1870
|
else newIslandsByStart.set(island.start, [island.raw]);
|
|
1822
1871
|
}
|
|
1823
1872
|
const disturbed = [];
|
|
1873
|
+
const carried = (island) => sorted.some((edit) => !edit.island && island.start >= edit.start && island.end <= edit.end);
|
|
1874
|
+
const changedInside = [];
|
|
1824
1875
|
for (const island of islands) {
|
|
1825
1876
|
if (replacedIslands.has(`${island.start}:${island.end}`)) continue;
|
|
1826
1877
|
const mappedStart = mapPosition(changes, island.start, { assoc: 1 }).pos;
|
|
1827
1878
|
const candidates = newIslandsByStart.get(mappedStart);
|
|
1828
1879
|
if (!candidates || !candidates.includes(island.raw)) {
|
|
1880
|
+
if (carried(island)) {
|
|
1881
|
+
changedInside.push(island);
|
|
1882
|
+
continue;
|
|
1883
|
+
}
|
|
1829
1884
|
disturbed.push({
|
|
1830
1885
|
islandType: island.islandType,
|
|
1831
1886
|
inline: island.inline,
|
|
@@ -1835,6 +1890,14 @@ function spliceSave(original, edits, options = {}) {
|
|
|
1835
1890
|
});
|
|
1836
1891
|
}
|
|
1837
1892
|
}
|
|
1893
|
+
if (changedInside.length > 0) {
|
|
1894
|
+
const first = changedInside[0];
|
|
1895
|
+
const name = first.meta.tag ?? first.meta.name ?? first.meta.lang ?? "";
|
|
1896
|
+
throw new SourceSpliceError(
|
|
1897
|
+
"island_edit",
|
|
1898
|
+
`the edit changes the protected ${first.islandType}${name ? ` (${String(name)})` : ""} island at [${first.start}, ${first.end}) \u2014 its bytes survive only as ordinary text${changedInside.length > 1 ? ` (and ${changedInside.length - 1} more)` : ""}; islands change only through islandEdit()`
|
|
1899
|
+
);
|
|
1900
|
+
}
|
|
1838
1901
|
const integrity = {
|
|
1839
1902
|
ok: bytesOutsideEditsIdentical && disturbed.length === 0,
|
|
1840
1903
|
bytesOutsideEditsIdentical,
|
|
@@ -1886,6 +1949,8 @@ function mapRange(changes, start, end, unit = "utf16") {
|
|
|
1886
1949
|
return { start: newStart, end: newEnd, touched, collapsed: newEnd === newStart && end > start };
|
|
1887
1950
|
}
|
|
1888
1951
|
|
|
1952
|
+
exports.CALLOUT_NAMES = CALLOUT_NAMES;
|
|
1953
|
+
exports.FENCE_OPENER_WHITESPACE = FENCE_OPENER_WHITESPACE;
|
|
1889
1954
|
exports.FENCE_WHITESPACE = FENCE_WHITESPACE;
|
|
1890
1955
|
exports.NESTING_FENCE_LANGUAGES = NESTING_FENCE_LANGUAGES;
|
|
1891
1956
|
exports.SourceSpliceError = SourceSpliceError;
|
|
@@ -1904,6 +1969,7 @@ exports.looksLikeDisplayMath = looksLikeDisplayMath;
|
|
|
1904
1969
|
exports.mapPosition = mapPosition;
|
|
1905
1970
|
exports.mapRange = mapRange;
|
|
1906
1971
|
exports.pairDisplayMath = pairDisplayMath;
|
|
1972
|
+
exports.parseFenceOpener = parseFenceOpener;
|
|
1907
1973
|
exports.readXmlTag = readXmlTag;
|
|
1908
1974
|
exports.singleDollarMathEnd = singleDollarMathEnd;
|
|
1909
1975
|
exports.spliceSave = spliceSave;
|