@ai-matrx/content-ir 0.19.15 → 0.19.17
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 +12 -0
- package/dist/index.cjs +22 -5
- 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 +22 -6
- package/dist/index.js.map +1 -1
- package/dist/source.cjs +22 -5
- package/dist/source.cjs.map +1 -1
- package/dist/source.d.cts +3 -1
- package/dist/source.d.ts +3 -1
- package/dist/source.js +22 -6
- package/dist/source.js.map +1 -1
- package/package.json +1 -1
package/dist/source.cjs
CHANGED
|
@@ -2612,20 +2612,36 @@ function normalizeLinkLabel(label) {
|
|
|
2612
2612
|
var DEFINITION = /^ {0,3}\[((?:[^\]\\]|\\.){1,999})\]:[ \t]*(?:<([^<>\n]*)>|(\S+))(?:[ \t]+(?:"((?:[^"\\]|\\.)*)"|'((?:[^'\\]|\\.)*)'|\(((?:[^()\\]|\\.)*)\)))?[ \t]*$/;
|
|
2613
2613
|
function collectLinkDefinitions(text) {
|
|
2614
2614
|
const defs = /* @__PURE__ */ new Map();
|
|
2615
|
-
|
|
2615
|
+
for (const { label, definition } of scanLinkDefinitions(text)) {
|
|
2616
|
+
const key = normalizeLinkLabel(label);
|
|
2617
|
+
if (key && !defs.has(key)) defs.set(key, definition);
|
|
2618
|
+
}
|
|
2619
|
+
return defs;
|
|
2620
|
+
}
|
|
2621
|
+
function findLinkDefinitionLines(text) {
|
|
2622
|
+
return scanLinkDefinitions(text).map(({ line }) => line);
|
|
2623
|
+
}
|
|
2624
|
+
function scanLinkDefinitions(text) {
|
|
2625
|
+
const found = [];
|
|
2626
|
+
if (!text.includes("]:")) return found;
|
|
2616
2627
|
const lines = text.split("\n");
|
|
2617
2628
|
const kinds = fenceLineKinds(text);
|
|
2629
|
+
let previousWasDefinition = false;
|
|
2618
2630
|
lines.forEach((line, i) => {
|
|
2631
|
+
const wasDefinition = previousWasDefinition;
|
|
2632
|
+
previousWasDefinition = false;
|
|
2619
2633
|
if (kinds[i] !== "prose") return;
|
|
2620
2634
|
const m = DEFINITION.exec(line);
|
|
2621
2635
|
if (!m) return;
|
|
2636
|
+
const above = i > 0 ? lines[i - 1] ?? "" : "";
|
|
2637
|
+
const opensBlock = i === 0 || !above.trim() || wasDefinition || kinds[i - 1] === "close" || /^ {0,3}(?:#{1,6}(?:\s|$)|(?:[-*_][ \t]*){3,}$)/.test(above);
|
|
2638
|
+
if (!opensBlock) return;
|
|
2622
2639
|
const label = m[1] ?? "";
|
|
2623
2640
|
if (label.startsWith("^")) return;
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
defs.set(key, { url: m[2] ?? m[3] ?? "", title: m[4] ?? m[5] ?? m[6] ?? null });
|
|
2641
|
+
previousWasDefinition = true;
|
|
2642
|
+
found.push({ line: i, label, definition: { url: m[2] ?? m[3] ?? "", title: m[4] ?? m[5] ?? m[6] ?? null } });
|
|
2627
2643
|
});
|
|
2628
|
-
return
|
|
2644
|
+
return found;
|
|
2629
2645
|
}
|
|
2630
2646
|
var REFERENCE = /(!?)\[((?:[^\]\\]|\\.)*)\](?:\[((?:[^\]\\]|\\.)*)\])?(?![(:[])/g;
|
|
2631
2647
|
var escapeTitle = (title) => title.replace(/["\\]/g, "\\$&");
|
|
@@ -2872,6 +2888,7 @@ exports.fenceOpenerOf = fenceOpenerOf;
|
|
|
2872
2888
|
exports.fenceParts = fenceParts;
|
|
2873
2889
|
exports.findCodeRanges = findCodeRanges;
|
|
2874
2890
|
exports.findInlineCodeSpans = findInlineCodeSpans;
|
|
2891
|
+
exports.findLinkDefinitionLines = findLinkDefinitionLines;
|
|
2875
2892
|
exports.findTableEnd = findTableEnd;
|
|
2876
2893
|
exports.findTableStart = findTableStart;
|
|
2877
2894
|
exports.isEscapedBracketMath = isEscapedBracketMath;
|