@ai-react-markdown/engine 2.5.0 → 2.5.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 +48 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.dev.cjs +48 -7
- package/dist/index.dev.cjs.map +1 -1
- package/dist/index.dev.js +48 -7
- package/dist/index.dev.js.map +1 -1
- package/dist/index.js +48 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -751,6 +751,7 @@ function processConfirmedLine(cp, ln, text) {
|
|
|
751
751
|
cp.openTotal += 1;
|
|
752
752
|
}
|
|
753
753
|
};
|
|
754
|
+
const strayTablePart = (tag) => TABLE_PART_NAMES.has(tag) && (cp.tagBalance.get("table") ?? 0) === 0;
|
|
754
755
|
const commentOpenAtLineStart = cp.commentOpen;
|
|
755
756
|
const rawOpenAtLineStart = cp.commentOpen || cp.piOpen || cp.declOpen || cp.cdataOpen || cp.bogusOpen;
|
|
756
757
|
if (cp.inFence) {
|
|
@@ -1079,7 +1080,7 @@ ${cont(scanText)}` };
|
|
|
1079
1080
|
if (cp.commentOpen) continue;
|
|
1080
1081
|
const closing = m[1] === "/";
|
|
1081
1082
|
const tag = m[2].toLowerCase();
|
|
1082
|
-
if (
|
|
1083
|
+
if (strayTablePart(tag)) cp.phasePoisonedAt = Math.min(cp.phasePoisonedAt, ln.start + m.index);
|
|
1083
1084
|
let attrs = m[3] ?? "";
|
|
1084
1085
|
if (cp.htmlFlowReal && (cp.rawTextOpen === null || closing && tag === cp.rawTextOpen)) {
|
|
1085
1086
|
const attrStart = m.index + 1 + (closing ? 1 : 0) + m[2].length;
|
|
@@ -1123,7 +1124,7 @@ ${cont(scanText)}` };
|
|
|
1123
1124
|
if (startMasked || wholeVisible || inRaw(mr.index) || cp.commentOpen) continue;
|
|
1124
1125
|
const closing = mr[1] === "/";
|
|
1125
1126
|
const tag = mr[2].toLowerCase();
|
|
1126
|
-
if (
|
|
1127
|
+
if (strayTablePart(tag)) cp.phasePoisonedAt = Math.min(cp.phasePoisonedAt, ln.start + mr.index);
|
|
1127
1128
|
if (closing && mr[3] !== void 0 && !/^\s*$/.test(mr[3])) continue;
|
|
1128
1129
|
const selfClosing = mr[3] !== void 0 && /\/\s*$/.test(mr[3]);
|
|
1129
1130
|
if (VOID_TAGS.has(tag) || selfClosing && honoursSelfClosing(tag)) continue;
|
|
@@ -1131,7 +1132,7 @@ ${cont(scanText)}` };
|
|
|
1131
1132
|
}
|
|
1132
1133
|
}
|
|
1133
1134
|
if (cp.pendingTruncatedTags.length > 0 && ln.text.includes(">")) {
|
|
1134
|
-
if (cp.pendingTruncatedTags.some((t) =>
|
|
1135
|
+
if (cp.pendingTruncatedTags.some((t) => strayTablePart(t))) {
|
|
1135
1136
|
cp.phasePoisonedAt = Math.min(cp.phasePoisonedAt, ln.start);
|
|
1136
1137
|
}
|
|
1137
1138
|
cp.pendingTruncatedTags = [];
|
|
@@ -1148,7 +1149,7 @@ ${cont(scanText)}` };
|
|
|
1148
1149
|
if (m2) {
|
|
1149
1150
|
const closing = m2[1] === "/";
|
|
1150
1151
|
const tag = m2[2].toLowerCase();
|
|
1151
|
-
if (
|
|
1152
|
+
if (strayTablePart(tag) && cp.htmlFlowReal) {
|
|
1152
1153
|
cp.phasePoisonedAt = Math.min(cp.phasePoisonedAt, ln.start + lastLt);
|
|
1153
1154
|
}
|
|
1154
1155
|
if (cp.htmlFlowReal) {
|
|
@@ -1373,6 +1374,24 @@ function rebaseDualWalk(node, segments, maxEnd, offsetDelta, lineDelta) {
|
|
|
1373
1374
|
}
|
|
1374
1375
|
}
|
|
1375
1376
|
var TABLE_PART_TAG_RE = /<(?:td|th|tr|tbody|thead|tfoot|caption|col|colgroup)\b/i;
|
|
1377
|
+
var TABLE_TOKEN_RE = /<(\/?)(table|td|th|tr|tbody|thead|tfoot|caption|col|colgroup)\b/gi;
|
|
1378
|
+
function hasStrayTablePart(values) {
|
|
1379
|
+
let depth = 0;
|
|
1380
|
+
for (const value of values) {
|
|
1381
|
+
TABLE_TOKEN_RE.lastIndex = 0;
|
|
1382
|
+
let m;
|
|
1383
|
+
while ((m = TABLE_TOKEN_RE.exec(value)) !== null) {
|
|
1384
|
+
const closing = m[1] === "/";
|
|
1385
|
+
const tag = m[2].toLowerCase();
|
|
1386
|
+
if (tag === "table") {
|
|
1387
|
+
depth = closing ? Math.max(0, depth - 1) : depth + 1;
|
|
1388
|
+
continue;
|
|
1389
|
+
}
|
|
1390
|
+
if (depth === 0) return true;
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
return false;
|
|
1394
|
+
}
|
|
1376
1395
|
var STRAY_SYNTHESIZED_END_TAG_RE = /<\/(?:br|p)\b/i;
|
|
1377
1396
|
function spliceTrees(input) {
|
|
1378
1397
|
const { prevMdast, prevHast, tailMdast, tailHast, content, boundary, injectionPrefix, injectedSegments } = input;
|
|
@@ -1430,7 +1449,7 @@ function spliceTrees(input) {
|
|
|
1430
1449
|
return !(start !== void 0 && start < injectedLen);
|
|
1431
1450
|
});
|
|
1432
1451
|
const tailWrapVisible = tailMdastChildren.some((child) => !isWrapInvisible(child));
|
|
1433
|
-
if (prefixMdast.
|
|
1452
|
+
if (hasStrayTablePart(prefixMdast.flatMap((c) => c.type === "html" ? [c.value] : []))) return null;
|
|
1434
1453
|
for (const child of tailMdastChildren) {
|
|
1435
1454
|
if (isWrapInvisible(child)) continue;
|
|
1436
1455
|
if (child.type !== "html") break;
|
|
@@ -4088,6 +4107,14 @@ var graphemeEnds = (text, base) => {
|
|
|
4088
4107
|
}
|
|
4089
4108
|
return ends;
|
|
4090
4109
|
};
|
|
4110
|
+
var RESUME_LOOKBACK = 64;
|
|
4111
|
+
var isMidSurrogatePair = (text, at) => at > 0 && at < text.length && (text.charCodeAt(at - 1) & 64512) === 55296 && (text.charCodeAt(at) & 64512) === 56320;
|
|
4112
|
+
var RI_FIRST = 127462;
|
|
4113
|
+
var RI_LAST = 127487;
|
|
4114
|
+
var isRegionalIndicatorAt = (text, at) => {
|
|
4115
|
+
const cp = text.codePointAt(at);
|
|
4116
|
+
return cp !== void 0 && cp >= RI_FIRST && cp <= RI_LAST;
|
|
4117
|
+
};
|
|
4091
4118
|
var createSmoothStreamController = (options = {}) => {
|
|
4092
4119
|
const now = options.now ?? defaultNow;
|
|
4093
4120
|
const schedule = options.schedule ?? defaultSchedule;
|
|
@@ -4096,6 +4123,7 @@ var createSmoothStreamController = (options = {}) => {
|
|
|
4096
4123
|
let pending = [];
|
|
4097
4124
|
let tentativeEnd = 0;
|
|
4098
4125
|
let finished = false;
|
|
4126
|
+
let seam;
|
|
4099
4127
|
let drainDeadlineAt;
|
|
4100
4128
|
let initialized = false;
|
|
4101
4129
|
let visibleCache = "";
|
|
@@ -4179,8 +4207,19 @@ var createSmoothStreamController = (options = {}) => {
|
|
|
4179
4207
|
if (!disposed && !cancelFrame && pending.length > 0) cancelFrame = schedule(tick);
|
|
4180
4208
|
};
|
|
4181
4209
|
const resegmentTail = () => {
|
|
4210
|
+
if (seam !== void 0 && seam < source.length && pending[pending.length - 1] === seam) {
|
|
4211
|
+
pending.pop();
|
|
4212
|
+
}
|
|
4182
4213
|
const from = pending.length > 0 ? pending[pending.length - 1] : visibleEnd;
|
|
4183
|
-
|
|
4214
|
+
let anchor = from;
|
|
4215
|
+
if (seam !== void 0 && from <= seam) {
|
|
4216
|
+
anchor = Math.max(0, from - RESUME_LOOKBACK);
|
|
4217
|
+
if (isMidSurrogatePair(source, anchor)) anchor -= 1;
|
|
4218
|
+
while (anchor >= 2 && isRegionalIndicatorAt(source, anchor - 2)) anchor -= 2;
|
|
4219
|
+
} else {
|
|
4220
|
+
seam = void 0;
|
|
4221
|
+
}
|
|
4222
|
+
const ends = graphemeEnds(source.slice(anchor), anchor);
|
|
4184
4223
|
if (ends.length === 0) {
|
|
4185
4224
|
tentativeEnd = from;
|
|
4186
4225
|
return;
|
|
@@ -4192,7 +4231,7 @@ var createSmoothStreamController = (options = {}) => {
|
|
|
4192
4231
|
if (last >= 55296 && last <= 56319) hold = 2;
|
|
4193
4232
|
}
|
|
4194
4233
|
const confirmedEnds = finished ? ends : ends.slice(0, -hold);
|
|
4195
|
-
for (const end of confirmedEnds) pending.push(end);
|
|
4234
|
+
for (const end of confirmedEnds) if (end > from) pending.push(end);
|
|
4196
4235
|
};
|
|
4197
4236
|
const snap = (next) => {
|
|
4198
4237
|
disposed = false;
|
|
@@ -4206,6 +4245,7 @@ var createSmoothStreamController = (options = {}) => {
|
|
|
4206
4245
|
visibleEnd = next.length;
|
|
4207
4246
|
tentativeEnd = next.length;
|
|
4208
4247
|
pending = [];
|
|
4248
|
+
seam = next.length;
|
|
4209
4249
|
credit = 0;
|
|
4210
4250
|
cancelScheduled();
|
|
4211
4251
|
if (visibleCache !== next) notify();
|
|
@@ -4240,6 +4280,7 @@ var createSmoothStreamController = (options = {}) => {
|
|
|
4240
4280
|
if (tentativeEnd > (pending.length > 0 ? pending[pending.length - 1] : visibleEnd)) {
|
|
4241
4281
|
pending.push(tentativeEnd);
|
|
4242
4282
|
}
|
|
4283
|
+
seam = source.length;
|
|
4243
4284
|
ensureScheduled();
|
|
4244
4285
|
},
|
|
4245
4286
|
snap,
|