@ai-matrx/content-ir 0.19.5 → 0.19.7
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 +28 -6
- 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 +27 -7
- package/dist/index.js.map +1 -1
- package/dist/source.cjs +28 -6
- package/dist/source.cjs.map +1 -1
- package/dist/source.d.cts +13 -2
- package/dist/source.d.ts +13 -2
- package/dist/source.js +27 -7
- package/dist/source.js.map +1 -1
- package/package.json +1 -1
package/dist/source.cjs
CHANGED
|
@@ -234,6 +234,7 @@ function parseFenceOpener(line) {
|
|
|
234
234
|
let ticks = 0;
|
|
235
235
|
while (start + ticks < end && line[start + ticks] === "`") ticks++;
|
|
236
236
|
if (ticks < 3) return null;
|
|
237
|
+
if (line.slice(start + ticks, end).includes("`")) return null;
|
|
237
238
|
let infoStart = start + ticks;
|
|
238
239
|
while (infoStart < end && isOpenerWhitespace(line[infoStart])) infoStart++;
|
|
239
240
|
let langEnd = infoStart;
|
|
@@ -258,9 +259,9 @@ function classifyInnerFenceLine(trimmed, openTicks, nests, nestedDepth) {
|
|
|
258
259
|
function fenceOpenerOf(content) {
|
|
259
260
|
const t = content.trimStart();
|
|
260
261
|
if (t.startsWith("```")) {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
return { char: "`", ticks, lang:
|
|
262
|
+
const parsed = parseFenceOpener(t);
|
|
263
|
+
if (!parsed) return null;
|
|
264
|
+
return { char: "`", ticks: parsed.ticks, lang: parsed.lang };
|
|
264
265
|
}
|
|
265
266
|
if (content.length - t.length <= 3 && t.startsWith("~~~")) {
|
|
266
267
|
const open = /^(~{3,})(.*)$/.exec(t);
|
|
@@ -269,6 +270,9 @@ function fenceOpenerOf(content) {
|
|
|
269
270
|
}
|
|
270
271
|
return null;
|
|
271
272
|
}
|
|
273
|
+
function opensStrictFence(line) {
|
|
274
|
+
return fenceOpenerOf(line) !== null;
|
|
275
|
+
}
|
|
272
276
|
var FenceReader = class {
|
|
273
277
|
opener;
|
|
274
278
|
state = { inString: false, escaped: false };
|
|
@@ -555,6 +559,21 @@ function mapCodeRanges(text, fn) {
|
|
|
555
559
|
}
|
|
556
560
|
return out + text.slice(at);
|
|
557
561
|
}
|
|
562
|
+
function findInlineCodeSpans(text) {
|
|
563
|
+
const ranges = [];
|
|
564
|
+
codeSpans(text, 0, text.length, ranges);
|
|
565
|
+
return ranges.sort((a, b) => a.start - b.start);
|
|
566
|
+
}
|
|
567
|
+
function mapInlineCodeSpans(text, fn) {
|
|
568
|
+
let out = "";
|
|
569
|
+
let at = 0;
|
|
570
|
+
for (const r of findInlineCodeSpans(text)) {
|
|
571
|
+
if (r.start < at) continue;
|
|
572
|
+
out += text.slice(at, r.start) + fn(r, text.slice(r.start, r.end));
|
|
573
|
+
at = r.end;
|
|
574
|
+
}
|
|
575
|
+
return out + text.slice(at);
|
|
576
|
+
}
|
|
558
577
|
function codeSpanText(raw) {
|
|
559
578
|
const ticks = backtickRunLength(raw, 0);
|
|
560
579
|
const inner = raw.slice(ticks, raw.length - ticks);
|
|
@@ -2614,7 +2633,8 @@ function rowCells(line) {
|
|
|
2614
2633
|
function unescapeCellPipes(cell) {
|
|
2615
2634
|
return cell.replace(/\\\|/g, "|");
|
|
2616
2635
|
}
|
|
2617
|
-
var BLOCK_START = /^(?:[-+*](?:\s|$)|\d{1,9}[.)](?:\s|$)|>|#{1,6}(?:\s|$)
|
|
2636
|
+
var BLOCK_START = /^(?:[-+*](?:\s|$)|\d{1,9}[.)](?:\s|$)|>|#{1,6}(?:\s|$)|(?:-\s*){3,}$|(?:\*\s*){3,}$|(?:_\s*){3,}$)/;
|
|
2637
|
+
var startsBlock = (trimmed) => BLOCK_START.test(trimmed) || opensStrictFence(trimmed);
|
|
2618
2638
|
var DELIMITER_CELL = /^:?-+:?$/;
|
|
2619
2639
|
function isGfmDelimiterRow(line) {
|
|
2620
2640
|
const trimmed = line.trim();
|
|
@@ -2628,7 +2648,7 @@ function isPipeLedRow(line) {
|
|
|
2628
2648
|
}
|
|
2629
2649
|
function startsPipelessTable(header, delimiter) {
|
|
2630
2650
|
const head = header.trim();
|
|
2631
|
-
if (!head || head.startsWith("|") ||
|
|
2651
|
+
if (!head || head.startsWith("|") || startsBlock(head)) return false;
|
|
2632
2652
|
if (splitRowSegments(head).length < 2) return false;
|
|
2633
2653
|
if (delimiter === void 0 || !isGfmDelimiterRow(delimiter)) return false;
|
|
2634
2654
|
return rowCells(head).length === rowCells(delimiter.trim()).length;
|
|
@@ -2636,7 +2656,7 @@ function startsPipelessTable(header, delimiter) {
|
|
|
2636
2656
|
function continuesTable(line) {
|
|
2637
2657
|
const trimmed = line.trim();
|
|
2638
2658
|
if (!trimmed) return false;
|
|
2639
|
-
return trimmed.startsWith("|") || !
|
|
2659
|
+
return trimmed.startsWith("|") || !startsBlock(trimmed);
|
|
2640
2660
|
}
|
|
2641
2661
|
function opensTable(lines, index) {
|
|
2642
2662
|
const line = lines[index] ?? "";
|
|
@@ -2677,6 +2697,7 @@ exports.fenceNestsInnerFences = fenceNestsInnerFences;
|
|
|
2677
2697
|
exports.fenceOpenerOf = fenceOpenerOf;
|
|
2678
2698
|
exports.fenceParts = fenceParts;
|
|
2679
2699
|
exports.findCodeRanges = findCodeRanges;
|
|
2700
|
+
exports.findInlineCodeSpans = findInlineCodeSpans;
|
|
2680
2701
|
exports.findTableEnd = findTableEnd;
|
|
2681
2702
|
exports.findTableStart = findTableStart;
|
|
2682
2703
|
exports.isEscapedBracketMath = isEscapedBracketMath;
|
|
@@ -2690,6 +2711,7 @@ exports.listIslands = listIslands;
|
|
|
2690
2711
|
exports.looksLikeDisplayMath = looksLikeDisplayMath;
|
|
2691
2712
|
exports.looksLikeOpenInlineMath = looksLikeOpenInlineMath;
|
|
2692
2713
|
exports.mapCodeRanges = mapCodeRanges;
|
|
2714
|
+
exports.mapInlineCodeSpans = mapInlineCodeSpans;
|
|
2693
2715
|
exports.mapPosition = mapPosition;
|
|
2694
2716
|
exports.mapRange = mapRange;
|
|
2695
2717
|
exports.opensTable = opensTable;
|