@ai-matrx/content-ir 0.18.1 → 0.18.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 +10 -0
- package/dist/index.cjs +30 -0
- 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 +28 -1
- package/dist/index.js.map +1 -1
- package/dist/source.cjs +30 -0
- package/dist/source.cjs.map +1 -1
- package/dist/source.d.cts +19 -1
- package/dist/source.d.ts +19 -1
- package/dist/source.js +28 -1
- package/dist/source.js.map +1 -1
- package/package.json +1 -1
package/dist/source.cjs
CHANGED
|
@@ -533,6 +533,33 @@ function findCodeRanges(text) {
|
|
|
533
533
|
for (const [from, to] of s.paragraphs) codeSpans(text, from, to, ranges);
|
|
534
534
|
return ranges.sort((a, b) => a.start - b.start);
|
|
535
535
|
}
|
|
536
|
+
function mapCodeRanges(text, fn) {
|
|
537
|
+
let out = "";
|
|
538
|
+
let at = 0;
|
|
539
|
+
for (const r of findCodeRanges(text)) {
|
|
540
|
+
if (r.start < at) continue;
|
|
541
|
+
out += text.slice(at, r.start) + fn(r, text.slice(r.start, r.end));
|
|
542
|
+
at = r.end;
|
|
543
|
+
}
|
|
544
|
+
return out + text.slice(at);
|
|
545
|
+
}
|
|
546
|
+
function codeSpanText(raw) {
|
|
547
|
+
const ticks = backtickRunLength(raw, 0);
|
|
548
|
+
const inner = raw.slice(ticks, raw.length - ticks);
|
|
549
|
+
return inner.length >= 2 && inner.startsWith(" ") && inner.endsWith(" ") && inner.trim() !== "" ? inner.slice(1, -1) : inner;
|
|
550
|
+
}
|
|
551
|
+
function fenceParts(raw) {
|
|
552
|
+
const lines = raw.split("\n").map((l) => l.endsWith("\r") ? l.slice(0, -1) : l);
|
|
553
|
+
const { offset } = quotePrefix(lines[0] ?? "");
|
|
554
|
+
const opener = fenceOpenerOf((lines[0] ?? "").slice(offset).replace(/^ *(?:[-*+]|\d{1,9}[.)])(?= |\t|$) ?/, ""));
|
|
555
|
+
if (!opener) return null;
|
|
556
|
+
const rest = lines.slice(1);
|
|
557
|
+
const closed = rest.length > 0 && new FenceReader(opener, { nesting: false }).feed(rest[rest.length - 1]);
|
|
558
|
+
if (!closed) return { opener, body: rest.join("\n"), closed };
|
|
559
|
+
const last = rest[rest.length - 1];
|
|
560
|
+
const before = trimFenceLine(last).startsWith("```") ? "" : last.slice(0, last.indexOf("```"));
|
|
561
|
+
return { opener, body: [...rest.slice(0, -1), ...before.trim() ? [before] : []].join("\n"), closed };
|
|
562
|
+
}
|
|
536
563
|
function fenceLineKinds(text) {
|
|
537
564
|
const s = scan(text);
|
|
538
565
|
let count = 1;
|
|
@@ -2360,9 +2387,11 @@ exports.blockRangeEdit = blockRangeEdit;
|
|
|
2360
2387
|
exports.buildCodePointIndex = buildCodePointIndex;
|
|
2361
2388
|
exports.classifyInnerFenceLine = classifyInnerFenceLine;
|
|
2362
2389
|
exports.closeFence = closeFence;
|
|
2390
|
+
exports.codeSpanText = codeSpanText;
|
|
2363
2391
|
exports.fenceLineKinds = fenceLineKinds;
|
|
2364
2392
|
exports.fenceNestsInnerFences = fenceNestsInnerFences;
|
|
2365
2393
|
exports.fenceOpenerOf = fenceOpenerOf;
|
|
2394
|
+
exports.fenceParts = fenceParts;
|
|
2366
2395
|
exports.findCodeRanges = findCodeRanges;
|
|
2367
2396
|
exports.isMathPlaceholder = isMathPlaceholder;
|
|
2368
2397
|
exports.isSingleDollarMath = isSingleDollarMath;
|
|
@@ -2371,6 +2400,7 @@ exports.joinSource = joinSource;
|
|
|
2371
2400
|
exports.listIslands = listIslands;
|
|
2372
2401
|
exports.looksLikeDisplayMath = looksLikeDisplayMath;
|
|
2373
2402
|
exports.looksLikeOpenInlineMath = looksLikeOpenInlineMath;
|
|
2403
|
+
exports.mapCodeRanges = mapCodeRanges;
|
|
2374
2404
|
exports.mapPosition = mapPosition;
|
|
2375
2405
|
exports.mapRange = mapRange;
|
|
2376
2406
|
exports.pairDisplayMath = pairDisplayMath;
|