acsi-core 0.9.4 → 0.9.6
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 +7 -6
- package/dist/index.js.map +1 -1
- package/dist/index.modern.js +7 -6
- package/dist/index.modern.js.map +1 -1
- package/package.json +1 -1
package/dist/index.modern.js
CHANGED
|
@@ -1673,31 +1673,32 @@ var LatexExtractor = /*#__PURE__*/function () {
|
|
|
1673
1673
|
var allComponents = LatexExtractor.extractAllLatexUltimate(content);
|
|
1674
1674
|
var multiLineFormulas = LatexExtractor.extractMultiLineFormulas(content);
|
|
1675
1675
|
var foundLatexStr = multiLineFormulas[0] || "";
|
|
1676
|
-
if (foundLatexStr && foundLatexStr !== "" &&
|
|
1676
|
+
if (foundLatexStr && foundLatexStr !== "" && allComponents.length > 0) {
|
|
1677
1677
|
var firstPosition = content.indexOf(allComponents[0]);
|
|
1678
1678
|
if (firstPosition > 0) {
|
|
1679
1679
|
var textPart = content.slice(0, firstPosition).trim();
|
|
1680
1680
|
var latexPart = content.slice(firstPosition).trim();
|
|
1681
1681
|
return textPart + (" $$" + latexPart + "$$");
|
|
1682
1682
|
}
|
|
1683
|
+
return content.replace(foundLatexStr, "$$" + foundLatexStr + "$$");
|
|
1683
1684
|
}
|
|
1684
|
-
return content
|
|
1685
|
+
return content;
|
|
1685
1686
|
};
|
|
1686
1687
|
return LatexExtractor;
|
|
1687
1688
|
}();
|
|
1688
1689
|
LatexExtractor.extractAllLatexUltimate = function (content) {
|
|
1689
1690
|
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
1691
|
var matches = content.match(latexRegex) || [];
|
|
1691
|
-
return matches.
|
|
1692
|
-
return match.trim();
|
|
1693
|
-
}).filter(function (match) {
|
|
1692
|
+
return matches.filter(function (match) {
|
|
1694
1693
|
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
1694
|
});
|
|
1696
1695
|
};
|
|
1697
1696
|
LatexExtractor.extractMultiLineFormulas = function (content) {
|
|
1698
1697
|
var formulas = content.split(/\\\\/);
|
|
1699
1698
|
return formulas.map(function (formula) {
|
|
1700
|
-
|
|
1699
|
+
var cleaned = formula.trim();
|
|
1700
|
+
cleaned = cleaned.replace(/\.$/, "");
|
|
1701
|
+
return cleaned;
|
|
1701
1702
|
}).filter(function (formula) {
|
|
1702
1703
|
return formula.length > 0 && LatexExtractor.isMathFormula(formula);
|
|
1703
1704
|
});
|