@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.d.cts
CHANGED
|
@@ -101,6 +101,11 @@ interface SourceBlock extends SourceSpan {
|
|
|
101
101
|
/** Inline islands of a `prose` block, in document order. Empty otherwise. */
|
|
102
102
|
readonly inlines: readonly SourceIsland[];
|
|
103
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* Every callout spelling the renderer resolves (matrx-frontend
|
|
106
|
+
* components/markdown-core/syntax/callout-types.ts ALIASES — keep in step).
|
|
107
|
+
*/
|
|
108
|
+
declare const CALLOUT_NAMES: ReadonlySet<string>;
|
|
104
109
|
/**
|
|
105
110
|
* Cut `text` into blocks whose raw concatenation is exactly `text`.
|
|
106
111
|
* Never throws; unclosed constructs are islands with `complete: false`.
|
|
@@ -385,6 +390,24 @@ type InnerFenceLine =
|
|
|
385
390
|
declare const FENCE_WHITESPACE = " \t\n\r\f\v";
|
|
386
391
|
/** Strip {@link FENCE_WHITESPACE} (and nothing else) from both ends of a line. */
|
|
387
392
|
declare function trimFenceLine(line: string): string;
|
|
393
|
+
/**
|
|
394
|
+
* The whitespace around a fence OPENER and inside its info string. The
|
|
395
|
+
* renderer finds openers with JavaScript's `String#trim()` and splits the info
|
|
396
|
+
* string on `/\s/`; this set IS that definition, written out so the Python
|
|
397
|
+
* twin can match it exactly — ECMAScript WhiteSpace + LineTerminator. It
|
|
398
|
+
* differs from Python's `str.split()` on U+0085 and U+001C–U+001F (not JS
|
|
399
|
+
* whitespace) and U+FEFF (JS whitespace) — verify-RC-B3 residual R4′.
|
|
400
|
+
*/
|
|
401
|
+
declare const FENCE_OPENER_WHITESPACE = "\t\n\v\f\r \u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF";
|
|
402
|
+
/**
|
|
403
|
+
* Parse a backtick fence OPENER line the way the renderer does: trim the line,
|
|
404
|
+
* count the backtick run (3+), trim the rest, and take the first
|
|
405
|
+
* whitespace-separated word as the language. null when the line opens nothing.
|
|
406
|
+
*/
|
|
407
|
+
declare function parseFenceOpener(line: string): {
|
|
408
|
+
ticks: number;
|
|
409
|
+
lang: string;
|
|
410
|
+
} | null;
|
|
388
411
|
declare function classifyInnerFenceLine(trimmed: string, openTicks: number, nests: boolean, nestedDepth: number): InnerFenceLine;
|
|
389
412
|
|
|
390
413
|
/**
|
|
@@ -407,4 +430,4 @@ declare function looksLikeDisplayMath(inner: string): boolean;
|
|
|
407
430
|
/** Map of `$$` opener offset → closer offset for every pair the renderer shows as math. */
|
|
408
431
|
declare function pairDisplayMath(text: string): Map<number, number>;
|
|
409
432
|
|
|
410
|
-
export { type BlockIslandType, type CodePointIndex, type DisturbedIsland, FENCE_WHITESPACE, type InlineIslandType, type InnerFenceLine, type IslandMeta, type IslandType, type MapOptions, type MappedPosition, type MappedRange, NESTING_FENCE_LANGUAGES, type ReadXmlTag, type SourceBlock, type SourceBlockKind, type SourceChange, type SourceEdit, type SourceIsland, type SourceSpan, SourceSpliceError, type SourceSpliceErrorCode, type SpliceIntegrity, type SpliceOptions, type SpliceResult, type TokenizeOptions, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, fenceNestsInnerFences, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, mapPosition, mapRange, pairDisplayMath, readXmlTag, singleDollarMathEnd, spliceSave, splitsSurrogatePair, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine };
|
|
433
|
+
export { type BlockIslandType, CALLOUT_NAMES, type CodePointIndex, type DisturbedIsland, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, type InlineIslandType, type InnerFenceLine, type IslandMeta, type IslandType, type MapOptions, type MappedPosition, type MappedRange, NESTING_FENCE_LANGUAGES, type ReadXmlTag, type SourceBlock, type SourceBlockKind, type SourceChange, type SourceEdit, type SourceIsland, type SourceSpan, SourceSpliceError, type SourceSpliceErrorCode, type SpliceIntegrity, type SpliceOptions, type SpliceResult, type TokenizeOptions, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, fenceNestsInnerFences, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, mapPosition, mapRange, pairDisplayMath, parseFenceOpener, readXmlTag, singleDollarMathEnd, spliceSave, splitsSurrogatePair, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine };
|
package/dist/source.d.ts
CHANGED
|
@@ -101,6 +101,11 @@ interface SourceBlock extends SourceSpan {
|
|
|
101
101
|
/** Inline islands of a `prose` block, in document order. Empty otherwise. */
|
|
102
102
|
readonly inlines: readonly SourceIsland[];
|
|
103
103
|
}
|
|
104
|
+
/**
|
|
105
|
+
* Every callout spelling the renderer resolves (matrx-frontend
|
|
106
|
+
* components/markdown-core/syntax/callout-types.ts ALIASES — keep in step).
|
|
107
|
+
*/
|
|
108
|
+
declare const CALLOUT_NAMES: ReadonlySet<string>;
|
|
104
109
|
/**
|
|
105
110
|
* Cut `text` into blocks whose raw concatenation is exactly `text`.
|
|
106
111
|
* Never throws; unclosed constructs are islands with `complete: false`.
|
|
@@ -385,6 +390,24 @@ type InnerFenceLine =
|
|
|
385
390
|
declare const FENCE_WHITESPACE = " \t\n\r\f\v";
|
|
386
391
|
/** Strip {@link FENCE_WHITESPACE} (and nothing else) from both ends of a line. */
|
|
387
392
|
declare function trimFenceLine(line: string): string;
|
|
393
|
+
/**
|
|
394
|
+
* The whitespace around a fence OPENER and inside its info string. The
|
|
395
|
+
* renderer finds openers with JavaScript's `String#trim()` and splits the info
|
|
396
|
+
* string on `/\s/`; this set IS that definition, written out so the Python
|
|
397
|
+
* twin can match it exactly — ECMAScript WhiteSpace + LineTerminator. It
|
|
398
|
+
* differs from Python's `str.split()` on U+0085 and U+001C–U+001F (not JS
|
|
399
|
+
* whitespace) and U+FEFF (JS whitespace) — verify-RC-B3 residual R4′.
|
|
400
|
+
*/
|
|
401
|
+
declare const FENCE_OPENER_WHITESPACE = "\t\n\v\f\r \u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF";
|
|
402
|
+
/**
|
|
403
|
+
* Parse a backtick fence OPENER line the way the renderer does: trim the line,
|
|
404
|
+
* count the backtick run (3+), trim the rest, and take the first
|
|
405
|
+
* whitespace-separated word as the language. null when the line opens nothing.
|
|
406
|
+
*/
|
|
407
|
+
declare function parseFenceOpener(line: string): {
|
|
408
|
+
ticks: number;
|
|
409
|
+
lang: string;
|
|
410
|
+
} | null;
|
|
388
411
|
declare function classifyInnerFenceLine(trimmed: string, openTicks: number, nests: boolean, nestedDepth: number): InnerFenceLine;
|
|
389
412
|
|
|
390
413
|
/**
|
|
@@ -407,4 +430,4 @@ declare function looksLikeDisplayMath(inner: string): boolean;
|
|
|
407
430
|
/** Map of `$$` opener offset → closer offset for every pair the renderer shows as math. */
|
|
408
431
|
declare function pairDisplayMath(text: string): Map<number, number>;
|
|
409
432
|
|
|
410
|
-
export { type BlockIslandType, type CodePointIndex, type DisturbedIsland, FENCE_WHITESPACE, type InlineIslandType, type InnerFenceLine, type IslandMeta, type IslandType, type MapOptions, type MappedPosition, type MappedRange, NESTING_FENCE_LANGUAGES, type ReadXmlTag, type SourceBlock, type SourceBlockKind, type SourceChange, type SourceEdit, type SourceIsland, type SourceSpan, SourceSpliceError, type SourceSpliceErrorCode, type SpliceIntegrity, type SpliceOptions, type SpliceResult, type TokenizeOptions, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, fenceNestsInnerFences, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, mapPosition, mapRange, pairDisplayMath, readXmlTag, singleDollarMathEnd, spliceSave, splitsSurrogatePair, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine };
|
|
433
|
+
export { type BlockIslandType, CALLOUT_NAMES, type CodePointIndex, type DisturbedIsland, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, type InlineIslandType, type InnerFenceLine, type IslandMeta, type IslandType, type MapOptions, type MappedPosition, type MappedRange, NESTING_FENCE_LANGUAGES, type ReadXmlTag, type SourceBlock, type SourceBlockKind, type SourceChange, type SourceEdit, type SourceIsland, type SourceSpan, SourceSpliceError, type SourceSpliceErrorCode, type SpliceIntegrity, type SpliceOptions, type SpliceResult, type TokenizeOptions, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, fenceNestsInnerFences, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, mapPosition, mapRange, pairDisplayMath, parseFenceOpener, readXmlTag, singleDollarMathEnd, spliceSave, splitsSurrogatePair, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine };
|
package/dist/source.js
CHANGED
|
@@ -220,6 +220,24 @@ function trimFenceLine(line) {
|
|
|
220
220
|
while (end > start && isFenceWhitespace(line[end - 1])) end--;
|
|
221
221
|
return start === 0 && end === line.length ? line : line.slice(start, end);
|
|
222
222
|
}
|
|
223
|
+
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";
|
|
224
|
+
function isOpenerWhitespace(ch) {
|
|
225
|
+
return ch !== void 0 && ch !== "" && FENCE_OPENER_WHITESPACE.includes(ch);
|
|
226
|
+
}
|
|
227
|
+
function parseFenceOpener(line) {
|
|
228
|
+
let start = 0;
|
|
229
|
+
let end = line.length;
|
|
230
|
+
while (start < end && isOpenerWhitespace(line[start])) start++;
|
|
231
|
+
while (end > start && isOpenerWhitespace(line[end - 1])) end--;
|
|
232
|
+
let ticks = 0;
|
|
233
|
+
while (start + ticks < end && line[start + ticks] === "`") ticks++;
|
|
234
|
+
if (ticks < 3) return null;
|
|
235
|
+
let infoStart = start + ticks;
|
|
236
|
+
while (infoStart < end && isOpenerWhitespace(line[infoStart])) infoStart++;
|
|
237
|
+
let langEnd = infoStart;
|
|
238
|
+
while (langEnd < end && !isOpenerWhitespace(line[langEnd])) langEnd++;
|
|
239
|
+
return { ticks, lang: line.slice(infoStart, langEnd) };
|
|
240
|
+
}
|
|
223
241
|
function classifyInnerFenceLine(trimmed, openTicks, nests, nestedDepth) {
|
|
224
242
|
let ticks = 0;
|
|
225
243
|
while (ticks < trimmed.length && trimmed[ticks] === "`") ticks++;
|
|
@@ -512,6 +530,37 @@ var NOT_WHITESPACE = /\S/;
|
|
|
512
530
|
var DIRECTIVE_OPEN = /^(:{2,})([A-Za-z][\w-]*)/;
|
|
513
531
|
var MKDOCS_OPEN = /^(!!!|\?\?\?\+?)[ \t]+([A-Za-z][\w-]*)/;
|
|
514
532
|
var CALLOUT_OPEN = /^>[ \t]*\[!([A-Za-z][\w-]*)\]([+-])?/;
|
|
533
|
+
var CALLOUT_NAMES = /* @__PURE__ */ new Set([
|
|
534
|
+
"note",
|
|
535
|
+
"seealso",
|
|
536
|
+
"example",
|
|
537
|
+
"tip",
|
|
538
|
+
"hint",
|
|
539
|
+
"important",
|
|
540
|
+
"warning",
|
|
541
|
+
"warn",
|
|
542
|
+
"attention",
|
|
543
|
+
"caution",
|
|
544
|
+
"danger",
|
|
545
|
+
"error",
|
|
546
|
+
"failure",
|
|
547
|
+
"fail",
|
|
548
|
+
"missing",
|
|
549
|
+
"bug",
|
|
550
|
+
"info",
|
|
551
|
+
"abstract",
|
|
552
|
+
"summary",
|
|
553
|
+
"tldr",
|
|
554
|
+
"todo",
|
|
555
|
+
"success",
|
|
556
|
+
"check",
|
|
557
|
+
"done",
|
|
558
|
+
"question",
|
|
559
|
+
"help",
|
|
560
|
+
"faq",
|
|
561
|
+
"quote",
|
|
562
|
+
"cite"
|
|
563
|
+
]);
|
|
515
564
|
var FOOTNOTE_DEF = /^\[\^([^\]\s]+)\]:/;
|
|
516
565
|
function countStructuralBraces(source) {
|
|
517
566
|
let opens = 0;
|
|
@@ -905,7 +954,7 @@ var Tokenizer = class {
|
|
|
905
954
|
/** A blockquote whose first line is `> [!TYPE]…` — every following `>` line belongs to it. */
|
|
906
955
|
callout(p, li, t) {
|
|
907
956
|
const open = CALLOUT_OPEN.exec(t);
|
|
908
|
-
if (!open) return null;
|
|
957
|
+
if (!open || !CALLOUT_NAMES.has(open[1].toLowerCase())) return null;
|
|
909
958
|
let last = li;
|
|
910
959
|
for (let k = li + 1; k < this.lineCount; k++) {
|
|
911
960
|
if (!/^ {0,3}>/.test(this.lineText(k))) break;
|
|
@@ -949,8 +998,7 @@ var Tokenizer = class {
|
|
|
949
998
|
*/
|
|
950
999
|
backtickFence(p, li, t) {
|
|
951
1000
|
const openTicks = backtickRunLength(t, 0);
|
|
952
|
-
const
|
|
953
|
-
const lang = info.split(/\s/)[0] ?? "";
|
|
1001
|
+
const lang = parseFenceOpener(t)?.lang ?? "";
|
|
954
1002
|
const isJson = lang === "json";
|
|
955
1003
|
const normalized = normalizeFenceLanguage(lang);
|
|
956
1004
|
const meta = { fence: "`", ticks: openTicks, lang };
|
|
@@ -1080,6 +1128,7 @@ var Tokenizer = class {
|
|
|
1080
1128
|
const endLine = this.lineOf(close);
|
|
1081
1129
|
const endCe = this.contentEnds[endLine];
|
|
1082
1130
|
if (endLine !== li && !this.isBlank(end, endCe)) return null;
|
|
1131
|
+
if (this.isOpenTail(endLine)) return this.island("math_block", p, this.n, false, { delimiter: "$$" });
|
|
1083
1132
|
return this.island("math_block", p, end, true, { delimiter: "$$" });
|
|
1084
1133
|
}
|
|
1085
1134
|
/** `<artifact …>`, `<decision …>`, … at the start of a line. */
|
|
@@ -1409,7 +1458,7 @@ var Tokenizer = class {
|
|
|
1409
1458
|
continue;
|
|
1410
1459
|
}
|
|
1411
1460
|
const end = singleDollarMathEnd(text, i, pe);
|
|
1412
|
-
if (end > 0) {
|
|
1461
|
+
if (end > 0 && !(this.streaming && end === this.n)) {
|
|
1413
1462
|
inlines.push(this.island("math_inline", i, end, true, { delimiter: "$" }));
|
|
1414
1463
|
i = end;
|
|
1415
1464
|
continue;
|
|
@@ -1819,11 +1868,17 @@ function spliceSave(original, edits, options = {}) {
|
|
|
1819
1868
|
else newIslandsByStart.set(island.start, [island.raw]);
|
|
1820
1869
|
}
|
|
1821
1870
|
const disturbed = [];
|
|
1871
|
+
const carried = (island) => sorted.some((edit) => !edit.island && island.start >= edit.start && island.end <= edit.end);
|
|
1872
|
+
const changedInside = [];
|
|
1822
1873
|
for (const island of islands) {
|
|
1823
1874
|
if (replacedIslands.has(`${island.start}:${island.end}`)) continue;
|
|
1824
1875
|
const mappedStart = mapPosition(changes, island.start, { assoc: 1 }).pos;
|
|
1825
1876
|
const candidates = newIslandsByStart.get(mappedStart);
|
|
1826
1877
|
if (!candidates || !candidates.includes(island.raw)) {
|
|
1878
|
+
if (carried(island)) {
|
|
1879
|
+
changedInside.push(island);
|
|
1880
|
+
continue;
|
|
1881
|
+
}
|
|
1827
1882
|
disturbed.push({
|
|
1828
1883
|
islandType: island.islandType,
|
|
1829
1884
|
inline: island.inline,
|
|
@@ -1833,6 +1888,14 @@ function spliceSave(original, edits, options = {}) {
|
|
|
1833
1888
|
});
|
|
1834
1889
|
}
|
|
1835
1890
|
}
|
|
1891
|
+
if (changedInside.length > 0) {
|
|
1892
|
+
const first = changedInside[0];
|
|
1893
|
+
const name = first.meta.tag ?? first.meta.name ?? first.meta.lang ?? "";
|
|
1894
|
+
throw new SourceSpliceError(
|
|
1895
|
+
"island_edit",
|
|
1896
|
+
`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()`
|
|
1897
|
+
);
|
|
1898
|
+
}
|
|
1836
1899
|
const integrity = {
|
|
1837
1900
|
ok: bytesOutsideEditsIdentical && disturbed.length === 0,
|
|
1838
1901
|
bytesOutsideEditsIdentical,
|
|
@@ -1884,6 +1947,6 @@ function mapRange(changes, start, end, unit = "utf16") {
|
|
|
1884
1947
|
return { start: newStart, end: newEnd, touched, collapsed: newEnd === newStart && end > start };
|
|
1885
1948
|
}
|
|
1886
1949
|
|
|
1887
|
-
export { FENCE_WHITESPACE, NESTING_FENCE_LANGUAGES, SourceSpliceError, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, fenceNestsInnerFences, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, mapPosition, mapRange, pairDisplayMath, readXmlTag, singleDollarMathEnd, spliceSave, splitsSurrogatePair, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine };
|
|
1950
|
+
export { CALLOUT_NAMES, FENCE_OPENER_WHITESPACE, FENCE_WHITESPACE, NESTING_FENCE_LANGUAGES, SourceSpliceError, XmlContainerTracker, blockAt, blockEdit, blockRangeEdit, buildCodePointIndex, classifyInnerFenceLine, fenceNestsInnerFences, isSingleDollarMath, islandEdit, joinSource, listIslands, looksLikeDisplayMath, mapPosition, mapRange, pairDisplayMath, parseFenceOpener, readXmlTag, singleDollarMathEnd, spliceSave, splitsSurrogatePair, toCodePointOffset, toUtf16Offset, tokenizeSource, trimFenceLine };
|
|
1888
1951
|
//# sourceMappingURL=source.js.map
|
|
1889
1952
|
//# sourceMappingURL=source.js.map
|