@ai-react-markdown/engine 2.5.2 → 2.5.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 +53 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +17 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.dev.cjs +53 -6
- package/dist/index.dev.cjs.map +1 -1
- package/dist/index.dev.js +53 -6
- package/dist/index.dev.js.map +1 -1
- package/dist/index.js +53 -6
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -270,6 +270,26 @@ var import_micromark_util_html_tag_name = require("micromark-util-html-tag-name"
|
|
|
270
270
|
var import_micromark_util_normalize_identifier = require("micromark-util-normalize-identifier");
|
|
271
271
|
var TYPE6_NAMES = new Set(import_micromark_util_html_tag_name.htmlBlockNames);
|
|
272
272
|
var TABLE_PART_NAMES = /* @__PURE__ */ new Set(["td", "th", "tr", "tbody", "thead", "tfoot", "caption", "col", "colgroup"]);
|
|
273
|
+
var DOCUMENT_STRUCTURE_NAMES = /* @__PURE__ */ new Set(["html", "head", "body", "frameset"]);
|
|
274
|
+
var RETROACTIVE_OPENERS = [
|
|
275
|
+
"<!doctype",
|
|
276
|
+
"<html",
|
|
277
|
+
"<head",
|
|
278
|
+
"<body",
|
|
279
|
+
"<frameset",
|
|
280
|
+
"</html",
|
|
281
|
+
"</head",
|
|
282
|
+
"</body",
|
|
283
|
+
"</frameset"
|
|
284
|
+
];
|
|
285
|
+
function tailCarriesRetroactive(text) {
|
|
286
|
+
const lower = text.toLowerCase();
|
|
287
|
+
for (let i = lower.indexOf("<"); i !== -1; i = lower.indexOf("<", i + 1)) {
|
|
288
|
+
const rest = lower.slice(i);
|
|
289
|
+
for (const op of RETROACTIVE_OPENERS) if (rest.startsWith(op)) return true;
|
|
290
|
+
}
|
|
291
|
+
return false;
|
|
292
|
+
}
|
|
273
293
|
var HTML_BREAKOUT_TAGS = /* @__PURE__ */ new Set([
|
|
274
294
|
"b",
|
|
275
295
|
"big",
|
|
@@ -335,6 +355,7 @@ var RAW_TEXT_ELEMENTS = /* @__PURE__ */ new Set([
|
|
|
335
355
|
]);
|
|
336
356
|
var TYPE6_START_RE = /^<\/?([A-Za-z][A-Za-z0-9-]*)(?:[ \t\r]|\/?>|$)/;
|
|
337
357
|
var TYPE1_START_RE = /^<(script|pre|style|textarea)(?:[ \t\r]|>|$)/i;
|
|
358
|
+
var TYPE1_CLOSE_RE = /<\/(?:script|pre|style|textarea)>/i;
|
|
338
359
|
var TYPE7_LINE_RE = /^(?:<[A-Za-z][A-Za-z0-9-]*(?:[ \t\r][^>]*|\/)?>|<\/[A-Za-z][A-Za-z0-9-]*[ \t\r]*>)[ \t\r]*$/;
|
|
339
360
|
var t7Name = (line) => /^<\/?([A-Za-z][A-Za-z0-9-]*)/.exec(line)[1];
|
|
340
361
|
var VOID_TAGS = /* @__PURE__ */ new Set([
|
|
@@ -510,7 +531,9 @@ function freshCheckpoint(defListEnabled, mathFlow, referenceTaint) {
|
|
|
510
531
|
tagAcrossLines: false,
|
|
511
532
|
tagAcrossLinesIndent: 0,
|
|
512
533
|
tagAcrossLinesState: "outside",
|
|
513
|
-
htmlFlowReal: false
|
|
534
|
+
htmlFlowReal: false,
|
|
535
|
+
type1FlowOpen: false,
|
|
536
|
+
rawTextInline: false
|
|
514
537
|
};
|
|
515
538
|
}
|
|
516
539
|
function isPlausibleLinkDefRest(rest) {
|
|
@@ -655,8 +678,9 @@ function computeFreezeBoundary(text, options, resume) {
|
|
|
655
678
|
if (tailLine) return !canBecomeDdLine(tailLine.text, false);
|
|
656
679
|
return false;
|
|
657
680
|
};
|
|
681
|
+
const tailRetroactive = tailLine !== null && tailCarriesRetroactive(tailLine.text);
|
|
658
682
|
let boundary = 0;
|
|
659
|
-
for (let i = cp.candidates.length - 1; i >= 0; i--) {
|
|
683
|
+
for (let i = cp.candidates.length - 1; i >= 0 && !tailRetroactive; i--) {
|
|
660
684
|
const c = cp.candidates[i];
|
|
661
685
|
if (!c.htmlBalanced || c.hazard || c.seamRisk) continue;
|
|
662
686
|
if (c.offset > cp.phasePoisonedAt) continue;
|
|
@@ -740,8 +764,10 @@ function processConfirmedLine(cp, ln, text) {
|
|
|
740
764
|
cp.rawTextOpen = null;
|
|
741
765
|
} else if (!closing && RAW_TEXT_ELEMENTS.has(tag) && htmlRulesApply()) {
|
|
742
766
|
cp.rawTextOpen = tag;
|
|
767
|
+
cp.rawTextInline = !cp.htmlFlowReal;
|
|
743
768
|
if (tag === "plaintext") cp.phasePoisonedAt = Math.min(cp.phasePoisonedAt, ln.start);
|
|
744
769
|
}
|
|
770
|
+
if (DOCUMENT_STRUCTURE_NAMES.has(tag)) cp.phasePoisonedAt = 0;
|
|
745
771
|
if (closing) {
|
|
746
772
|
const count = cp.tagBalance.get(tag) ?? 0;
|
|
747
773
|
if (count > 0) {
|
|
@@ -852,15 +878,22 @@ function processConfirmedLine(cp, ln, text) {
|
|
|
852
878
|
cp.candidates.push({
|
|
853
879
|
offset: Math.min(ln.end + 1, text.length),
|
|
854
880
|
blankRun: cp.blankRun,
|
|
855
|
-
|
|
881
|
+
// `type1FlowOpen`: an unterminated type-1 block swallows this blank
|
|
882
|
+
// and everything after it as RAW content, so nothing here is a block
|
|
883
|
+
// boundary at all. Its tags are invisible to the balance scan
|
|
884
|
+
// (`rawTextOpen` suppresses them), which is exactly why `openTotal`
|
|
885
|
+
// reads 0 and the candidate looked safe.
|
|
886
|
+
htmlBalanced: cp.openTotal === 0 && !cp.commentOpen && !cp.piOpen && !cp.declOpen && !cp.cdataOpen && !cp.bogusOpen && !cp.type1FlowOpen,
|
|
856
887
|
hazard: cp.hazardVerdict,
|
|
857
888
|
seamRisk: cp.htmlSeamPending,
|
|
858
889
|
defListSettled: null
|
|
859
890
|
});
|
|
860
891
|
cp.paragraphHasUnpairedRun = false;
|
|
861
892
|
cp.openBracket = null;
|
|
862
|
-
cp.
|
|
863
|
-
|
|
893
|
+
if (!cp.type1FlowOpen) {
|
|
894
|
+
cp.htmlFlowSinceBlank = false;
|
|
895
|
+
cp.htmlFlowReal = false;
|
|
896
|
+
}
|
|
864
897
|
cp.prevLineBlank = true;
|
|
865
898
|
cp.prevLineWasText = false;
|
|
866
899
|
cp.prevLineWasValidDef = false;
|
|
@@ -874,7 +907,9 @@ function processConfirmedLine(cp, ln, text) {
|
|
|
874
907
|
}
|
|
875
908
|
const tagStart = ln.indent <= 3 ? /^<\/?([A-Za-z][A-Za-z0-9-]*)/.exec(mdTrimStart(ln.text)) : null;
|
|
876
909
|
if (tagStart) {
|
|
910
|
+
const noRealBlockOpen = !cp.htmlFlowReal;
|
|
877
911
|
cp.htmlFlowSinceBlank = true;
|
|
912
|
+
if (noRealBlockOpen && TYPE1_START_RE.test(mdTrimStart(ln.text))) cp.type1FlowOpen = true;
|
|
878
913
|
if (!TYPE6_NAMES.has(tagStart[1].toLowerCase())) cp.hazardVerdict = true;
|
|
879
914
|
if (!cp.htmlFlowReal) {
|
|
880
915
|
const t = mdTrimStart(ln.text);
|
|
@@ -1025,6 +1060,7 @@ ${cont(scanText)}` };
|
|
|
1025
1060
|
pos = pi + 2;
|
|
1026
1061
|
} else {
|
|
1027
1062
|
rawSpans.push([decl, decl + 2]);
|
|
1063
|
+
if (ln.indent <= 3 && /^doctype/i.test(scanText.slice(decl + 2))) cp.phasePoisonedAt = 0;
|
|
1028
1064
|
cp.declOpen = true;
|
|
1029
1065
|
pos = decl + 2;
|
|
1030
1066
|
}
|
|
@@ -1105,7 +1141,10 @@ ${cont(scanText)}` };
|
|
|
1105
1141
|
TAG_OR_COMMENT_RE.lastIndex = gt + 1;
|
|
1106
1142
|
}
|
|
1107
1143
|
}
|
|
1108
|
-
if (closing && !cp.htmlFlowReal && !/^\s*$/.test(attrs))
|
|
1144
|
+
if (closing && !cp.htmlFlowReal && !/^\s*$/.test(attrs)) {
|
|
1145
|
+
TAG_OR_COMMENT_RE.lastIndex = m.index + 2 + m[2].length;
|
|
1146
|
+
continue;
|
|
1147
|
+
}
|
|
1109
1148
|
const selfClosing = /\/\s*$/.test(attrs);
|
|
1110
1149
|
if (VOID_TAGS.has(tag) || selfClosing && honoursSelfClosing(tag)) continue;
|
|
1111
1150
|
applyTag(tag, closing);
|
|
@@ -1186,6 +1225,14 @@ ${cont(scanText)}` };
|
|
|
1186
1225
|
cp.htmlSeamPending = true;
|
|
1187
1226
|
}
|
|
1188
1227
|
}
|
|
1228
|
+
if (cp.rawTextOpen !== null && cp.rawTextInline) {
|
|
1229
|
+
cp.phasePoisonedAt = Math.min(cp.phasePoisonedAt, ln.start);
|
|
1230
|
+
}
|
|
1231
|
+
if (cp.type1FlowOpen && TYPE1_CLOSE_RE.test(ln.text)) {
|
|
1232
|
+
cp.type1FlowOpen = false;
|
|
1233
|
+
cp.htmlFlowSinceBlank = false;
|
|
1234
|
+
cp.htmlFlowReal = false;
|
|
1235
|
+
}
|
|
1189
1236
|
cp.blankRun = 0;
|
|
1190
1237
|
cp.prevLineBlank = false;
|
|
1191
1238
|
cp.prevLineWasText = true;
|