@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.cjs +17 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +23 -1
- package/dist/index.d.ts +23 -1
- package/dist/index.dev.cjs +17 -28
- package/dist/index.dev.cjs.map +1 -1
- package/dist/index.dev.js +15 -28
- package/dist/index.dev.js.map +1 -1
- package/dist/index.js +15 -28
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.dev.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])) {
|
|
@@ -4578,21 +4577,7 @@ function convertSingleToDoubleDollar(text) {
|
|
|
4578
4577
|
}
|
|
4579
4578
|
function preprocessLaTeX(str) {
|
|
4580
4579
|
if (!hasLatexTrigger(str)) return str;
|
|
4581
|
-
|
|
4582
|
-
const result = segments.map((segment) => {
|
|
4583
|
-
if (segment.isCode) return segment.text;
|
|
4584
|
-
let text = segment.text;
|
|
4585
|
-
text = escapeMhchemCommands(text);
|
|
4586
|
-
text = escapeCurrencyDollarSigns(text);
|
|
4587
|
-
text = convertLatexDelimiters(text);
|
|
4588
|
-
text = escapeLatexPipes(text);
|
|
4589
|
-
text = escapeLatexPipesInUnclosed(text);
|
|
4590
|
-
text = escapeTextUnderscores(text);
|
|
4591
|
-
text = convertSingleToDoubleDollar(text);
|
|
4592
|
-
text = truncateUnclosedLatexBlock(text);
|
|
4593
|
-
return text;
|
|
4594
|
-
});
|
|
4595
|
-
return result.join("");
|
|
4580
|
+
return processSlice(str, false).out;
|
|
4596
4581
|
}
|
|
4597
4582
|
function hasLatexTrigger(str) {
|
|
4598
4583
|
return str.includes("$") || str.includes("\\[") || str.includes("\\(");
|
|
@@ -4621,7 +4606,7 @@ function hasUnclosedTextCommand(text) {
|
|
|
4621
4606
|
}
|
|
4622
4607
|
var RESIDUAL_OPEN_BRACKET_RE = /(?<!!)\\\[/;
|
|
4623
4608
|
var LEADING_DOUBLE_DOLLAR_RE = /^\s*\$\$/;
|
|
4624
|
-
function
|
|
4609
|
+
function processSlice(slice, probe = true) {
|
|
4625
4610
|
const segments = splitByProtectedRegions(slice);
|
|
4626
4611
|
const parts = [];
|
|
4627
4612
|
let quiescent = true;
|
|
@@ -4745,13 +4730,13 @@ function createIncrementalLatexPreprocessor(options) {
|
|
|
4745
4730
|
};
|
|
4746
4731
|
const cut = findRawSafeCut(active);
|
|
4747
4732
|
if (cut > 0) {
|
|
4748
|
-
const candidate =
|
|
4733
|
+
const candidate = processSlice(active.slice(0, cut));
|
|
4749
4734
|
if (candidate.quiescent) freeze(cut, candidate);
|
|
4750
4735
|
}
|
|
4751
4736
|
nextAttemptLen = advanced || !backoff ? 0 : active.length * 2;
|
|
4752
4737
|
onAttempt?.({ activeLength, frozenBytes });
|
|
4753
4738
|
}
|
|
4754
|
-
const tail =
|
|
4739
|
+
const tail = processSlice(active, false);
|
|
4755
4740
|
const head = tail.truncatedAtSeamStart ? frozenOut.replace(/\s+$/, "") : frozenOut;
|
|
4756
4741
|
const out = head + tail.out;
|
|
4757
4742
|
prevSource = source;
|
|
@@ -4815,6 +4800,8 @@ export {
|
|
|
4815
4800
|
hasLoneSurrogate,
|
|
4816
4801
|
highlight,
|
|
4817
4802
|
isFootnoteSection,
|
|
4803
|
+
isWhitespaceText,
|
|
4804
|
+
lastMeaningfulIdx,
|
|
4818
4805
|
measureStage,
|
|
4819
4806
|
mergeClassNameAllowlist,
|
|
4820
4807
|
normalizeForMatch,
|