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