@ai-react-markdown/core 1.2.7 → 1.2.9
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 +10 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +10 -28
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1669,29 +1669,24 @@ function escapeLatexPipes(text) {
|
|
|
1669
1669
|
return match;
|
|
1670
1670
|
});
|
|
1671
1671
|
}
|
|
1672
|
-
function
|
|
1672
|
+
function findUnclosedDelimiterStart(text, mode) {
|
|
1673
1673
|
let unclosedStart = -1;
|
|
1674
1674
|
let i = 0;
|
|
1675
1675
|
while (i < text.length) {
|
|
1676
1676
|
if (text[i] === "$" && i + 1 < text.length && text[i + 1] === "$") {
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
unclosedStart = -1;
|
|
1682
|
-
i += 2;
|
|
1683
|
-
}
|
|
1684
|
-
} else if (text[i] === "$" && (i === 0 || text[i - 1] !== "\\") && (i + 1 >= text.length || text[i + 1] !== "$")) {
|
|
1685
|
-
if (unclosedStart === -1) {
|
|
1686
|
-
unclosedStart = i;
|
|
1687
|
-
} else {
|
|
1688
|
-
unclosedStart = -1;
|
|
1689
|
-
}
|
|
1677
|
+
unclosedStart = unclosedStart === -1 ? i : -1;
|
|
1678
|
+
i += 2;
|
|
1679
|
+
} else if (mode === "both" && text[i] === "$" && (i === 0 || text[i - 1] !== "\\") && (i + 1 >= text.length || text[i + 1] !== "$")) {
|
|
1680
|
+
unclosedStart = unclosedStart === -1 ? i : -1;
|
|
1690
1681
|
i += 1;
|
|
1691
1682
|
} else {
|
|
1692
1683
|
i += 1;
|
|
1693
1684
|
}
|
|
1694
1685
|
}
|
|
1686
|
+
return unclosedStart;
|
|
1687
|
+
}
|
|
1688
|
+
function escapeLatexPipesInUnclosed(text) {
|
|
1689
|
+
const unclosedStart = findUnclosedDelimiterStart(text, "both");
|
|
1695
1690
|
if (unclosedStart === -1) return text;
|
|
1696
1691
|
const before = text.substring(0, unclosedStart);
|
|
1697
1692
|
const delimLen = text[unclosedStart + 1] === "$" ? 2 : 1;
|
|
@@ -1700,20 +1695,7 @@ function escapeLatexPipesInUnclosed(text) {
|
|
|
1700
1695
|
return before + delim + replaceUnescapedPipes(tail);
|
|
1701
1696
|
}
|
|
1702
1697
|
function truncateUnclosedLatexBlock(text) {
|
|
1703
|
-
|
|
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
|
-
}
|
|
1698
|
+
const unclosedStart = findUnclosedDelimiterStart(text, "double-only");
|
|
1717
1699
|
if (unclosedStart === -1) return text;
|
|
1718
1700
|
return text.substring(0, unclosedStart).trimEnd();
|
|
1719
1701
|
}
|