@ai-matrx/content-ir 0.19.1 → 0.19.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 +32 -3
- package/dist/index.cjs +81 -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 +71 -1
- package/dist/index.js.map +1 -1
- package/dist/source.cjs +81 -0
- package/dist/source.cjs.map +1 -1
- package/dist/source.d.cts +43 -1
- package/dist/source.d.ts +43 -1
- package/dist/source.js +71 -1
- package/dist/source.js.map +1 -1
- package/package.json +1 -1
package/dist/source.cjs
CHANGED
|
@@ -2559,6 +2559,76 @@ function mapRange(changes, start, end, unit = "utf16") {
|
|
|
2559
2559
|
return { start: newStart, end: newEnd, touched, collapsed: newEnd === newStart && end > start };
|
|
2560
2560
|
}
|
|
2561
2561
|
|
|
2562
|
+
// source/gfm-table.ts
|
|
2563
|
+
function splitRowSegments(line) {
|
|
2564
|
+
const segments = [];
|
|
2565
|
+
let start = 0;
|
|
2566
|
+
for (let i = 0; i < line.length; i += 1) {
|
|
2567
|
+
const ch = line[i];
|
|
2568
|
+
if (ch === "\\") {
|
|
2569
|
+
i += 1;
|
|
2570
|
+
continue;
|
|
2571
|
+
}
|
|
2572
|
+
if (ch === "|") {
|
|
2573
|
+
segments.push(line.slice(start, i));
|
|
2574
|
+
start = i + 1;
|
|
2575
|
+
}
|
|
2576
|
+
}
|
|
2577
|
+
segments.push(line.slice(start));
|
|
2578
|
+
return segments;
|
|
2579
|
+
}
|
|
2580
|
+
function rowCells(line) {
|
|
2581
|
+
const cells = splitRowSegments(line).map((cell) => cell.trim());
|
|
2582
|
+
if (cells.length > 1 && cells[0] === "") cells.shift();
|
|
2583
|
+
if (cells.length > 1 && cells[cells.length - 1] === "") cells.pop();
|
|
2584
|
+
else if (cells.length === 1 && cells[0] === "") cells.pop();
|
|
2585
|
+
return cells;
|
|
2586
|
+
}
|
|
2587
|
+
function unescapeCellPipes(cell) {
|
|
2588
|
+
return cell.replace(/\\\|/g, "|");
|
|
2589
|
+
}
|
|
2590
|
+
var BLOCK_START = /^(?:[-+*](?:\s|$)|\d{1,9}[.)](?:\s|$)|>|#{1,6}(?:\s|$)|```|~~~|(?:-\s*){3,}$|(?:\*\s*){3,}$|(?:_\s*){3,}$)/;
|
|
2591
|
+
var DELIMITER_CELL = /^:?-+:?$/;
|
|
2592
|
+
function isGfmDelimiterRow(line) {
|
|
2593
|
+
const trimmed = line.trim();
|
|
2594
|
+
if (!trimmed.includes("|")) return false;
|
|
2595
|
+
const cells = rowCells(trimmed);
|
|
2596
|
+
return cells.length > 0 && cells.every((cell) => DELIMITER_CELL.test(cell));
|
|
2597
|
+
}
|
|
2598
|
+
function isPipeLedRow(line) {
|
|
2599
|
+
const trimmed = line.trim();
|
|
2600
|
+
return trimmed.startsWith("|") && trimmed.includes("|", 1);
|
|
2601
|
+
}
|
|
2602
|
+
function startsPipelessTable(header, delimiter) {
|
|
2603
|
+
const head = header.trim();
|
|
2604
|
+
if (!head || head.startsWith("|") || BLOCK_START.test(head)) return false;
|
|
2605
|
+
if (splitRowSegments(head).length < 2) return false;
|
|
2606
|
+
if (delimiter === void 0 || !isGfmDelimiterRow(delimiter)) return false;
|
|
2607
|
+
return rowCells(head).length === rowCells(delimiter.trim()).length;
|
|
2608
|
+
}
|
|
2609
|
+
function continuesTable(line) {
|
|
2610
|
+
const trimmed = line.trim();
|
|
2611
|
+
if (!trimmed) return false;
|
|
2612
|
+
if (trimmed.startsWith("|")) return trimmed.includes("|", 1);
|
|
2613
|
+
return splitRowSegments(trimmed).length > 1 && !BLOCK_START.test(trimmed);
|
|
2614
|
+
}
|
|
2615
|
+
function opensTable(lines, index) {
|
|
2616
|
+
const line = lines[index] ?? "";
|
|
2617
|
+
return isPipeLedRow(line) || startsPipelessTable(line, lines[index + 1]);
|
|
2618
|
+
}
|
|
2619
|
+
function tableStartsAt(lines, index) {
|
|
2620
|
+
return opensTable(lines, index) && isGfmDelimiterRow(lines[index + 1] ?? "");
|
|
2621
|
+
}
|
|
2622
|
+
function findTableStart(lines, from = 0) {
|
|
2623
|
+
for (let i = Math.max(0, from); i < lines.length; i += 1) if (opensTable(lines, i)) return i;
|
|
2624
|
+
return -1;
|
|
2625
|
+
}
|
|
2626
|
+
function findTableEnd(lines, start) {
|
|
2627
|
+
let end = Math.min(lines.length, start + 2);
|
|
2628
|
+
while (end < lines.length && continuesTable(lines[end] ?? "")) end += 1;
|
|
2629
|
+
return end;
|
|
2630
|
+
}
|
|
2631
|
+
|
|
2562
2632
|
exports.AFTER_WINDOW = AFTER_WINDOW;
|
|
2563
2633
|
exports.BacktickRuns = BacktickRuns;
|
|
2564
2634
|
exports.CALLOUT_NAMES = CALLOUT_NAMES;
|
|
@@ -2575,13 +2645,18 @@ exports.buildCodePointIndex = buildCodePointIndex;
|
|
|
2575
2645
|
exports.classifyInnerFenceLine = classifyInnerFenceLine;
|
|
2576
2646
|
exports.closeFence = closeFence;
|
|
2577
2647
|
exports.codeSpanText = codeSpanText;
|
|
2648
|
+
exports.continuesTable = continuesTable;
|
|
2578
2649
|
exports.fenceLineKinds = fenceLineKinds;
|
|
2579
2650
|
exports.fenceNestsInnerFences = fenceNestsInnerFences;
|
|
2580
2651
|
exports.fenceOpenerOf = fenceOpenerOf;
|
|
2581
2652
|
exports.fenceParts = fenceParts;
|
|
2582
2653
|
exports.findCodeRanges = findCodeRanges;
|
|
2654
|
+
exports.findTableEnd = findTableEnd;
|
|
2655
|
+
exports.findTableStart = findTableStart;
|
|
2583
2656
|
exports.isEscapedBracketMath = isEscapedBracketMath;
|
|
2657
|
+
exports.isGfmDelimiterRow = isGfmDelimiterRow;
|
|
2584
2658
|
exports.isMathPlaceholder = isMathPlaceholder;
|
|
2659
|
+
exports.isPipeLedRow = isPipeLedRow;
|
|
2585
2660
|
exports.isSingleDollarMath = isSingleDollarMath;
|
|
2586
2661
|
exports.islandEdit = islandEdit;
|
|
2587
2662
|
exports.joinSource = joinSource;
|
|
@@ -2591,17 +2666,23 @@ exports.looksLikeOpenInlineMath = looksLikeOpenInlineMath;
|
|
|
2591
2666
|
exports.mapCodeRanges = mapCodeRanges;
|
|
2592
2667
|
exports.mapPosition = mapPosition;
|
|
2593
2668
|
exports.mapRange = mapRange;
|
|
2669
|
+
exports.opensTable = opensTable;
|
|
2594
2670
|
exports.pairDisplayMath = pairDisplayMath;
|
|
2595
2671
|
exports.parseFenceOpener = parseFenceOpener;
|
|
2596
2672
|
exports.pendingDisplayMathOpener = pendingDisplayMathOpener;
|
|
2597
2673
|
exports.readXmlTag = readXmlTag;
|
|
2674
|
+
exports.rowCells = rowCells;
|
|
2598
2675
|
exports.singleDollarAfter = singleDollarAfter;
|
|
2599
2676
|
exports.singleDollarMathEnd = singleDollarMathEnd;
|
|
2600
2677
|
exports.spliceSave = spliceSave;
|
|
2678
|
+
exports.splitRowSegments = splitRowSegments;
|
|
2601
2679
|
exports.splitsSurrogatePair = splitsSurrogatePair;
|
|
2680
|
+
exports.startsPipelessTable = startsPipelessTable;
|
|
2681
|
+
exports.tableStartsAt = tableStartsAt;
|
|
2602
2682
|
exports.toCodePointOffset = toCodePointOffset;
|
|
2603
2683
|
exports.toUtf16Offset = toUtf16Offset;
|
|
2604
2684
|
exports.tokenizeSource = tokenizeSource;
|
|
2605
2685
|
exports.trimFenceLine = trimFenceLine;
|
|
2686
|
+
exports.unescapeCellPipes = unescapeCellPipes;
|
|
2606
2687
|
//# sourceMappingURL=source.cjs.map
|
|
2607
2688
|
//# sourceMappingURL=source.cjs.map
|