@ai-matrx/content-ir 0.18.0 → 0.18.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 +34 -0
- package/dist/index.cjs +30 -16
- 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 +26 -17
- package/dist/index.js.map +1 -1
- package/dist/source.cjs +30 -16
- package/dist/source.cjs.map +1 -1
- package/dist/source.d.cts +81 -13
- package/dist/source.d.ts +81 -13
- package/dist/source.js +26 -17
- package/dist/source.js.map +1 -1
- package/package.json +1 -1
package/dist/source.cjs
CHANGED
|
@@ -394,7 +394,7 @@ function scan(text) {
|
|
|
394
394
|
}
|
|
395
395
|
const count = starts.length;
|
|
396
396
|
const raw = (k) => text.slice(starts[k], ends[k]);
|
|
397
|
-
const out = { ranges: [], paragraphs: [], endsInFence: false, pendingPara: -1 };
|
|
397
|
+
const out = { ranges: [], fences: [], paragraphs: [], endsInFence: false, pendingPara: -1 };
|
|
398
398
|
const rawLines = { count, line: raw };
|
|
399
399
|
let segment = 0;
|
|
400
400
|
for (let k = 0; k < count; k++) {
|
|
@@ -403,6 +403,7 @@ function scan(text) {
|
|
|
403
403
|
prose(text, starts, ends, raw, segment, k, out);
|
|
404
404
|
const end = closeFence(rawLines, k, opener);
|
|
405
405
|
out.ranges.push({ start: starts[k], end: ends[end.line], kind: "fence" });
|
|
406
|
+
out.fences.push([k, end.line, end.closed]);
|
|
406
407
|
out.pendingPara = -1;
|
|
407
408
|
if (!end.closed && end.line === count - 1) out.endsInFence = true;
|
|
408
409
|
k = end.line;
|
|
@@ -468,6 +469,7 @@ function prose(text, starts, ends, raw, from, to, out) {
|
|
|
468
469
|
};
|
|
469
470
|
const end = closeFence(src, k, opener);
|
|
470
471
|
out.ranges.push({ start: starts[k], end: ends[end.line], kind: "fence" });
|
|
472
|
+
out.fences.push([k, end.line, end.closed]);
|
|
471
473
|
if (!end.closed && end.line === starts.length - 1) out.endsInFence = true;
|
|
472
474
|
k = end.line;
|
|
473
475
|
}
|
|
@@ -531,6 +533,18 @@ function findCodeRanges(text) {
|
|
|
531
533
|
for (const [from, to] of s.paragraphs) codeSpans(text, from, to, ranges);
|
|
532
534
|
return ranges.sort((a, b) => a.start - b.start);
|
|
533
535
|
}
|
|
536
|
+
function fenceLineKinds(text) {
|
|
537
|
+
const s = scan(text);
|
|
538
|
+
let count = 1;
|
|
539
|
+
for (let i = text.indexOf("\n"); i !== -1; i = text.indexOf("\n", i + 1)) count++;
|
|
540
|
+
const kinds = new Array(count).fill("prose");
|
|
541
|
+
for (const [open, last, closed] of s.fences) {
|
|
542
|
+
kinds[open] = "open";
|
|
543
|
+
for (let k = open + 1; k <= last; k++) kinds[k] = "body";
|
|
544
|
+
if (closed && last > open) kinds[last] = "close";
|
|
545
|
+
}
|
|
546
|
+
return kinds;
|
|
547
|
+
}
|
|
534
548
|
function pendingCodeSpanStart(text) {
|
|
535
549
|
const n = text.length;
|
|
536
550
|
if (n === 0 || /\n[ \t]*\n[ \t]*$/.test(text)) return -1;
|
|
@@ -829,25 +843,20 @@ var XmlContainerTracker = class {
|
|
|
829
843
|
inComment = false;
|
|
830
844
|
inCdata = false;
|
|
831
845
|
inlineTicks = 0;
|
|
832
|
-
|
|
846
|
+
/** The open fence, read by THE one closer (source/code-ranges.ts). */
|
|
847
|
+
fence = null;
|
|
833
848
|
consumeLine(line, startOffset = 0) {
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
return null;
|
|
843
|
-
}
|
|
844
|
-
if (char === this.fenceMarker.char && marker.length >= this.fenceMarker.ticks && suffix.trim() === "") {
|
|
845
|
-
this.fenceMarker = null;
|
|
846
|
-
}
|
|
849
|
+
if (this.fence) {
|
|
850
|
+
if (this.fence.feed(line)) this.fence = null;
|
|
851
|
+
return null;
|
|
852
|
+
}
|
|
853
|
+
if (!this.inComment && !this.inCdata && this.inlineTicks === 0) {
|
|
854
|
+
const opener = fenceOpenerOf(line);
|
|
855
|
+
if (opener) {
|
|
856
|
+
this.fence = new FenceReader(opener);
|
|
847
857
|
return null;
|
|
848
858
|
}
|
|
849
859
|
}
|
|
850
|
-
if (this.fenceMarker) return null;
|
|
851
860
|
for (let i = startOffset; i < line.length; i++) {
|
|
852
861
|
if (this.inlineTicks > 0) {
|
|
853
862
|
if (line[i] === "`") {
|
|
@@ -2337,9 +2346,11 @@ function mapRange(changes, start, end, unit = "utf16") {
|
|
|
2337
2346
|
return { start: newStart, end: newEnd, touched, collapsed: newEnd === newStart && end > start };
|
|
2338
2347
|
}
|
|
2339
2348
|
|
|
2349
|
+
exports.BacktickRuns = BacktickRuns;
|
|
2340
2350
|
exports.CALLOUT_NAMES = CALLOUT_NAMES;
|
|
2341
2351
|
exports.FENCE_OPENER_WHITESPACE = FENCE_OPENER_WHITESPACE;
|
|
2342
2352
|
exports.FENCE_WHITESPACE = FENCE_WHITESPACE;
|
|
2353
|
+
exports.FenceReader = FenceReader;
|
|
2343
2354
|
exports.NESTING_FENCE_LANGUAGES = NESTING_FENCE_LANGUAGES;
|
|
2344
2355
|
exports.SourceSpliceError = SourceSpliceError;
|
|
2345
2356
|
exports.XmlContainerTracker = XmlContainerTracker;
|
|
@@ -2348,7 +2359,10 @@ exports.blockEdit = blockEdit;
|
|
|
2348
2359
|
exports.blockRangeEdit = blockRangeEdit;
|
|
2349
2360
|
exports.buildCodePointIndex = buildCodePointIndex;
|
|
2350
2361
|
exports.classifyInnerFenceLine = classifyInnerFenceLine;
|
|
2362
|
+
exports.closeFence = closeFence;
|
|
2363
|
+
exports.fenceLineKinds = fenceLineKinds;
|
|
2351
2364
|
exports.fenceNestsInnerFences = fenceNestsInnerFences;
|
|
2365
|
+
exports.fenceOpenerOf = fenceOpenerOf;
|
|
2352
2366
|
exports.findCodeRanges = findCodeRanges;
|
|
2353
2367
|
exports.isMathPlaceholder = isMathPlaceholder;
|
|
2354
2368
|
exports.isSingleDollarMath = isSingleDollarMath;
|