@ai-react-markdown/engine 2.8.2 → 2.9.0
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 +46 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.dev.cjs +51 -11
- package/dist/index.dev.cjs.map +1 -1
- package/dist/index.dev.js +51 -11
- package/dist/index.dev.js.map +1 -1
- package/dist/index.js +46 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.dev.cjs
CHANGED
|
@@ -378,9 +378,9 @@ function inlineResourceEnd(text, openIdx) {
|
|
|
378
378
|
}
|
|
379
379
|
return -1;
|
|
380
380
|
}
|
|
381
|
-
function collectRefLine(cp, lnStart, lnEnd, scanText, inRawText, isBlockStart) {
|
|
382
|
-
const defShaped = inRawText ? null : DEF_RE.exec(
|
|
383
|
-
const def = defShaped !== null && (defShaped[1].startsWith("^") || isPlausibleLinkDefRest(
|
|
381
|
+
function collectRefLine(cp, lnStart, lnEnd, scanText, rawText, inRawText, isBlockStart) {
|
|
382
|
+
const defShaped = inRawText ? null : DEF_RE.exec(rawText);
|
|
383
|
+
const def = defShaped !== null && (defShaped[1].startsWith("^") || isPlausibleLinkDefRest(rawText.slice(defShaped.index + defShaped[0].length))) ? defShaped : null;
|
|
384
384
|
const defLineStart = isBlockStart || !cp.prevLineWasText || cp.prevLineWasValidDef;
|
|
385
385
|
const validDef = def !== null && defLineStart;
|
|
386
386
|
if (validDef) {
|
|
@@ -598,12 +598,15 @@ var rawTextElement = (t) => t.kind === "rawText" ? t.element : t.kind === "scrip
|
|
|
598
598
|
var VOID_TAGS = /* @__PURE__ */ new Set([
|
|
599
599
|
"area",
|
|
600
600
|
"base",
|
|
601
|
+
"basefont",
|
|
602
|
+
"bgsound",
|
|
601
603
|
"br",
|
|
602
604
|
"col",
|
|
603
605
|
"embed",
|
|
604
606
|
"hr",
|
|
605
607
|
"img",
|
|
606
608
|
"input",
|
|
609
|
+
"keygen",
|
|
607
610
|
"link",
|
|
608
611
|
"meta",
|
|
609
612
|
"param",
|
|
@@ -855,6 +858,24 @@ function floatingResidue(text, commentOpenAtStart) {
|
|
|
855
858
|
if (!open) out += text.slice(last);
|
|
856
859
|
return out;
|
|
857
860
|
}
|
|
861
|
+
var RAW_CONSTRUCT_START_RE = /^<(?:!--|\?|![A-Za-z]|!\[CDATA\[)/;
|
|
862
|
+
var sealResumableAbove = (cp) => cp.defBlockMaybeOpen || cp.fnDefResumable || cp.containerMaybeOpen;
|
|
863
|
+
function sealReleaseDerived(cp, ln, isBlockStart) {
|
|
864
|
+
if (sealResumableAbove(cp) && !(isBlockStart && ln.indent <= 3)) return false;
|
|
865
|
+
if (cp.prevLineOpenContent) return false;
|
|
866
|
+
if (cp.tableMaybeOpen) return false;
|
|
867
|
+
const head = mdTrimStart(ln.text);
|
|
868
|
+
if (RAW_CONSTRUCT_START_RE.test(head) || TYPE1_START_RE.test(head) || isType7Line(head)) return false;
|
|
869
|
+
const t6 = TYPE6_START_RE.exec(head);
|
|
870
|
+
if (t6 !== null && TYPE6_NAMES.has(t6[1].toLowerCase())) return false;
|
|
871
|
+
if (DEF_RE.test(ln.text) || FOOTNOTE_DEF_RE.test(ln.text)) return false;
|
|
872
|
+
return true;
|
|
873
|
+
}
|
|
874
|
+
function sealReleaseEnumerated(cp, ln, isBlockStart) {
|
|
875
|
+
const defShapedLine = DEF_RE.test(ln.text) || FOOTNOTE_DEF_RE.test(ln.text) || cp.defBlockMaybeOpen || cp.fnDefResumable && !(isBlockStart && ln.indent <= 3);
|
|
876
|
+
const commentOnly = ln.text.replace(/<!--[\s\S]*?-->/g, " ").replace(/<!--[\s\S]*$/, " ").replace(/[ \t\r]/g, "") === "";
|
|
877
|
+
return !defShapedLine && !commentOnly && !CLOSE_TAG_ONLY_RE.test(ln.text);
|
|
878
|
+
}
|
|
858
879
|
function processConfirmedLine(cp, ln, text) {
|
|
859
880
|
const newest = cp.candidates[cp.candidates.length - 1];
|
|
860
881
|
if (newest && newest.defListSettled === null) {
|
|
@@ -862,16 +883,19 @@ function processConfirmedLine(cp, ln, text) {
|
|
|
862
883
|
}
|
|
863
884
|
const isBlockStart = cp.prevLineBlank;
|
|
864
885
|
if (cp.p5SealPending && !ln.blank && cp.mdBlock.kind !== "html" && !(cp.p5Tok.kind === "comment" || cp.p5Tok.kind === "bogus")) {
|
|
865
|
-
|
|
866
|
-
const commentOnly = ln.text.replace(/<!--[\s\S]*?-->/g, " ").replace(/<!--[\s\S]*$/, " ").replace(/[ \t\r]/g, "") === "";
|
|
867
|
-
const closeTagOnly = CLOSE_TAG_ONLY_RE.test(ln.text);
|
|
868
|
-
if (!defShapedLine && !commentOnly && !closeTagOnly) {
|
|
886
|
+
if (sealReleaseDerived(cp, ln, isBlockStart)) {
|
|
869
887
|
cp.p5SealPending = false;
|
|
888
|
+
if (!sealReleaseEnumerated(cp, ln, isBlockStart)) {
|
|
889
|
+
console.error(
|
|
890
|
+
`[ai-react-markdown] seal-release containment broken at offset ${ln.start}: the derived predicate released a line the retired enumeration withheld (${JSON.stringify(ln.text.slice(0, 80))}).`
|
|
891
|
+
);
|
|
892
|
+
}
|
|
870
893
|
}
|
|
871
894
|
}
|
|
872
895
|
const possiblyInsideForeign = () => FOREIGN_ROOT_NAMES.some((name) => (cp.tagBalance.get(name) ?? 0) > 0);
|
|
873
896
|
const honoursSelfClosing = (tag) => tag === "svg" || tag === "math";
|
|
874
897
|
const foreignRawTextSwitchUnknowable = () => possiblyInsideForeign();
|
|
898
|
+
let discardedEndTag = false;
|
|
875
899
|
const applyTag = (tag, closing) => {
|
|
876
900
|
if (inRawTextTok(cp.p5Tok)) {
|
|
877
901
|
if (cp.p5Tok.kind === "script" && cp.p5Tok.escaped && !closing && tag === "script") {
|
|
@@ -904,7 +928,10 @@ function processConfirmedLine(cp, ln, text) {
|
|
|
904
928
|
}
|
|
905
929
|
if (SCOPE_BARRIER_NAMES.has(cp.openStack[i])) break;
|
|
906
930
|
}
|
|
907
|
-
if (idx === -1)
|
|
931
|
+
if (idx === -1) {
|
|
932
|
+
discardedEndTag = true;
|
|
933
|
+
return;
|
|
934
|
+
}
|
|
908
935
|
cp.openStack.splice(idx, 1);
|
|
909
936
|
const count = cp.tagBalance.get(tag) ?? 0;
|
|
910
937
|
if (count > 0) {
|
|
@@ -1023,6 +1050,9 @@ function processConfirmedLine(cp, ln, text) {
|
|
|
1023
1050
|
cp.p5Tok = { kind: "data" };
|
|
1024
1051
|
}
|
|
1025
1052
|
}
|
|
1053
|
+
if (cp.p5Tok.kind === "comment" && !mdHtml(cp.mdBlock, 2)) {
|
|
1054
|
+
cp.phasePoisonedAt = Math.min(cp.phasePoisonedAt, ln.start);
|
|
1055
|
+
}
|
|
1026
1056
|
if (cp.mdBlock.kind === "html" && cp.mdBlock.type >= 6) cp.mdBlock = { kind: "none" };
|
|
1027
1057
|
cp.blankRun += 1;
|
|
1028
1058
|
cp.lastBlankStart = ln.start;
|
|
@@ -1090,14 +1120,14 @@ function processConfirmedLine(cp, ln, text) {
|
|
|
1090
1120
|
}
|
|
1091
1121
|
}
|
|
1092
1122
|
}
|
|
1093
|
-
const rawFlowStart = ln.indent <= 3 &&
|
|
1123
|
+
const rawFlowStart = ln.indent <= 3 && RAW_CONSTRUCT_START_RE.test(mdTrimStart(ln.text));
|
|
1094
1124
|
const htmlOwnedLine = cp.mdBlock.kind === "html" || rawOpenAtLineStart || rawFlowStart;
|
|
1095
1125
|
const maskingSuppressed = htmlOwnedLine || inRawTextTok(cp.p5Tok);
|
|
1096
1126
|
const { masked, unpaired } = maskingSuppressed ? { masked: null, unpaired: false } : maskIntraLineCodeSpans(ln.text, cp.paragraphHasUnpairedRun);
|
|
1097
1127
|
if (unpaired) cp.paragraphHasUnpairedRun = true;
|
|
1098
1128
|
const scanText = masked ?? ln.text;
|
|
1099
1129
|
const defRawToMicromark = cp.mdBlock.kind === "html" || rawOpenAtLineStart || inRawTextTok(cp.p5Tok);
|
|
1100
|
-
const { validLinkDef } = collectRefLine(cp, ln.start, ln.end, scanText, defRawToMicromark, isBlockStart);
|
|
1130
|
+
const { validLinkDef } = collectRefLine(cp, ln.start, ln.end, scanText, ln.text, defRawToMicromark, isBlockStart);
|
|
1101
1131
|
const rawSpans = [];
|
|
1102
1132
|
let pos = 0;
|
|
1103
1133
|
const poisonRawDivergence = () => {
|
|
@@ -1372,7 +1402,7 @@ function processConfirmedLine(cp, ln, text) {
|
|
|
1372
1402
|
cursor = to;
|
|
1373
1403
|
}
|
|
1374
1404
|
masked2 += scanText.slice(cursor);
|
|
1375
|
-
if (floatingResidue(masked2, bothCommentsOpenAtLineStart).length > 0) {
|
|
1405
|
+
if (floatingResidue(masked2, bothCommentsOpenAtLineStart).length > 0 || discardedEndTag) {
|
|
1376
1406
|
cp.p5SealPending = true;
|
|
1377
1407
|
}
|
|
1378
1408
|
}
|
|
@@ -1425,6 +1455,16 @@ function processConfirmedLine(cp, ln, text) {
|
|
|
1425
1455
|
}
|
|
1426
1456
|
}
|
|
1427
1457
|
}
|
|
1458
|
+
var SCANNER_NAME_LISTS = [
|
|
1459
|
+
["type1", TYPE1_NAMES],
|
|
1460
|
+
["rawText", RAW_TEXT_ELEMENTS],
|
|
1461
|
+
["type6", TYPE6_NAMES],
|
|
1462
|
+
["void", VOID_TAGS],
|
|
1463
|
+
["documentStructure", DOCUMENT_STRUCTURE_NAMES],
|
|
1464
|
+
["tablePart", TABLE_PART_NAMES],
|
|
1465
|
+
["scopeBarrier", SCOPE_BARRIER_NAMES],
|
|
1466
|
+
["foreignRoot", new Set(FOREIGN_ROOT_NAMES)]
|
|
1467
|
+
];
|
|
1428
1468
|
|
|
1429
1469
|
// src/components/incrementalParse/spliceParse.ts
|
|
1430
1470
|
var import_micromark_util_normalize_identifier2 = require("micromark-util-normalize-identifier");
|