@ai-matrx/content-ir 0.19.13 → 0.19.14
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 +6 -0
- package/dist/index.cjs +84 -2
- 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 +82 -3
- package/dist/index.js.map +1 -1
- package/dist/source.cjs +84 -2
- package/dist/source.cjs.map +1 -1
- package/dist/source.d.cts +28 -1
- package/dist/source.d.ts +28 -1
- package/dist/source.js +82 -3
- package/dist/source.js.map +1 -1
- package/package.json +1 -1
package/dist/source.cjs
CHANGED
|
@@ -2605,6 +2605,51 @@ function mapRange(changes, start, end, unit = "utf16") {
|
|
|
2605
2605
|
return { start: newStart, end: newEnd, touched, collapsed: newEnd === newStart && end > start };
|
|
2606
2606
|
}
|
|
2607
2607
|
|
|
2608
|
+
// source/link-references.ts
|
|
2609
|
+
function normalizeLinkLabel(label) {
|
|
2610
|
+
return label.trim().replace(/\s+/g, " ").toLowerCase();
|
|
2611
|
+
}
|
|
2612
|
+
var DEFINITION = /^ {0,3}\[((?:[^\]\\]|\\.){1,999})\]:[ \t]*(?:<([^<>\n]*)>|(\S+))(?:[ \t]+(?:"((?:[^"\\]|\\.)*)"|'((?:[^'\\]|\\.)*)'|\(((?:[^()\\]|\\.)*)\)))?[ \t]*$/;
|
|
2613
|
+
function collectLinkDefinitions(text) {
|
|
2614
|
+
const defs = /* @__PURE__ */ new Map();
|
|
2615
|
+
if (!text.includes("]:")) return defs;
|
|
2616
|
+
const lines = text.split("\n");
|
|
2617
|
+
const kinds = fenceLineKinds(text);
|
|
2618
|
+
lines.forEach((line, i) => {
|
|
2619
|
+
if (kinds[i] !== "prose") return;
|
|
2620
|
+
const m = DEFINITION.exec(line);
|
|
2621
|
+
if (!m) return;
|
|
2622
|
+
const label = m[1] ?? "";
|
|
2623
|
+
if (label.startsWith("^")) return;
|
|
2624
|
+
const key = normalizeLinkLabel(label);
|
|
2625
|
+
if (!key || defs.has(key)) return;
|
|
2626
|
+
defs.set(key, { url: m[2] ?? m[3] ?? "", title: m[4] ?? m[5] ?? m[6] ?? null });
|
|
2627
|
+
});
|
|
2628
|
+
return defs;
|
|
2629
|
+
}
|
|
2630
|
+
var REFERENCE = /(!?)\[((?:[^\]\\]|\\.)*)\](?:\[((?:[^\]\\]|\\.)*)\])?(?![(:[])/g;
|
|
2631
|
+
var escapeTitle = (title) => title.replace(/["\\]/g, "\\$&");
|
|
2632
|
+
function resolveReferenceLinks(fragment, defs) {
|
|
2633
|
+
if (defs.size === 0 || !fragment.includes("[")) return fragment;
|
|
2634
|
+
const PLACEHOLDER = "\uE011";
|
|
2635
|
+
const spans = [];
|
|
2636
|
+
const masked = mapInlineCodeSpans(fragment, (_range, raw) => {
|
|
2637
|
+
spans.push(raw);
|
|
2638
|
+
return `${PLACEHOLDER}${spans.length - 1}${PLACEHOLDER}`;
|
|
2639
|
+
});
|
|
2640
|
+
const resolved = masked.replace(REFERENCE, (whole, bang, text, ref, at) => {
|
|
2641
|
+
if (at > 0 && masked[at - 1] === "\\") return whole;
|
|
2642
|
+
if (text.startsWith("^")) return whole;
|
|
2643
|
+
const key = normalizeLinkLabel(ref === void 0 || ref === "" ? text : ref);
|
|
2644
|
+
const def = defs.get(key);
|
|
2645
|
+
if (!def) return whole;
|
|
2646
|
+
const title = def.title === null ? "" : ` "${escapeTitle(def.title)}"`;
|
|
2647
|
+
const url = /[\s()<>]/.test(def.url) ? `<${def.url}>` : def.url;
|
|
2648
|
+
return `${bang}[${text}](${url}${title})`;
|
|
2649
|
+
});
|
|
2650
|
+
return resolved.replace(new RegExp(`${PLACEHOLDER}(\\d+)${PLACEHOLDER}`, "g"), (_m, i) => spans[Number(i)] ?? "");
|
|
2651
|
+
}
|
|
2652
|
+
|
|
2608
2653
|
// source/gfm-table.ts
|
|
2609
2654
|
function splitRowSegments(line) {
|
|
2610
2655
|
const segments = [];
|
|
@@ -2633,7 +2678,7 @@ function rowCells(line) {
|
|
|
2633
2678
|
function unescapeCellPipes(cell) {
|
|
2634
2679
|
return cell.replace(/\\\|/g, "|");
|
|
2635
2680
|
}
|
|
2636
|
-
var BLOCK_START = /^(?:[-+*](?:\s|$)|\d{1,9}[.)](?:\s|$)|>|#{1,6}(?:\s|$)|(?:-\s*){3,}$|(?:\*\s*){3,}$|(?:_\s*){3,}
|
|
2681
|
+
var BLOCK_START = /^(?:[-+*](?:\s|$)|\d{1,9}[.)](?:\s|$)|>|#{1,6}(?:\s|$)|(?:-\s*){3,}$|(?:\*\s*){3,}$|(?:_\s*){3,}$|\[\^[^\]\s]+\]:)/;
|
|
2637
2682
|
var startsBlock = (trimmed) => BLOCK_START.test(trimmed) || opensStrictFence(trimmed) || startsHtmlBlock(trimmed);
|
|
2638
2683
|
var HTML_RAW = /^<(?:script|pre|style|textarea)(?:[\s>]|$)/i;
|
|
2639
2684
|
var HTML_COMMENT_ETC = /^(?:<!--|<\?|<![A-Za-z]|<!\[CDATA\[)/;
|
|
@@ -2723,11 +2768,45 @@ function continuesTable(line, containerIndent = 0) {
|
|
|
2723
2768
|
function opensTable(lines, index) {
|
|
2724
2769
|
const line = lines[index] ?? "";
|
|
2725
2770
|
if (!isPipeLedRow(line) && !startsPipelessTable(line, lines[index + 1])) return false;
|
|
2726
|
-
return !isLazyContinuation(lines, index);
|
|
2771
|
+
return !isLazyContinuation(lines, index) && !insideHtmlBlock(lines, index);
|
|
2727
2772
|
}
|
|
2728
2773
|
var QUOTE_LINE = /^ {0,3}>/;
|
|
2729
2774
|
var THEMATIC_BREAK = /^(?:(?:-[ \t]*){3,}|(?:\*[ \t]*){3,}|(?:_[ \t]*){3,})$/;
|
|
2730
2775
|
var breaksParagraph = (trimmed) => /^#{1,6}(?:\s|$)/.test(trimmed) || THEMATIC_BREAK.test(trimmed) || opensStrictFence(trimmed) || startsHtmlBlock(trimmed);
|
|
2776
|
+
function htmlBlockEnd(trimmed) {
|
|
2777
|
+
if (HTML_RAW.test(trimmed)) return /<\/(?:script|pre|style|textarea)>/i;
|
|
2778
|
+
if (trimmed.startsWith("<!--")) return /-->/;
|
|
2779
|
+
if (trimmed.startsWith("<?")) return /\?>/;
|
|
2780
|
+
if (trimmed.startsWith("<![CDATA[")) return /\]\]>/;
|
|
2781
|
+
if (/^<![A-Za-z]/.test(trimmed)) return />/;
|
|
2782
|
+
if (HTML_BLOCK_TAG.test(trimmed)) return null;
|
|
2783
|
+
if (HTML_COMPLETE_TAG.test(trimmed)) return null;
|
|
2784
|
+
return void 0;
|
|
2785
|
+
}
|
|
2786
|
+
function insideHtmlBlock(lines, index) {
|
|
2787
|
+
let start = index;
|
|
2788
|
+
while (start > 0 && (lines[start - 1] ?? "").trim()) start -= 1;
|
|
2789
|
+
let open;
|
|
2790
|
+
let paragraph = false;
|
|
2791
|
+
for (let k = start; k < index; k += 1) {
|
|
2792
|
+
const line = lines[k] ?? "";
|
|
2793
|
+
if (open !== void 0) {
|
|
2794
|
+
if (open && open.test(line)) open = void 0;
|
|
2795
|
+
continue;
|
|
2796
|
+
}
|
|
2797
|
+
const trimmed = line.trim();
|
|
2798
|
+
const end = lineIndent(line) < 4 ? htmlBlockEnd(trimmed) : void 0;
|
|
2799
|
+
const type7 = end === null && !HTML_BLOCK_TAG.test(trimmed);
|
|
2800
|
+
const interrupts = end !== void 0 && !(paragraph && type7);
|
|
2801
|
+
if (!interrupts) {
|
|
2802
|
+
paragraph = true;
|
|
2803
|
+
continue;
|
|
2804
|
+
}
|
|
2805
|
+
paragraph = false;
|
|
2806
|
+
open = end && end.test(trimmed.slice(2)) ? void 0 : end;
|
|
2807
|
+
}
|
|
2808
|
+
return open !== void 0;
|
|
2809
|
+
}
|
|
2731
2810
|
function isLazyContinuation(lines, index) {
|
|
2732
2811
|
const header = lines[index] ?? "";
|
|
2733
2812
|
let first = -1;
|
|
@@ -2785,6 +2864,7 @@ exports.buildCodePointIndex = buildCodePointIndex;
|
|
|
2785
2864
|
exports.classifyInnerFenceLine = classifyInnerFenceLine;
|
|
2786
2865
|
exports.closeFence = closeFence;
|
|
2787
2866
|
exports.codeSpanText = codeSpanText;
|
|
2867
|
+
exports.collectLinkDefinitions = collectLinkDefinitions;
|
|
2788
2868
|
exports.continuesTable = continuesTable;
|
|
2789
2869
|
exports.fenceLineKinds = fenceLineKinds;
|
|
2790
2870
|
exports.fenceNestsInnerFences = fenceNestsInnerFences;
|
|
@@ -2810,11 +2890,13 @@ exports.mapCodeRanges = mapCodeRanges;
|
|
|
2810
2890
|
exports.mapInlineCodeSpans = mapInlineCodeSpans;
|
|
2811
2891
|
exports.mapPosition = mapPosition;
|
|
2812
2892
|
exports.mapRange = mapRange;
|
|
2893
|
+
exports.normalizeLinkLabel = normalizeLinkLabel;
|
|
2813
2894
|
exports.opensTable = opensTable;
|
|
2814
2895
|
exports.pairDisplayMath = pairDisplayMath;
|
|
2815
2896
|
exports.parseFenceOpener = parseFenceOpener;
|
|
2816
2897
|
exports.pendingDisplayMathOpener = pendingDisplayMathOpener;
|
|
2817
2898
|
exports.readXmlTag = readXmlTag;
|
|
2899
|
+
exports.resolveReferenceLinks = resolveReferenceLinks;
|
|
2818
2900
|
exports.rowCells = rowCells;
|
|
2819
2901
|
exports.singleDollarAfter = singleDollarAfter;
|
|
2820
2902
|
exports.singleDollarMathEnd = singleDollarMathEnd;
|