@ai-react-markdown/engine 2.8.1 → 2.8.2

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.js CHANGED
@@ -773,7 +773,7 @@ function processConfirmedLine(cp, ln, text) {
773
773
  }
774
774
  const isBlockStart = cp.prevLineBlank;
775
775
  if (cp.p5SealPending && !ln.blank && cp.mdBlock.kind !== "html" && !(cp.p5Tok.kind === "comment" || cp.p5Tok.kind === "bogus")) {
776
- const defShapedLine = DEF_RE.test(ln.text) || FOOTNOTE_DEF_RE.test(ln.text) || cp.defBlockMaybeOpen || cp.fnDefResumable && ln.indent >= 4;
776
+ const defShapedLine = DEF_RE.test(ln.text) || FOOTNOTE_DEF_RE.test(ln.text) || cp.defBlockMaybeOpen || cp.fnDefResumable && !(isBlockStart && ln.indent <= 3);
777
777
  const commentOnly = ln.text.replace(/<!--[\s\S]*?-->/g, " ").replace(/<!--[\s\S]*$/, " ").replace(/[ \t\r]/g, "") === "";
778
778
  const closeTagOnly = CLOSE_TAG_ONLY_RE.test(ln.text);
779
779
  if (!defShapedLine && !commentOnly && !closeTagOnly) {
@@ -977,7 +977,7 @@ function processConfirmedLine(cp, ln, text) {
977
977
  if (tagStart) {
978
978
  const noRealBlockOpen = cp.mdBlock.kind !== "html";
979
979
  const t1 = noRealBlockOpen ? TYPE1_START_RE.exec(mdTrimStart(ln.text)) : null;
980
- if (t1) cp.mdBlock = { kind: "html", type: 1, raw: RAW_TEXT_ELEMENTS.has(t1[1].toLowerCase()) };
980
+ if (t1) cp.mdBlock = { kind: "html", type: 1, raw: RAW_TEXT_ELEMENTS.has(t1[1].toLowerCase()), indent: ln.indent };
981
981
  if (cp.mdBlock.kind !== "html") {
982
982
  const t = mdTrimStart(ln.text);
983
983
  const t6 = TYPE6_START_RE.exec(t);
@@ -992,7 +992,7 @@ function processConfirmedLine(cp, ln, text) {
992
992
  // raw-text names (`</style>` alone is type 7, measured) and
993
993
  // quoted-`>` attribute values.
994
994
  !cp.prevLineOpenContent && type7Shaped) {
995
- if (cp.mdBlock.kind === "none") cp.mdBlock = { kind: "html", type: realT6 ? 6 : 7 };
995
+ if (cp.mdBlock.kind === "none") cp.mdBlock = { kind: "html", type: realT6 ? 6 : 7, indent: ln.indent };
996
996
  } else if (cp.prevLineOpenContent && cp.tableMaybeOpen && type7Shaped) {
997
997
  cp.phasePoisonedAt = Math.min(cp.phasePoisonedAt, ln.start);
998
998
  }
@@ -1084,7 +1084,7 @@ function processConfirmedLine(cp, ln, text) {
1084
1084
  pos = bogus + 2;
1085
1085
  } else if (first === cd) {
1086
1086
  rawSpans.push([cd, cd + 9]);
1087
- if (cp.mdBlock.kind === "none") cp.mdBlock = { kind: "html", type: 5 };
1087
+ if (cp.mdBlock.kind === "none") cp.mdBlock = { kind: "html", type: 5, indent: ln.indent };
1088
1088
  if (cp.p5Tok.kind === "data") cp.p5Tok = { kind: "bogus" };
1089
1089
  if (!isMdBlank(scanText.slice(0, cd)) || ln.indent > 3) inlineRawOpenerIdx = cd;
1090
1090
  pos = cd + 9;
@@ -1096,14 +1096,14 @@ function processConfirmedLine(cp, ln, text) {
1096
1096
  continue;
1097
1097
  }
1098
1098
  rawSpans.push([pi, pi + 2]);
1099
- if (cp.mdBlock.kind === "none") cp.mdBlock = { kind: "html", type: 3 };
1099
+ if (cp.mdBlock.kind === "none") cp.mdBlock = { kind: "html", type: 3, indent: ln.indent };
1100
1100
  if (cp.p5Tok.kind === "data") cp.p5Tok = { kind: "bogus" };
1101
1101
  if (!isMdBlank(scanText.slice(0, pi)) || ln.indent > 3) inlineRawOpenerIdx = pi;
1102
1102
  pos = pi + 2;
1103
1103
  } else {
1104
1104
  rawSpans.push([decl, decl + 2]);
1105
1105
  if (ln.indent <= 3 && /^doctype/i.test(scanText.slice(decl + 2))) cp.phasePoisonedAt = 0;
1106
- if (cp.mdBlock.kind === "none") cp.mdBlock = { kind: "html", type: 4 };
1106
+ if (cp.mdBlock.kind === "none") cp.mdBlock = { kind: "html", type: 4, indent: ln.indent };
1107
1107
  if (cp.p5Tok.kind === "data") cp.p5Tok = { kind: "bogus" };
1108
1108
  if (!isMdBlank(scanText.slice(0, decl)) || ln.indent > 3) inlineRawOpenerIdx = decl;
1109
1109
  pos = decl + 2;
@@ -1162,7 +1162,7 @@ function processConfirmedLine(cp, ln, text) {
1162
1162
  if (next.startsWith(">") || next === "->") {
1163
1163
  continue;
1164
1164
  }
1165
- if (cp.mdBlock.kind === "none") cp.mdBlock = { kind: "html", type: 2 };
1165
+ if (cp.mdBlock.kind === "none") cp.mdBlock = { kind: "html", type: 2, indent: ln.indent };
1166
1166
  if (cp.p5Tok.kind === "data") cp.p5Tok = { kind: "comment" };
1167
1167
  lastCommentOpenerIdx = m.index;
1168
1168
  continue;
@@ -1322,6 +1322,19 @@ function processConfirmedLine(cp, ln, text) {
1322
1322
  cp.defBlockMaybeOpen = cp.defBlockMaybeOpen || DEF_RE.test(ln.text) || FOOTNOTE_DEF_RE.test(ln.text);
1323
1323
  if (FOOTNOTE_DEF_RE.test(ln.text)) cp.fnDefResumable = true;
1324
1324
  else if (isBlockStart && ln.indent <= 3) cp.fnDefResumable = false;
1325
+ const isBarrier = (name) => SCOPE_BARRIER_NAMES.has(name);
1326
+ const topLevelHtmlBlock = cp.mdBlock.kind === "html" && cp.mdBlock.indent === 0;
1327
+ const confirmedBarriers = cp.openStack.filter(isBarrier).length - cp.pendingTruncatedTags.filter(isBarrier).length;
1328
+ if (!topLevelHtmlBlock && confirmedBarriers > 0) {
1329
+ cp.phasePoisonedAt = Math.min(cp.phasePoisonedAt, ln.start);
1330
+ }
1331
+ const maskUnbacked = mdType1RawText(cp.mdBlock) && !inRawTextTok(cp.p5Tok);
1332
+ if (maskUnbacked) {
1333
+ cp.phasePoisonedAt = Math.min(cp.phasePoisonedAt, ln.start);
1334
+ if (tailCarriesRetroactive(ln.text) || /<template(?![a-z0-9-])/i.test(ln.text)) {
1335
+ cp.phasePoisonedAt = 0;
1336
+ }
1337
+ }
1325
1338
  }
1326
1339
 
1327
1340
  // src/components/incrementalParse/spliceParse.ts