@ai-react-markdown/core 1.2.6 → 1.2.7
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 +19 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1699,6 +1699,24 @@ function escapeLatexPipesInUnclosed(text) {
|
|
|
1699
1699
|
const tail = text.substring(unclosedStart + delimLen);
|
|
1700
1700
|
return before + delim + replaceUnescapedPipes(tail);
|
|
1701
1701
|
}
|
|
1702
|
+
function truncateUnclosedLatexBlock(text) {
|
|
1703
|
+
let unclosedStart = -1;
|
|
1704
|
+
let i = 0;
|
|
1705
|
+
while (i < text.length) {
|
|
1706
|
+
if (text[i] === "$" && i + 1 < text.length && text[i + 1] === "$") {
|
|
1707
|
+
if (unclosedStart === -1) {
|
|
1708
|
+
unclosedStart = i;
|
|
1709
|
+
} else {
|
|
1710
|
+
unclosedStart = -1;
|
|
1711
|
+
}
|
|
1712
|
+
i += 2;
|
|
1713
|
+
} else {
|
|
1714
|
+
i += 1;
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
if (unclosedStart === -1) return text;
|
|
1718
|
+
return text.substring(0, unclosedStart).trimEnd();
|
|
1719
|
+
}
|
|
1702
1720
|
function escapeTextUnderscores(text) {
|
|
1703
1721
|
return text.replaceAll(ESCAPE_TEXT_UNDERSCORES_REGEX, (_match, textContent) => {
|
|
1704
1722
|
const escapedTextContent = textContent.replaceAll(/(?<!\\)_/g, "\\_");
|
|
@@ -1721,6 +1739,7 @@ function preprocessLaTeX(str) {
|
|
|
1721
1739
|
text = escapeLatexPipesInUnclosed(text);
|
|
1722
1740
|
text = escapeTextUnderscores(text);
|
|
1723
1741
|
text = convertSingleToDoubleDollar(text);
|
|
1742
|
+
text = truncateUnclosedLatexBlock(text);
|
|
1724
1743
|
return text;
|
|
1725
1744
|
});
|
|
1726
1745
|
return result.join("");
|