@ai-react-markdown/engine 2.8.2 → 2.9.1
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 +70 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.dev.cjs +76 -21
- package/dist/index.dev.cjs.map +1 -1
- package/dist/index.dev.js +76 -21
- package/dist/index.dev.js.map +1 -1
- package/dist/index.js +70 -22
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.dev.js
CHANGED
|
@@ -289,9 +289,9 @@ function inlineResourceEnd(text, openIdx) {
|
|
|
289
289
|
}
|
|
290
290
|
return -1;
|
|
291
291
|
}
|
|
292
|
-
function collectRefLine(cp, lnStart, lnEnd, scanText, inRawText, isBlockStart) {
|
|
293
|
-
const defShaped = inRawText ? null : DEF_RE.exec(
|
|
294
|
-
const def = defShaped !== null && (defShaped[1].startsWith("^") || isPlausibleLinkDefRest(
|
|
292
|
+
function collectRefLine(cp, lnStart, lnEnd, scanText, rawText, inRawText, isBlockStart) {
|
|
293
|
+
const defShaped = inRawText ? null : DEF_RE.exec(rawText);
|
|
294
|
+
const def = defShaped !== null && (defShaped[1].startsWith("^") || isPlausibleLinkDefRest(rawText.slice(defShaped.index + defShaped[0].length))) ? defShaped : null;
|
|
295
295
|
const defLineStart = isBlockStart || !cp.prevLineWasText || cp.prevLineWasValidDef;
|
|
296
296
|
const validDef = def !== null && defLineStart;
|
|
297
297
|
if (validDef) {
|
|
@@ -370,16 +370,15 @@ function settleRefsAndEarliestUnresolved(cp) {
|
|
|
370
370
|
var TYPE6_NAMES = new Set(htmlBlockNames);
|
|
371
371
|
var TABLE_PART_NAMES = /* @__PURE__ */ new Set(["td", "th", "tr", "tbody", "thead", "tfoot", "caption", "col", "colgroup"]);
|
|
372
372
|
var DOCUMENT_STRUCTURE_NAMES = /* @__PURE__ */ new Set(["html", "head", "body", "frameset"]);
|
|
373
|
+
var NO_ELEMENT_NAMES = /* @__PURE__ */ new Set([...DOCUMENT_STRUCTURE_NAMES, "frame", "image"]);
|
|
373
374
|
var RETROACTIVE_OPENERS = [
|
|
374
375
|
"<!doctype",
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
"</body",
|
|
382
|
-
"</frameset"
|
|
376
|
+
// DERIVED, so the trailing-partial guard cannot drift from the poison the
|
|
377
|
+
// confirmed lines get. It was transcribed until F28, and the transcription
|
|
378
|
+
// was already two names behind by then. `<frame` subsumes `<frameset`,
|
|
379
|
+
// which is why the derived list is SHORTER than the one it replaces and
|
|
380
|
+
// still covers strictly more.
|
|
381
|
+
...[...NO_ELEMENT_NAMES].flatMap((name) => [`<${name}`, `</${name}`])
|
|
383
382
|
];
|
|
384
383
|
function tailCarriesRetroactive(text) {
|
|
385
384
|
const lower = text.toLowerCase();
|
|
@@ -509,12 +508,15 @@ var rawTextElement = (t) => t.kind === "rawText" ? t.element : t.kind === "scrip
|
|
|
509
508
|
var VOID_TAGS = /* @__PURE__ */ new Set([
|
|
510
509
|
"area",
|
|
511
510
|
"base",
|
|
511
|
+
"basefont",
|
|
512
|
+
"bgsound",
|
|
512
513
|
"br",
|
|
513
514
|
"col",
|
|
514
515
|
"embed",
|
|
515
516
|
"hr",
|
|
516
517
|
"img",
|
|
517
518
|
"input",
|
|
519
|
+
"keygen",
|
|
518
520
|
"link",
|
|
519
521
|
"meta",
|
|
520
522
|
"param",
|
|
@@ -629,6 +631,7 @@ function freshCheckpoint(defListEnabled, mathFlow, referenceTaint) {
|
|
|
629
631
|
tagBalance: /* @__PURE__ */ new Map(),
|
|
630
632
|
openTotal: 0,
|
|
631
633
|
p5Tok: { kind: "data" },
|
|
634
|
+
formPointerMaybeSet: false,
|
|
632
635
|
openStack: [],
|
|
633
636
|
mdBlock: { kind: "none" },
|
|
634
637
|
blankRun: 0,
|
|
@@ -766,6 +769,25 @@ function floatingResidue(text, commentOpenAtStart) {
|
|
|
766
769
|
if (!open) out += text.slice(last);
|
|
767
770
|
return out;
|
|
768
771
|
}
|
|
772
|
+
var RAW_CONSTRUCT_START_RE = /^<(?:!--|\?|![A-Za-z]|!\[CDATA\[)/;
|
|
773
|
+
var sealResumableAbove = (cp) => cp.defBlockMaybeOpen || cp.fnDefResumable || cp.containerMaybeOpen;
|
|
774
|
+
function sealReleaseDerived(cp, ln, isBlockStart) {
|
|
775
|
+
if (sealResumableAbove(cp) && !(isBlockStart && ln.indent <= 3)) return false;
|
|
776
|
+
if (cp.prevLineOpenContent) return false;
|
|
777
|
+
if (cp.tableMaybeOpen) return false;
|
|
778
|
+
const head = mdTrimStart(ln.text);
|
|
779
|
+
if (RAW_CONSTRUCT_START_RE.test(head) || TYPE1_START_RE.test(head) || isType7Line(head)) return false;
|
|
780
|
+
const t6 = TYPE6_START_RE.exec(head);
|
|
781
|
+
if (t6 !== null && TYPE6_NAMES.has(t6[1].toLowerCase())) return false;
|
|
782
|
+
if (DEF_RE.test(ln.text) || FOOTNOTE_DEF_RE.test(ln.text)) return false;
|
|
783
|
+
return true;
|
|
784
|
+
}
|
|
785
|
+
var sealReleaseEvaluations = 0;
|
|
786
|
+
function sealReleaseEnumerated(cp, ln, isBlockStart) {
|
|
787
|
+
const defShapedLine = DEF_RE.test(ln.text) || FOOTNOTE_DEF_RE.test(ln.text) || cp.defBlockMaybeOpen || cp.fnDefResumable && !(isBlockStart && ln.indent <= 3);
|
|
788
|
+
const commentOnly = ln.text.replace(/<!--[\s\S]*?-->/g, " ").replace(/<!--[\s\S]*$/, " ").replace(/[ \t\r]/g, "") === "";
|
|
789
|
+
return !defShapedLine && !commentOnly && !CLOSE_TAG_ONLY_RE.test(ln.text);
|
|
790
|
+
}
|
|
769
791
|
function processConfirmedLine(cp, ln, text) {
|
|
770
792
|
const newest = cp.candidates[cp.candidates.length - 1];
|
|
771
793
|
if (newest && newest.defListSettled === null) {
|
|
@@ -773,16 +795,22 @@ function processConfirmedLine(cp, ln, text) {
|
|
|
773
795
|
}
|
|
774
796
|
const isBlockStart = cp.prevLineBlank;
|
|
775
797
|
if (cp.p5SealPending && !ln.blank && cp.mdBlock.kind !== "html" && !(cp.p5Tok.kind === "comment" || cp.p5Tok.kind === "bogus")) {
|
|
776
|
-
|
|
777
|
-
const commentOnly = ln.text.replace(/<!--[\s\S]*?-->/g, " ").replace(/<!--[\s\S]*$/, " ").replace(/[ \t\r]/g, "") === "";
|
|
778
|
-
const closeTagOnly = CLOSE_TAG_ONLY_RE.test(ln.text);
|
|
779
|
-
if (!defShapedLine && !commentOnly && !closeTagOnly) {
|
|
798
|
+
if (sealReleaseDerived(cp, ln, isBlockStart)) {
|
|
780
799
|
cp.p5SealPending = false;
|
|
800
|
+
if (true) {
|
|
801
|
+
sealReleaseEvaluations += 1;
|
|
802
|
+
if (!sealReleaseEnumerated(cp, ln, isBlockStart)) {
|
|
803
|
+
console.error(
|
|
804
|
+
`[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))}).`
|
|
805
|
+
);
|
|
806
|
+
}
|
|
807
|
+
}
|
|
781
808
|
}
|
|
782
809
|
}
|
|
783
810
|
const possiblyInsideForeign = () => FOREIGN_ROOT_NAMES.some((name) => (cp.tagBalance.get(name) ?? 0) > 0);
|
|
784
811
|
const honoursSelfClosing = (tag) => tag === "svg" || tag === "math";
|
|
785
812
|
const foreignRawTextSwitchUnknowable = () => possiblyInsideForeign();
|
|
813
|
+
let discardedEndTag = false;
|
|
786
814
|
const applyTag = (tag, closing) => {
|
|
787
815
|
if (inRawTextTok(cp.p5Tok)) {
|
|
788
816
|
if (cp.p5Tok.kind === "script" && cp.p5Tok.escaped && !closing && tag === "script") {
|
|
@@ -804,7 +832,7 @@ function processConfirmedLine(cp, ln, text) {
|
|
|
804
832
|
if (tag === "plaintext") cp.phasePoisonedAt = Math.min(cp.phasePoisonedAt, ln.start);
|
|
805
833
|
}
|
|
806
834
|
}
|
|
807
|
-
if (
|
|
835
|
+
if (NO_ELEMENT_NAMES.has(tag)) cp.phasePoisonedAt = 0;
|
|
808
836
|
if (tag === "template" && !closing) cp.phasePoisonedAt = 0;
|
|
809
837
|
if (closing) {
|
|
810
838
|
let idx = -1;
|
|
@@ -815,14 +843,19 @@ function processConfirmedLine(cp, ln, text) {
|
|
|
815
843
|
}
|
|
816
844
|
if (SCOPE_BARRIER_NAMES.has(cp.openStack[i])) break;
|
|
817
845
|
}
|
|
818
|
-
if (idx === -1)
|
|
846
|
+
if (idx === -1) {
|
|
847
|
+
discardedEndTag = true;
|
|
848
|
+
return;
|
|
849
|
+
}
|
|
819
850
|
cp.openStack.splice(idx, 1);
|
|
851
|
+
if (tag === "form") cp.formPointerMaybeSet = false;
|
|
820
852
|
const count = cp.tagBalance.get(tag) ?? 0;
|
|
821
853
|
if (count > 0) {
|
|
822
854
|
cp.tagBalance.set(tag, count - 1);
|
|
823
855
|
cp.openTotal -= 1;
|
|
824
856
|
}
|
|
825
857
|
} else {
|
|
858
|
+
if (tag === "form") cp.formPointerMaybeSet = true;
|
|
826
859
|
cp.openStack.push(tag);
|
|
827
860
|
cp.tagBalance.set(tag, (cp.tagBalance.get(tag) ?? 0) + 1);
|
|
828
861
|
cp.openTotal += 1;
|
|
@@ -934,6 +967,9 @@ function processConfirmedLine(cp, ln, text) {
|
|
|
934
967
|
cp.p5Tok = { kind: "data" };
|
|
935
968
|
}
|
|
936
969
|
}
|
|
970
|
+
if (cp.p5Tok.kind === "comment" && !mdHtml(cp.mdBlock, 2)) {
|
|
971
|
+
cp.phasePoisonedAt = Math.min(cp.phasePoisonedAt, ln.start);
|
|
972
|
+
}
|
|
937
973
|
if (cp.mdBlock.kind === "html" && cp.mdBlock.type >= 6) cp.mdBlock = { kind: "none" };
|
|
938
974
|
cp.blankRun += 1;
|
|
939
975
|
cp.lastBlankStart = ln.start;
|
|
@@ -946,7 +982,11 @@ function processConfirmedLine(cp, ln, text) {
|
|
|
946
982
|
// mask suppresses them — which is exactly why `openTotal` reads 0
|
|
947
983
|
// and the candidate looked safe), and the 2-5 interiors are the
|
|
948
984
|
// same construct to both grammars.
|
|
949
|
-
htmlBalanced: cp.openTotal === 0 && cp.mdBlock.kind !== "html" && cp.p5Tok.kind !== "bogus"
|
|
985
|
+
htmlBalanced: cp.openTotal === 0 && cp.mdBlock.kind !== "html" && cp.p5Tok.kind !== "bogus" && // A form pointer parse5 may still be holding makes a LATER `<form>`
|
|
986
|
+
// in the tail vanish from the full parse while a split parse opens
|
|
987
|
+
// it — forward independence fails with every other condition clean.
|
|
988
|
+
// See the field doc.
|
|
989
|
+
!cp.formPointerMaybeSet,
|
|
950
990
|
hazard: cp.hazardVerdict,
|
|
951
991
|
seamRisk: cp.p5SealPending,
|
|
952
992
|
defListSettled: null
|
|
@@ -1001,14 +1041,14 @@ function processConfirmedLine(cp, ln, text) {
|
|
|
1001
1041
|
}
|
|
1002
1042
|
}
|
|
1003
1043
|
}
|
|
1004
|
-
const rawFlowStart = ln.indent <= 3 &&
|
|
1044
|
+
const rawFlowStart = ln.indent <= 3 && RAW_CONSTRUCT_START_RE.test(mdTrimStart(ln.text));
|
|
1005
1045
|
const htmlOwnedLine = cp.mdBlock.kind === "html" || rawOpenAtLineStart || rawFlowStart;
|
|
1006
1046
|
const maskingSuppressed = htmlOwnedLine || inRawTextTok(cp.p5Tok);
|
|
1007
1047
|
const { masked, unpaired } = maskingSuppressed ? { masked: null, unpaired: false } : maskIntraLineCodeSpans(ln.text, cp.paragraphHasUnpairedRun);
|
|
1008
1048
|
if (unpaired) cp.paragraphHasUnpairedRun = true;
|
|
1009
1049
|
const scanText = masked ?? ln.text;
|
|
1010
1050
|
const defRawToMicromark = cp.mdBlock.kind === "html" || rawOpenAtLineStart || inRawTextTok(cp.p5Tok);
|
|
1011
|
-
const { validLinkDef } = collectRefLine(cp, ln.start, ln.end, scanText, defRawToMicromark, isBlockStart);
|
|
1051
|
+
const { validLinkDef } = collectRefLine(cp, ln.start, ln.end, scanText, ln.text, defRawToMicromark, isBlockStart);
|
|
1012
1052
|
const rawSpans = [];
|
|
1013
1053
|
let pos = 0;
|
|
1014
1054
|
const poisonRawDivergence = () => {
|
|
@@ -1283,7 +1323,7 @@ function processConfirmedLine(cp, ln, text) {
|
|
|
1283
1323
|
cursor = to;
|
|
1284
1324
|
}
|
|
1285
1325
|
masked2 += scanText.slice(cursor);
|
|
1286
|
-
if (floatingResidue(masked2, bothCommentsOpenAtLineStart).length > 0) {
|
|
1326
|
+
if (floatingResidue(masked2, bothCommentsOpenAtLineStart).length > 0 || discardedEndTag) {
|
|
1287
1327
|
cp.p5SealPending = true;
|
|
1288
1328
|
}
|
|
1289
1329
|
}
|
|
@@ -1336,6 +1376,21 @@ function processConfirmedLine(cp, ln, text) {
|
|
|
1336
1376
|
}
|
|
1337
1377
|
}
|
|
1338
1378
|
}
|
|
1379
|
+
var SCANNER_NAME_LISTS = [
|
|
1380
|
+
["type1", TYPE1_NAMES],
|
|
1381
|
+
["rawText", RAW_TEXT_ELEMENTS],
|
|
1382
|
+
["type6", TYPE6_NAMES],
|
|
1383
|
+
["void", VOID_TAGS],
|
|
1384
|
+
["documentStructure", DOCUMENT_STRUCTURE_NAMES],
|
|
1385
|
+
// Added with F28, and it is the list that would have made F28 visible: the
|
|
1386
|
+
// derived census alphabet partitions names by their membership across THIS
|
|
1387
|
+
// table, so before it existed `frame` shared one 39-name class with `div`
|
|
1388
|
+
// and could never be sampled apart from it.
|
|
1389
|
+
["noElement", NO_ELEMENT_NAMES],
|
|
1390
|
+
["tablePart", TABLE_PART_NAMES],
|
|
1391
|
+
["scopeBarrier", SCOPE_BARRIER_NAMES],
|
|
1392
|
+
["foreignRoot", new Set(FOREIGN_ROOT_NAMES)]
|
|
1393
|
+
];
|
|
1339
1394
|
|
|
1340
1395
|
// src/components/incrementalParse/spliceParse.ts
|
|
1341
1396
|
import { normalizeIdentifier as normalizeIdentifier2 } from "micromark-util-normalize-identifier";
|