@ai-react-markdown/engine 2.5.1 → 2.5.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
@@ -1108,6 +1108,15 @@ function isFootnoteSection(node) {
1108
1108
  const props = node.properties;
1109
1109
  return props?.dataFootnotes !== void 0;
1110
1110
  }
1111
+ function isWhitespaceText(c) {
1112
+ return c.type === "text" && /^\s*$/.test(c.value);
1113
+ }
1114
+ function lastMeaningfulIdx(children) {
1115
+ for (let i = children.length - 1; i >= 0; i--) {
1116
+ if (!isWhitespaceText(children[i])) return i;
1117
+ }
1118
+ return -1;
1119
+ }
1111
1120
 
1112
1121
  // src/components/incrementalParse/attributeHastChildren.ts
1113
1122
  function attributeHastChildren(mdast, hast, stopAt = Infinity) {
@@ -1890,16 +1899,6 @@ function isBackrefAnchor(c) {
1890
1899
  if (el.tagName !== "a") return false;
1891
1900
  return Boolean(el.properties && "dataFootnoteBackref" in el.properties);
1892
1901
  }
1893
- function isWhitespaceText(c) {
1894
- if (c.type !== "text") return false;
1895
- return /^\s*$/.test(c.value);
1896
- }
1897
- function lastMeaningfulIdx(children) {
1898
- for (let i = children.length - 1; i >= 0; i--) {
1899
- if (!isWhitespaceText(children[i])) return i;
1900
- }
1901
- return -1;
1902
- }
1903
1902
  function dropTrailingBackrefs(children) {
1904
1903
  let trailingWsStart = children.length;
1905
1904
  while (trailingWsStart > 0 && isWhitespaceText(children[trailingWsStart - 1])) {
@@ -4566,21 +4565,7 @@ function convertSingleToDoubleDollar(text) {
4566
4565
  }
4567
4566
  function preprocessLaTeX(str) {
4568
4567
  if (!hasLatexTrigger(str)) return str;
4569
- const segments = splitByProtectedRegions(str);
4570
- const result = segments.map((segment) => {
4571
- if (segment.isCode) return segment.text;
4572
- let text = segment.text;
4573
- text = escapeMhchemCommands(text);
4574
- text = escapeCurrencyDollarSigns(text);
4575
- text = convertLatexDelimiters(text);
4576
- text = escapeLatexPipes(text);
4577
- text = escapeLatexPipesInUnclosed(text);
4578
- text = escapeTextUnderscores(text);
4579
- text = convertSingleToDoubleDollar(text);
4580
- text = truncateUnclosedLatexBlock(text);
4581
- return text;
4582
- });
4583
- return result.join("");
4568
+ return processSlice(str, false).out;
4584
4569
  }
4585
4570
  function hasLatexTrigger(str) {
4586
4571
  return str.includes("$") || str.includes("\\[") || str.includes("\\(");
@@ -4609,7 +4594,7 @@ function hasUnclosedTextCommand(text) {
4609
4594
  }
4610
4595
  var RESIDUAL_OPEN_BRACKET_RE = /(?<!!)\\\[/;
4611
4596
  var LEADING_DOUBLE_DOLLAR_RE = /^\s*\$\$/;
4612
- function processSliceInstrumented(slice, probe = true) {
4597
+ function processSlice(slice, probe = true) {
4613
4598
  const segments = splitByProtectedRegions(slice);
4614
4599
  const parts = [];
4615
4600
  let quiescent = true;
@@ -4733,13 +4718,13 @@ function createIncrementalLatexPreprocessor(options) {
4733
4718
  };
4734
4719
  const cut = findRawSafeCut(active);
4735
4720
  if (cut > 0) {
4736
- const candidate = processSliceInstrumented(active.slice(0, cut));
4721
+ const candidate = processSlice(active.slice(0, cut));
4737
4722
  if (candidate.quiescent) freeze(cut, candidate);
4738
4723
  }
4739
4724
  nextAttemptLen = advanced || !backoff ? 0 : active.length * 2;
4740
4725
  onAttempt?.({ activeLength, frozenBytes });
4741
4726
  }
4742
- const tail = processSliceInstrumented(active, false);
4727
+ const tail = processSlice(active, false);
4743
4728
  const head = tail.truncatedAtSeamStart ? frozenOut.replace(/\s+$/, "") : frozenOut;
4744
4729
  const out = head + tail.out;
4745
4730
  prevSource = source;
@@ -4803,6 +4788,8 @@ export {
4803
4788
  hasLoneSurrogate,
4804
4789
  highlight,
4805
4790
  isFootnoteSection,
4791
+ isWhitespaceText,
4792
+ lastMeaningfulIdx,
4806
4793
  measureStage,
4807
4794
  mergeClassNameAllowlist,
4808
4795
  normalizeForMatch,