acsi-core 0.9.3 → 0.9.4
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 +36 -30
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +36 -30
- package/dist/index.modern.js.map +1 -1
- package/dist/utils/latexExtractor.d.ts +4 -3
- package/package.json +1 -1
package/dist/index.modern.js
CHANGED
|
@@ -1669,33 +1669,42 @@ var CoreTooltip = function CoreTooltip(_ref) {
|
|
|
1669
1669
|
|
|
1670
1670
|
var LatexExtractor = /*#__PURE__*/function () {
|
|
1671
1671
|
function LatexExtractor() {}
|
|
1672
|
-
LatexExtractor.
|
|
1673
|
-
var
|
|
1674
|
-
var
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
var matches = content.match(inlineMathRegex) || [];
|
|
1686
|
-
return matches.map(function (match) {
|
|
1687
|
-
return match.trim();
|
|
1688
|
-
});
|
|
1689
|
-
};
|
|
1690
|
-
LatexExtractor.extractDisplayMath = function extractDisplayMath(content) {
|
|
1691
|
-
var displayMathRegex = /\\\[[^\]]+\\\]/g;
|
|
1692
|
-
var matches = content.match(displayMathRegex) || [];
|
|
1693
|
-
return matches.map(function (match) {
|
|
1694
|
-
return match.trim();
|
|
1695
|
-
});
|
|
1672
|
+
LatexExtractor.ApplyLatexFormat = function ApplyLatexFormat(content) {
|
|
1673
|
+
var allComponents = LatexExtractor.extractAllLatexUltimate(content);
|
|
1674
|
+
var multiLineFormulas = LatexExtractor.extractMultiLineFormulas(content);
|
|
1675
|
+
var foundLatexStr = multiLineFormulas[0] || "";
|
|
1676
|
+
if (foundLatexStr && foundLatexStr !== "" && content.includes(foundLatexStr)) {
|
|
1677
|
+
var firstPosition = content.indexOf(allComponents[0]);
|
|
1678
|
+
if (firstPosition > 0) {
|
|
1679
|
+
var textPart = content.slice(0, firstPosition).trim();
|
|
1680
|
+
var latexPart = content.slice(firstPosition).trim();
|
|
1681
|
+
return textPart + (" $$" + latexPart + "$$");
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
return content.replace(foundLatexStr, "$$" + foundLatexStr + "$$");
|
|
1696
1685
|
};
|
|
1697
1686
|
return LatexExtractor;
|
|
1698
1687
|
}();
|
|
1688
|
+
LatexExtractor.extractAllLatexUltimate = function (content) {
|
|
1689
|
+
var latexRegex = /(\\[a-zA-Z]+\s*\{[^}]*\}(?:\s*\{[^}]*\})*|\\[a-zA-Z]+|\\[a-zA-Z]+\s*[^\\\s\{]+|[a-zA-Z]+\^{[^}]*}|[a-zA-Z]+\_{[^}]*}|\$[^$]+\$|\\\([^)]+\\\)|\\\[[^\]]+\\\]|\\[a-zA-Z]+\d*|(?:\\[a-zA-Z]+\s*)+[^\\]*(?=\\\\|\.|$))/g;
|
|
1690
|
+
var matches = content.match(latexRegex) || [];
|
|
1691
|
+
return matches.map(function (match) {
|
|
1692
|
+
return match.trim();
|
|
1693
|
+
}).filter(function (match) {
|
|
1694
|
+
return match.length > 1 && !match.match(/^[,\s\.]*$/) && (match.includes("\\") || match.includes("^{") || match.includes("_{") || match.includes("$") || !!match.match(/[a-zA-Z]\s*[=+\-*/]\s*[a-zA-Z0-9]/));
|
|
1695
|
+
});
|
|
1696
|
+
};
|
|
1697
|
+
LatexExtractor.extractMultiLineFormulas = function (content) {
|
|
1698
|
+
var formulas = content.split(/\\\\/);
|
|
1699
|
+
return formulas.map(function (formula) {
|
|
1700
|
+
return formula.trim().replace(/\.$/, "");
|
|
1701
|
+
}).filter(function (formula) {
|
|
1702
|
+
return formula.length > 0 && LatexExtractor.isMathFormula(formula);
|
|
1703
|
+
});
|
|
1704
|
+
};
|
|
1705
|
+
LatexExtractor.isMathFormula = function (text) {
|
|
1706
|
+
return !!text && (text.includes("=") || text.includes("\\") || text.includes("^{") || text.includes("_{") || !!text.match(/[a-zA-Z]\s*[=+\-*/]\s*[a-zA-Z0-9]/));
|
|
1707
|
+
};
|
|
1699
1708
|
|
|
1700
1709
|
var _excluded$3 = ["node"];
|
|
1701
1710
|
var MarkdownLatexRender = function MarkdownLatexRender(_ref) {
|
|
@@ -1718,12 +1727,9 @@ function formatContent(content) {
|
|
|
1718
1727
|
var i = 0;
|
|
1719
1728
|
while (i < lines.length) {
|
|
1720
1729
|
var line = lines[i];
|
|
1721
|
-
var
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
});
|
|
1725
|
-
if (newline !== line) {
|
|
1726
|
-
result.push(newline);
|
|
1730
|
+
var appliedLatexFormat = LatexExtractor.ApplyLatexFormat(line);
|
|
1731
|
+
if (appliedLatexFormat !== line) {
|
|
1732
|
+
result.push(appliedLatexFormat);
|
|
1727
1733
|
i++;
|
|
1728
1734
|
continue;
|
|
1729
1735
|
}
|