@ai-react-markdown/engine 2.4.2 → 2.4.3
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/dist/index.cjs +26 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +20 -41
- package/dist/index.d.ts +20 -41
- package/dist/index.dev.cjs +26 -21
- package/dist/index.dev.cjs.map +1 -1
- package/dist/index.dev.js +26 -21
- package/dist/index.dev.js.map +1 -1
- package/dist/index.js +26 -21
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1149,6 +1149,8 @@ function rebaseDualWalk(node, segments, maxEnd, offsetDelta, lineDelta) {
|
|
|
1149
1149
|
for (const child of children) rebaseDualWalk(child, segments, maxEnd, offsetDelta, lineDelta);
|
|
1150
1150
|
}
|
|
1151
1151
|
}
|
|
1152
|
+
var TABLE_PART_TAG_RE = /<(?:td|th|tr|tbody|thead|tfoot|caption|col|colgroup)\b/i;
|
|
1153
|
+
var STRAY_SYNTHESIZED_END_TAG_RE = /<\/(?:br|p)\b/i;
|
|
1152
1154
|
function spliceTrees(input) {
|
|
1153
1155
|
const { prevMdast, prevHast, tailMdast, tailHast, content, boundary, injectionPrefix, injectedSegments } = input;
|
|
1154
1156
|
const injectedLen = injectionPrefix.length;
|
|
@@ -1205,6 +1207,12 @@ function spliceTrees(input) {
|
|
|
1205
1207
|
return !(start !== void 0 && start < injectedLen);
|
|
1206
1208
|
});
|
|
1207
1209
|
const tailWrapVisible = tailMdastChildren.some((child) => !isWrapInvisible(child));
|
|
1210
|
+
if (prefixMdast.some((c) => c.type === "html" && TABLE_PART_TAG_RE.test(c.value))) return null;
|
|
1211
|
+
for (const child of tailMdastChildren) {
|
|
1212
|
+
if (isWrapInvisible(child)) continue;
|
|
1213
|
+
if (child.type !== "html") break;
|
|
1214
|
+
if (STRAY_SYNTHESIZED_END_TAG_RE.test(child.value) || TABLE_PART_TAG_RE.test(child.value)) return null;
|
|
1215
|
+
}
|
|
1208
1216
|
const aligned = alignPrefixCut(prefixMdast, cutRegion, tailWrapVisible);
|
|
1209
1217
|
if (aligned === null) return null;
|
|
1210
1218
|
const hastChildren = aligned.children;
|
|
@@ -1330,6 +1338,9 @@ function alignPrefixCut(prefixMdast, cutRegion, tailWrapVisible) {
|
|
|
1330
1338
|
return null;
|
|
1331
1339
|
}
|
|
1332
1340
|
const lastIsLiteral = last !== void 0 && last.type === "text" && last.value.trim() !== "";
|
|
1341
|
+
if (lastIsLiteral && pairIdx >= 0 && visibles[pairIdx].type !== "html") {
|
|
1342
|
+
return null;
|
|
1343
|
+
}
|
|
1333
1344
|
const litOwnerEnd = pairIdx >= 0 ? visibles[pairIdx].position?.end?.offset : void 0;
|
|
1334
1345
|
const litEnd = lastIsLiteral ? last.position?.end?.offset : void 0;
|
|
1335
1346
|
if (lastIsLiteral && last.position !== void 0 && (litEnd === void 0 || litOwnerEnd === void 0)) {
|
|
@@ -1418,8 +1429,9 @@ function stripInjectedHast(tailMdast, tailHast, injectedLen, tailWrapVisible) {
|
|
|
1418
1429
|
}
|
|
1419
1430
|
function tailLeadingTextIsHoist(tailMdastChildren, tailHastChildren) {
|
|
1420
1431
|
const firstText = tailHastChildren[0];
|
|
1421
|
-
if (!firstText) return false;
|
|
1422
1432
|
const firstVisible = tailMdastChildren.find((c) => !isWrapInvisible(c));
|
|
1433
|
+
if (firstVisible?.type === "html" && STRAY_SYNTHESIZED_END_TAG_RE.test(firstVisible.value)) return null;
|
|
1434
|
+
if (!firstText) return false;
|
|
1423
1435
|
if (!isSeparatorText(firstText)) {
|
|
1424
1436
|
if (firstText.type === "text" && firstText.position === void 0 && firstVisible?.type === "html") {
|
|
1425
1437
|
if (/^\s*<\/[A-Za-z][A-Za-z0-9-]*\s*>/.test(firstVisible.value)) return true;
|
|
@@ -1860,17 +1872,8 @@ function phantomSuffixCloser(content) {
|
|
|
1860
1872
|
}
|
|
1861
1873
|
|
|
1862
1874
|
// src/components/extractContributions.ts
|
|
1863
|
-
function fakeAnchorElement(url) {
|
|
1864
|
-
return { type: "element", tagName: "a", properties: { href: url }, children: [] };
|
|
1865
|
-
}
|
|
1866
|
-
function sanitizeDefUrl(url, urlTransform) {
|
|
1867
|
-
if (!urlTransform) return url;
|
|
1868
|
-
const result = urlTransform(url, "href", fakeAnchorElement(url));
|
|
1869
|
-
return result == null ? "" : String(result);
|
|
1870
|
-
}
|
|
1871
1875
|
function* extractContributions(mdast, options = {}) {
|
|
1872
1876
|
const phantomFn = options.phantomFootnoteLabels;
|
|
1873
|
-
const urlTransform = options.urlTransform;
|
|
1874
1877
|
const out = [];
|
|
1875
1878
|
(0, import_unist_util_visit3.visit)(mdast, (n) => {
|
|
1876
1879
|
if (n.type === "footnoteReference") {
|
|
@@ -1898,7 +1901,7 @@ function* extractContributions(mdast, options = {}) {
|
|
|
1898
1901
|
out.push({
|
|
1899
1902
|
kind: "linkDef",
|
|
1900
1903
|
label: normalizeId(d.identifier),
|
|
1901
|
-
url:
|
|
1904
|
+
url: d.url,
|
|
1902
1905
|
title: d.title
|
|
1903
1906
|
});
|
|
1904
1907
|
}
|
|
@@ -3612,8 +3615,7 @@ function isProtocolAllowed(url, allowed) {
|
|
|
3612
3615
|
}
|
|
3613
3616
|
function sanitizeCrossChunkUrl(rawUrl, key, tagName, urlTransform, schema) {
|
|
3614
3617
|
rawUrl = (0, import_micromark_util_sanitize_uri2.normalizeUri)(rawUrl);
|
|
3615
|
-
const
|
|
3616
|
-
const allowed = callerProtocols === void 0 || callerProtocols === null ? sanitizeSchema.protocols?.[key] : callerProtocols[key];
|
|
3618
|
+
const allowed = Object.hasOwn(schema, "protocols") ? schema.protocols?.[key] : sanitizeSchema.protocols?.[key];
|
|
3617
3619
|
if (allowed && allowed.length > 0 && !isProtocolAllowed(rawUrl, allowed)) return null;
|
|
3618
3620
|
const transformed = urlTransform(rawUrl, key, fakeElement(tagName, key, rawUrl));
|
|
3619
3621
|
if (transformed == null) return null;
|
|
@@ -4011,15 +4013,14 @@ function lineHasBacktick(content, pos) {
|
|
|
4011
4013
|
}
|
|
4012
4014
|
return false;
|
|
4013
4015
|
}
|
|
4014
|
-
function
|
|
4016
|
+
function lineIndentBefore(content, pos) {
|
|
4015
4017
|
let i = pos - 1;
|
|
4016
|
-
let
|
|
4017
|
-
while (i >= 0 && content[i] === " ") {
|
|
4018
|
-
|
|
4019
|
-
if (spaces > 3) return false;
|
|
4018
|
+
let indent = 0;
|
|
4019
|
+
while (i >= 0 && (content[i] === " " || content[i] === " ")) {
|
|
4020
|
+
indent += content[i] === " " ? 4 : 1;
|
|
4020
4021
|
i--;
|
|
4021
4022
|
}
|
|
4022
|
-
return i < 0 || content[i] === "\n" || content[i] === "\r";
|
|
4023
|
+
return i < 0 || content[i] === "\n" || content[i] === "\r" ? indent : -1;
|
|
4023
4024
|
}
|
|
4024
4025
|
function findClosingBacktickRun(content, start, n) {
|
|
4025
4026
|
let i = start;
|
|
@@ -4040,6 +4041,7 @@ function splitByProtectedRegions(content) {
|
|
|
4040
4041
|
let multilineStart = -1;
|
|
4041
4042
|
let multilineFenceMarker = null;
|
|
4042
4043
|
let multilineFenceLength = 0;
|
|
4044
|
+
let multilineFenceIndent = 0;
|
|
4043
4045
|
function pushProtected(start, end) {
|
|
4044
4046
|
if (start > lastIndex) {
|
|
4045
4047
|
segments.push({ text: content.substring(lastIndex, start), isCode: false });
|
|
@@ -4053,7 +4055,8 @@ function splitByProtectedRegions(content) {
|
|
|
4053
4055
|
if (multilineStart !== -1) {
|
|
4054
4056
|
if (char === multilineFenceMarker) {
|
|
4055
4057
|
const runLen = getRepeatedMarkerLength(content, i, multilineFenceMarker);
|
|
4056
|
-
|
|
4058
|
+
const closerIndent = lineIndentBefore(content, i);
|
|
4059
|
+
if (runLen >= multilineFenceLength && closerIndent !== -1 && closerIndent <= multilineFenceIndent + 3 && restOfLineIsBlank(content, i + runLen)) {
|
|
4057
4060
|
pushProtected(multilineStart, i + runLen);
|
|
4058
4061
|
multilineStart = -1;
|
|
4059
4062
|
multilineFenceMarker = null;
|
|
@@ -4069,10 +4072,12 @@ function splitByProtectedRegions(content) {
|
|
|
4069
4072
|
}
|
|
4070
4073
|
if (char === "`" || char === "~") {
|
|
4071
4074
|
const runLen = getRepeatedMarkerLength(content, i, char);
|
|
4072
|
-
|
|
4075
|
+
const openerIndent = lineIndentBefore(content, i);
|
|
4076
|
+
if (runLen >= 3 && openerIndent !== -1 && !(char === "`" && lineHasBacktick(content, i + runLen))) {
|
|
4073
4077
|
multilineStart = i;
|
|
4074
4078
|
multilineFenceMarker = char;
|
|
4075
4079
|
multilineFenceLength = runLen;
|
|
4080
|
+
multilineFenceIndent = openerIndent;
|
|
4076
4081
|
i += runLen;
|
|
4077
4082
|
continue;
|
|
4078
4083
|
}
|