@ai-react-markdown/engine 2.5.4 → 2.5.5
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 +85 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.dev.cjs +85 -4
- package/dist/index.dev.cjs.map +1 -1
- package/dist/index.dev.js +85 -4
- package/dist/index.dev.js.map +1 -1
- package/dist/index.js +85 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -499,6 +499,11 @@ interface FreezeScanCheckpoint {
|
|
|
499
499
|
/** The currently open raw-text element (`rawTextOpen`) was opened INLINE —
|
|
500
500
|
* in paragraph context rather than in a real html-flow run. */
|
|
501
501
|
rawTextInline: boolean;
|
|
502
|
+
/** The open-element stack, in order. `tagBalance` and `openTotal` are
|
|
503
|
+
* derived views kept in step with it, but the STACK is the truth: an end
|
|
504
|
+
* tag's effect depends on what sits BETWEEN it and its match, which a
|
|
505
|
+
* name→count bag cannot represent (see SCOPE_BARRIER_NAMES). */
|
|
506
|
+
openStack: string[];
|
|
502
507
|
/** parse5 is in "script data escaped": a `<!--` has been seen inside the
|
|
503
508
|
* open `<script>`. Only meaningful while `rawTextOpen === 'script'`.
|
|
504
509
|
* Deliberately NOT cleared by `-->` — staying escaped can only poison
|
package/dist/index.d.ts
CHANGED
|
@@ -499,6 +499,11 @@ interface FreezeScanCheckpoint {
|
|
|
499
499
|
/** The currently open raw-text element (`rawTextOpen`) was opened INLINE —
|
|
500
500
|
* in paragraph context rather than in a real html-flow run. */
|
|
501
501
|
rawTextInline: boolean;
|
|
502
|
+
/** The open-element stack, in order. `tagBalance` and `openTotal` are
|
|
503
|
+
* derived views kept in step with it, but the STACK is the truth: an end
|
|
504
|
+
* tag's effect depends on what sits BETWEEN it and its match, which a
|
|
505
|
+
* name→count bag cannot represent (see SCOPE_BARRIER_NAMES). */
|
|
506
|
+
openStack: string[];
|
|
502
507
|
/** parse5 is in "script data escaped": a `<!--` has been seen inside the
|
|
503
508
|
* open `<script>`. Only meaningful while `rawTextOpen === 'script'`.
|
|
504
509
|
* Deliberately NOT cleared by `-->` — staying escaped can only poison
|
package/dist/index.dev.cjs
CHANGED
|
@@ -337,6 +337,26 @@ var HTML_BREAKOUT_TAGS = /* @__PURE__ */ new Set([
|
|
|
337
337
|
"var"
|
|
338
338
|
]);
|
|
339
339
|
var HTML_INTEGRATION_POINTS = ["foreignobject", "desc", "title", "mi", "mo", "mn", "ms", "mtext", "annotation-xml"];
|
|
340
|
+
var SCOPE_BARRIER_NAMES = /* @__PURE__ */ new Set([
|
|
341
|
+
"applet",
|
|
342
|
+
"caption",
|
|
343
|
+
"html",
|
|
344
|
+
"table",
|
|
345
|
+
"td",
|
|
346
|
+
"th",
|
|
347
|
+
"marquee",
|
|
348
|
+
"object",
|
|
349
|
+
"template",
|
|
350
|
+
"mi",
|
|
351
|
+
"mo",
|
|
352
|
+
"mn",
|
|
353
|
+
"ms",
|
|
354
|
+
"mtext",
|
|
355
|
+
"annotation-xml",
|
|
356
|
+
"foreignobject",
|
|
357
|
+
"desc",
|
|
358
|
+
"title"
|
|
359
|
+
]);
|
|
340
360
|
var FOREIGN_ROOT_NAMES = ["svg", "math"];
|
|
341
361
|
var TYPE1_NAMES = /* @__PURE__ */ new Set(["script", "pre", "style", "textarea"]);
|
|
342
362
|
var RAW_TEXT_ELEMENTS = /* @__PURE__ */ new Set([
|
|
@@ -507,6 +527,7 @@ function freshCheckpoint(defListEnabled, mathFlow, referenceTaint) {
|
|
|
507
527
|
piOpen: false,
|
|
508
528
|
bogusOpen: false,
|
|
509
529
|
rawTextOpen: null,
|
|
530
|
+
openStack: [],
|
|
510
531
|
scriptDataEscaped: false,
|
|
511
532
|
declOpen: false,
|
|
512
533
|
cdataOpen: false,
|
|
@@ -768,6 +789,7 @@ function processConfirmedLine(cp, ln, text) {
|
|
|
768
789
|
cp.openTotal -= count;
|
|
769
790
|
}
|
|
770
791
|
}
|
|
792
|
+
if (cp.openStack.length > 0) cp.openStack = cp.openStack.filter((n) => !FOREIGN_ROOT_NAMES.includes(n));
|
|
771
793
|
};
|
|
772
794
|
const noteBreakout = (tag, closing) => {
|
|
773
795
|
if (closing || cp.rawTextOpen !== null) return;
|
|
@@ -791,13 +813,25 @@ function processConfirmedLine(cp, ln, text) {
|
|
|
791
813
|
}
|
|
792
814
|
}
|
|
793
815
|
if (DOCUMENT_STRUCTURE_NAMES.has(tag)) cp.phasePoisonedAt = 0;
|
|
816
|
+
if (tag === "template" && !closing) cp.phasePoisonedAt = 0;
|
|
794
817
|
if (closing) {
|
|
818
|
+
let idx = -1;
|
|
819
|
+
for (let i = cp.openStack.length - 1; i >= 0; i--) {
|
|
820
|
+
if (cp.openStack[i] === tag) {
|
|
821
|
+
idx = i;
|
|
822
|
+
break;
|
|
823
|
+
}
|
|
824
|
+
if (SCOPE_BARRIER_NAMES.has(cp.openStack[i])) break;
|
|
825
|
+
}
|
|
826
|
+
if (idx === -1) return;
|
|
827
|
+
cp.openStack.splice(idx, 1);
|
|
795
828
|
const count = cp.tagBalance.get(tag) ?? 0;
|
|
796
829
|
if (count > 0) {
|
|
797
830
|
cp.tagBalance.set(tag, count - 1);
|
|
798
831
|
cp.openTotal -= 1;
|
|
799
832
|
}
|
|
800
833
|
} else {
|
|
834
|
+
cp.openStack.push(tag);
|
|
801
835
|
cp.tagBalance.set(tag, (cp.tagBalance.get(tag) ?? 0) + 1);
|
|
802
836
|
cp.openTotal += 1;
|
|
803
837
|
}
|
|
@@ -916,6 +950,9 @@ function processConfirmedLine(cp, ln, text) {
|
|
|
916
950
|
if (!cp.type1FlowOpen) {
|
|
917
951
|
cp.htmlFlowSinceBlank = false;
|
|
918
952
|
cp.htmlFlowReal = false;
|
|
953
|
+
if (cp.rawTextOpen !== null && !cp.rawTextInline) {
|
|
954
|
+
cp.phasePoisonedAt = 0;
|
|
955
|
+
}
|
|
919
956
|
}
|
|
920
957
|
cp.prevLineBlank = true;
|
|
921
958
|
cp.prevLineWasText = false;
|
|
@@ -1015,6 +1052,7 @@ ${cont(scanText)}` };
|
|
|
1015
1052
|
const poisonRawDivergence = () => {
|
|
1016
1053
|
cp.phasePoisonedAt = Math.min(cp.phasePoisonedAt, ln.start);
|
|
1017
1054
|
};
|
|
1055
|
+
let inlineRawOpenerIdx = -1;
|
|
1018
1056
|
while (pos < scanText.length) {
|
|
1019
1057
|
if (cp.piOpen) {
|
|
1020
1058
|
const c = scanText.indexOf("?>", pos);
|
|
@@ -1070,6 +1108,7 @@ ${cont(scanText)}` };
|
|
|
1070
1108
|
} else if (first === cd) {
|
|
1071
1109
|
rawSpans.push([cd, cd + 9]);
|
|
1072
1110
|
cp.cdataOpen = true;
|
|
1111
|
+
if (!isMdBlank(scanText.slice(0, cd)) || ln.indent > 3) inlineRawOpenerIdx = cd;
|
|
1073
1112
|
pos = cd + 9;
|
|
1074
1113
|
} else if (first === pi) {
|
|
1075
1114
|
if (scanText[pi + 2] === ">") {
|
|
@@ -1080,14 +1119,19 @@ ${cont(scanText)}` };
|
|
|
1080
1119
|
}
|
|
1081
1120
|
rawSpans.push([pi, pi + 2]);
|
|
1082
1121
|
cp.piOpen = true;
|
|
1122
|
+
if (!isMdBlank(scanText.slice(0, pi)) || ln.indent > 3) inlineRawOpenerIdx = pi;
|
|
1083
1123
|
pos = pi + 2;
|
|
1084
1124
|
} else {
|
|
1085
1125
|
rawSpans.push([decl, decl + 2]);
|
|
1086
1126
|
if (ln.indent <= 3 && /^doctype/i.test(scanText.slice(decl + 2))) cp.phasePoisonedAt = 0;
|
|
1087
1127
|
cp.declOpen = true;
|
|
1128
|
+
if (!isMdBlank(scanText.slice(0, decl)) || ln.indent > 3) inlineRawOpenerIdx = decl;
|
|
1088
1129
|
pos = decl + 2;
|
|
1089
1130
|
}
|
|
1090
1131
|
}
|
|
1132
|
+
if (inlineRawOpenerIdx !== -1 && (cp.piOpen || cp.declOpen || cp.cdataOpen)) {
|
|
1133
|
+
cp.phasePoisonedAt = 0;
|
|
1134
|
+
}
|
|
1091
1135
|
let tagText = scanText;
|
|
1092
1136
|
for (const [from, to] of rawSpans) {
|
|
1093
1137
|
tagText = tagText.slice(0, from) + " ".repeat(to - from) + tagText.slice(to);
|
|
@@ -1176,9 +1220,9 @@ ${cont(scanText)}` };
|
|
|
1176
1220
|
if (VOID_TAGS.has(tag) || selfClosing && honoursSelfClosing(tag)) continue;
|
|
1177
1221
|
applyTag(tag, closing);
|
|
1178
1222
|
}
|
|
1179
|
-
if (cp.commentOpen && lastCommentOpenerIdx !== -1
|
|
1180
|
-
if (!isMdBlank(tagText.slice(0, lastCommentOpenerIdx))) {
|
|
1181
|
-
cp.phasePoisonedAt =
|
|
1223
|
+
if (cp.commentOpen && lastCommentOpenerIdx !== -1) {
|
|
1224
|
+
if (!isMdBlank(tagText.slice(0, lastCommentOpenerIdx)) || ln.indent > 3) {
|
|
1225
|
+
cp.phasePoisonedAt = 0;
|
|
1182
1226
|
}
|
|
1183
1227
|
}
|
|
1184
1228
|
if (masked !== null && masked !== ln.text) {
|
|
@@ -1478,6 +1522,40 @@ function hasStrayTablePart(values) {
|
|
|
1478
1522
|
}
|
|
1479
1523
|
return false;
|
|
1480
1524
|
}
|
|
1525
|
+
var HEAD_ROUTED_NAMES = /* @__PURE__ */ new Set([
|
|
1526
|
+
"base",
|
|
1527
|
+
"basefont",
|
|
1528
|
+
"bgsound",
|
|
1529
|
+
"link",
|
|
1530
|
+
"meta",
|
|
1531
|
+
"noframes",
|
|
1532
|
+
"script",
|
|
1533
|
+
"style",
|
|
1534
|
+
"template",
|
|
1535
|
+
"title"
|
|
1536
|
+
]);
|
|
1537
|
+
var HEAD_ROUTED_RAW_TEXT_RE = /<(script|style|title|noframes)(?=[\s/>])/i;
|
|
1538
|
+
var ANY_START_TAG_RE = /<([a-z][a-z0-9-]*)(?=[\s/>])/gi;
|
|
1539
|
+
function headRoutedCaptureUnclosed(values) {
|
|
1540
|
+
if (values.length === 0) return false;
|
|
1541
|
+
const joined = values.join("\n");
|
|
1542
|
+
const opener = HEAD_ROUTED_RAW_TEXT_RE.exec(joined);
|
|
1543
|
+
if (opener === null) return false;
|
|
1544
|
+
const before = joined.slice(0, opener.index);
|
|
1545
|
+
if (/<[!?]/.test(before)) return true;
|
|
1546
|
+
ANY_START_TAG_RE.lastIndex = 0;
|
|
1547
|
+
let m;
|
|
1548
|
+
while ((m = ANY_START_TAG_RE.exec(before)) !== null) {
|
|
1549
|
+
if (!HEAD_ROUTED_NAMES.has(m[1].toLowerCase())) return false;
|
|
1550
|
+
}
|
|
1551
|
+
const name = opener[1].toLowerCase();
|
|
1552
|
+
const after = joined.slice(opener.index + opener[0].length);
|
|
1553
|
+
if (name === "script") {
|
|
1554
|
+
const close = after.search(/<\/script(?=[\s/>])/i);
|
|
1555
|
+
return close === -1 || /<!--/.test(after.slice(0, close));
|
|
1556
|
+
}
|
|
1557
|
+
return !new RegExp(`</${name}(?=[\\s/>])`, "i").test(after);
|
|
1558
|
+
}
|
|
1481
1559
|
var STRAY_SYNTHESIZED_END_TAG_RE = /<\/(?:br|p)\b/i;
|
|
1482
1560
|
function spliceTrees(input) {
|
|
1483
1561
|
const { prevMdast, prevHast, tailMdast, tailHast, content, boundary, injectionPrefix, injectedSegments } = input;
|
|
@@ -1536,11 +1614,14 @@ function spliceTrees(input) {
|
|
|
1536
1614
|
});
|
|
1537
1615
|
const tailWrapVisible = tailMdastChildren.some((child) => !isWrapInvisible(child));
|
|
1538
1616
|
if (hasStrayTablePart(prefixMdast.flatMap((c) => c.type === "html" ? [c.value] : []))) return null;
|
|
1617
|
+
const leadingHtml = [];
|
|
1539
1618
|
for (const child of tailMdastChildren) {
|
|
1540
1619
|
if (isWrapInvisible(child)) continue;
|
|
1541
1620
|
if (child.type !== "html") break;
|
|
1542
1621
|
if (STRAY_SYNTHESIZED_END_TAG_RE.test(child.value) || TABLE_PART_TAG_RE.test(child.value)) return null;
|
|
1622
|
+
leadingHtml.push(child.value);
|
|
1543
1623
|
}
|
|
1624
|
+
if (headRoutedCaptureUnclosed(leadingHtml)) return null;
|
|
1544
1625
|
const aligned = alignPrefixCut(prefixMdast, cutRegion, tailWrapVisible);
|
|
1545
1626
|
if (aligned === null) return null;
|
|
1546
1627
|
const hastChildren = aligned.children;
|
|
@@ -2465,7 +2546,7 @@ function createRegistry(onEmpty) {
|
|
|
2465
2546
|
|
|
2466
2547
|
// src/components/pluginChain.ts
|
|
2467
2548
|
var import_rehype_katex = __toESM(require("rehype-katex"), 1);
|
|
2468
|
-
var import_rehype_raw = __toESM(require("rehype-raw"), 1);
|
|
2549
|
+
var import_rehype_raw = __toESM(require("@ai-markdown/rehype-raw"), 1);
|
|
2469
2550
|
var import_rehype_unwrap_images = __toESM(require("rehype-unwrap-images"), 1);
|
|
2470
2551
|
|
|
2471
2552
|
// src/components/rehypeUnwrapCrossChunkImages.ts
|