acsi-core 0.9.7 → 0.9.8

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.
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import "katex/dist/katex.min.css";
3
- interface MarkdownLatexRenderProps {
3
+ interface MarkdownRendererProps {
4
4
  content: string;
5
5
  }
6
- declare const MarkdownLatexRender: React.FC<MarkdownLatexRenderProps>;
7
- export default MarkdownLatexRender;
6
+ declare const MarkdownRenderer: React.FC<MarkdownRendererProps>;
7
+ export default MarkdownRenderer;
package/dist/index.js CHANGED
@@ -689,6 +689,28 @@ function _catch(body, recover) {
689
689
  return result;
690
690
  }
691
691
 
692
+ function _arrayLikeToArray(r, a) {
693
+ (null == a || a > r.length) && (a = r.length);
694
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
695
+ return n;
696
+ }
697
+ function _createForOfIteratorHelperLoose(r, e) {
698
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
699
+ if (t) return (t = t.call(r)).next.bind(t);
700
+ if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) {
701
+ t && (r = t);
702
+ var o = 0;
703
+ return function () {
704
+ return o >= r.length ? {
705
+ done: !0
706
+ } : {
707
+ done: !1,
708
+ value: r[o++]
709
+ };
710
+ };
711
+ }
712
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
713
+ }
692
714
  function _extends$1() {
693
715
  return _extends$1 = Object.assign ? Object.assign.bind() : function (n) {
694
716
  for (var e = 1; e < arguments.length; e++) {
@@ -707,6 +729,13 @@ function _objectWithoutPropertiesLoose(r, e) {
707
729
  }
708
730
  return t;
709
731
  }
732
+ function _unsupportedIterableToArray(r, a) {
733
+ if (r) {
734
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
735
+ var t = {}.toString.call(r).slice(8, -1);
736
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
737
+ }
738
+ }
710
739
 
711
740
  var styles = {"core-button":"_xvNBN","primary":"_U9Qyp","secondary":"_1VzMy","text":"_pZNuj","danger":"_2uYm1","light":"_wxH5S"};
712
741
 
@@ -1668,76 +1697,434 @@ var CoreTooltip = function CoreTooltip(_ref) {
1668
1697
 
1669
1698
  var LatexExtractor = /*#__PURE__*/function () {
1670
1699
  function LatexExtractor() {}
1671
- LatexExtractor.ApplyLatexFormat = function ApplyLatexFormat(content) {
1672
- var allComponents = LatexExtractor.extractAllLatexUltimate(content);
1673
- var multiLineFormulas = LatexExtractor.extractMultiLineFormulas(content);
1674
- var foundLatexStr = multiLineFormulas[0] || "";
1675
- if (foundLatexStr && foundLatexStr !== "" && allComponents.length > 0) {
1676
- var firstPosition = content.indexOf(allComponents[0]);
1677
- if (firstPosition > 0) {
1678
- var textPart = content.slice(0, firstPosition).trim();
1679
- var latexPart = content.slice(firstPosition).trim();
1680
- return textPart + (" $$" + latexPart + "$$");
1700
+ LatexExtractor.isLatexFormula = function isLatexFormula(text) {
1701
+ if (!text || text.trim().length === 0) {
1702
+ return false;
1703
+ }
1704
+ if (/^[a-zA-Z\s]+$/.test(text.trim()) && !/^[a-zA-Z]_|^[a-zA-Z]\^/.test(text.trim())) {
1705
+ return false;
1706
+ }
1707
+ if (text.length > 100 && text.split(' ').length > 15) {
1708
+ return false;
1709
+ }
1710
+ var englishPhrases = ['the surface of', 'acceleration caused by', 'force of gravity', 'measured value', 'approximately equal to', 'has a', 'is', 'are', 'will be', 'can be', 'may be', 'should be', 'would be'];
1711
+ for (var _i = 0, _englishPhrases = englishPhrases; _i < _englishPhrases.length; _i++) {
1712
+ var phrase = _englishPhrases[_i];
1713
+ if (text.toLowerCase().includes(phrase)) {
1714
+ return false;
1715
+ }
1716
+ }
1717
+ for (var _iterator = _createForOfIteratorHelperLoose(this.LATEX_COMMANDS), _step; !(_step = _iterator()).done;) {
1718
+ var command = _step.value;
1719
+ if (text.includes(command)) {
1720
+ return true;
1721
+ }
1722
+ }
1723
+ if (/_\{[^}]*\}/.test(text) || /\^\{[^}]*\}/.test(text)) {
1724
+ return true;
1725
+ }
1726
+ if (/^[a-zA-Z0-9_{}\\]+\s*[=~≈]\s*[a-zA-Z0-9_{}\\+\-*/^().\s]*$/.test(text.trim())) {
1727
+ return true;
1728
+ }
1729
+ if (/\\/.test(text) && /[=+\-*/^_{}[\]]/.test(text)) {
1730
+ return true;
1731
+ }
1732
+ if (/[≈~±∞∂∇∑∏∫]/.test(text)) {
1733
+ return true;
1734
+ }
1735
+ if (/^[a-zA-Z0-9_{}\\]*[a-zA-Z]_[a-zA-Z0-9{}\\]*$/.test(text.trim()) || /^[a-zA-Z0-9_{}\\]*[a-zA-Z]\^[a-zA-Z0-9{}\\]*$/.test(text.trim())) {
1736
+ return true;
1737
+ }
1738
+ if (/^[a-zA-Z0-9_{}\\]+\/[a-zA-Z0-9_{}\\^]+$/.test(text.trim()) && /[a-zA-Z]/.test(text)) {
1739
+ return true;
1740
+ }
1741
+ return false;
1742
+ };
1743
+ LatexExtractor.hasAnyMathematicalContent = function hasAnyMathematicalContent(content) {
1744
+ if (/\\[a-zA-Z]/.test(content)) return true;
1745
+ if (/_\{|\^\{/.test(content)) return true;
1746
+ if (/[a-zA-Z]\s*=\s*[a-zA-Z0-9]/.test(content)) return true;
1747
+ if (/(?:Relevant|Derived)\s+equation:/i.test(content)) return true;
1748
+ if (/[≈~±∞∂∇∑∏∫\\]/.test(content)) return true;
1749
+ if (/[a-zA-Z]_[a-zA-Z0-9]/.test(content)) return true;
1750
+ if (/[a-zA-Z]\^[a-zA-Z0-9]/.test(content)) return true;
1751
+ if (/\$[^$]+\$/.test(content)) return true;
1752
+ return false;
1753
+ };
1754
+ LatexExtractor.isAlreadyWrapped = function isAlreadyWrapped(content) {
1755
+ if (/^\$[^$]+\$$/.test(content.trim())) return true;
1756
+ if (/^\$\$[^$]+\$\$$/.test(content.trim())) return true;
1757
+ return false;
1758
+ };
1759
+ LatexExtractor.extractExistingMathContent = function extractExistingMathContent(content) {
1760
+ var mathBlocks = [];
1761
+ var displayMathPattern = /\$\$([^$]+)\$\$/g;
1762
+ var displayMatch;
1763
+ while ((displayMatch = displayMathPattern.exec(content)) !== null) {
1764
+ mathBlocks.push({
1765
+ text: displayMatch[1],
1766
+ start: displayMatch.index,
1767
+ end: displayMatch.index + displayMatch[0].length,
1768
+ type: 'display'
1769
+ });
1770
+ }
1771
+ var inlineMathPattern = /\$([^$]+)\$/g;
1772
+ var inlineMatch;
1773
+ var _loop = function _loop() {
1774
+ var matchStart = inlineMatch.index;
1775
+ var isOverlapping = mathBlocks.some(function (block) {
1776
+ return matchStart >= block.start && matchStart < block.end;
1777
+ });
1778
+ if (!isOverlapping) {
1779
+ mathBlocks.push({
1780
+ text: inlineMatch[1],
1781
+ start: inlineMatch.index,
1782
+ end: inlineMatch.index + inlineMatch[0].length,
1783
+ type: 'inline'
1784
+ });
1681
1785
  }
1682
- return content.replace(foundLatexStr, "$$" + foundLatexStr + "$$");
1786
+ };
1787
+ while ((inlineMatch = inlineMathPattern.exec(content)) !== null) {
1788
+ _loop();
1789
+ }
1790
+ return mathBlocks.sort(function (a, b) {
1791
+ return a.start - b.start;
1792
+ });
1793
+ };
1794
+ LatexExtractor.extractLatexFormulas = function extractLatexFormulas(content) {
1795
+ var _this = this;
1796
+ var formulas = [];
1797
+ for (var _iterator2 = _createForOfIteratorHelperLoose(this.LATEX_PATTERNS), _step2; !(_step2 = _iterator2()).done;) {
1798
+ var pattern = _step2.value;
1799
+ var matches = content.match(pattern);
1800
+ if (matches) {
1801
+ var processedMatches = matches.map(function (match) {
1802
+ if (match.startsWith(',')) {
1803
+ return match.substring(1).trim();
1804
+ }
1805
+ if (match.endsWith(',')) {
1806
+ return match.substring(0, match.length - 1).trim();
1807
+ }
1808
+ return match.trim();
1809
+ });
1810
+ formulas.push.apply(formulas, processedMatches);
1811
+ }
1812
+ }
1813
+ var lines = content.split(/\\\\/);
1814
+ for (var _iterator3 = _createForOfIteratorHelperLoose(lines), _step3; !(_step3 = _iterator3()).done;) {
1815
+ var line = _step3.value;
1816
+ var trimmed = line.trim().replace(/\.$/, '');
1817
+ if (trimmed && this.isLatexFormula(trimmed)) {
1818
+ formulas.push(trimmed);
1819
+ }
1820
+ }
1821
+ var commaSeparatedParts = content.split(',');
1822
+ for (var _iterator4 = _createForOfIteratorHelperLoose(commaSeparatedParts), _step4; !(_step4 = _iterator4()).done;) {
1823
+ var part = _step4.value;
1824
+ var _trimmed = part.trim();
1825
+ if (_trimmed && this.isLatexFormula(_trimmed)) {
1826
+ formulas.push(_trimmed);
1827
+ }
1828
+ }
1829
+ var uniqueFormulas = Array.from(new Set(formulas));
1830
+ return uniqueFormulas.filter(function (formula) {
1831
+ return formula.length > 1 && !formula.match(/^[,\s.]*$/) && _this.isLatexFormula(formula);
1832
+ });
1833
+ };
1834
+ LatexExtractor.findLatexExpressions = function findLatexExpressions(content) {
1835
+ var expressions = [];
1836
+ var mathStartPatterns = [/\\[a-zA-Z]+(?:\s*\{[^}]*\})*|\\[a-zA-Z]+/g, /[a-zA-Z][_^]\{[^}]*\}/g, /[a-zA-Z][_^][a-zA-Z0-9]/g, /[≈~±∞∂∇∑∏∫]/g, /\b[a-zA-Z]+\/[a-zA-Z]+\^?\{?[0-9]+\}?/g];
1837
+ for (var _i2 = 0, _mathStartPatterns = mathStartPatterns; _i2 < _mathStartPatterns.length; _i2++) {
1838
+ var pattern = _mathStartPatterns[_i2];
1839
+ var match = void 0;
1840
+ while ((match = pattern.exec(content)) !== null) {
1841
+ var startPos = match.index;
1842
+ var endPos = startPos + match[0].length;
1843
+ var remaining = content.substring(endPos);
1844
+ var limitedContinuationPattern = /^[\s]*[=~≈]\s*[a-zA-Z0-9_{}\\]+|^[\s]*[+\-*/]\s*[a-zA-Z0-9_{}\\]+/;
1845
+ var continuationMatch = remaining.match(limitedContinuationPattern);
1846
+ if (continuationMatch) {
1847
+ endPos += continuationMatch[0].length;
1848
+ }
1849
+ var expressionText = content.substring(startPos, endPos).trim();
1850
+ if (this.isLatexFormula(expressionText) && expressionText.length > 0) {
1851
+ expressions.push({
1852
+ text: expressionText,
1853
+ start: startPos,
1854
+ end: startPos + expressionText.length
1855
+ });
1856
+ }
1857
+ }
1858
+ }
1859
+ var equationPattern = /\b[a-zA-Z][a-zA-Z0-9_{}\\]*\s*[=~≈]\s*[a-zA-Z0-9_{}\\+\-*/^().\s]*?\b/g;
1860
+ var eqMatch;
1861
+ while ((eqMatch = equationPattern.exec(content)) !== null) {
1862
+ var _expressionText = eqMatch[0].trim();
1863
+ if (this.isLatexFormula(_expressionText) && _expressionText.length > 3) {
1864
+ expressions.push({
1865
+ text: _expressionText,
1866
+ start: eqMatch.index,
1867
+ end: eqMatch.index + eqMatch[0].length
1868
+ });
1869
+ }
1870
+ }
1871
+ this.findKeywordSeparatedExpressions(content, expressions);
1872
+ expressions.sort(function (a, b) {
1873
+ return a.start - b.start;
1874
+ });
1875
+ var merged = [];
1876
+ for (var _i3 = 0, _expressions = expressions; _i3 < _expressions.length; _i3++) {
1877
+ var expr = _expressions[_i3];
1878
+ var last = merged[merged.length - 1];
1879
+ if (last && expr.start <= last.end) {
1880
+ if (this.isLatexFormula(content.substring(last.start, expr.end).trim())) {
1881
+ last.end = Math.max(last.end, expr.end);
1882
+ last.text = content.substring(last.start, last.end).trim();
1883
+ }
1884
+ } else {
1885
+ merged.push(expr);
1886
+ }
1887
+ }
1888
+ return merged;
1889
+ };
1890
+ LatexExtractor.findKeywordSeparatedExpressions = function findKeywordSeparatedExpressions(content, expressions) {
1891
+ var afterCommaPattern = /,\s*([a-zA-Z0-9_{}\\]+(?:\s*[=+\-*/^~≈]\s*[a-zA-Z0-9_{}\\().\s]*)*)/g;
1892
+ var match;
1893
+ while ((match = afterCommaPattern.exec(content)) !== null) {
1894
+ var expression = match[1].trim();
1895
+ if (this.isLatexFormula(expression) && expression.length > 1) {
1896
+ var startPos = match.index + match[0].indexOf(expression);
1897
+ expressions.push({
1898
+ text: expression,
1899
+ start: startPos,
1900
+ end: startPos + expression.length
1901
+ });
1902
+ }
1903
+ }
1904
+ var beforeCommaPattern = /([a-zA-Z0-9_{}\\]+(?:\s*[=+\-*/^~≈]\s*[a-zA-Z0-9_{}\\().\s]*)*)\s*,/g;
1905
+ while ((match = beforeCommaPattern.exec(content)) !== null) {
1906
+ var _expression = match[1].trim();
1907
+ if (this.isLatexFormula(_expression) && _expression.length > 1) {
1908
+ var _startPos = match.index;
1909
+ expressions.push({
1910
+ text: _expression,
1911
+ start: _startPos,
1912
+ end: _startPos + _expression.length
1913
+ });
1914
+ }
1915
+ }
1916
+ var afterToPattern = /\bto\s+([a-zA-Z0-9_{}\\]+(?:\s*[=+\-*/^~≈]\s*[a-zA-Z0-9_{}\\().\s]*)*)/g;
1917
+ while ((match = afterToPattern.exec(content)) !== null) {
1918
+ var _expression2 = match[1].trim();
1919
+ if (this.isLatexFormula(_expression2) && _expression2.length > 1) {
1920
+ var _startPos2 = match.index + match[0].indexOf(_expression2);
1921
+ expressions.push({
1922
+ text: _expression2,
1923
+ start: _startPos2,
1924
+ end: _startPos2 + _expression2.length
1925
+ });
1926
+ }
1927
+ }
1928
+ var beforeToPattern = /([a-zA-Z0-9_{}\\]+(?:\s*[=+\-*/^~≈]\s*[a-zA-Z0-9_{}\\().\s]*)*)\s+to\b/g;
1929
+ while ((match = beforeToPattern.exec(content)) !== null) {
1930
+ var _expression3 = match[1].trim();
1931
+ if (this.isLatexFormula(_expression3) && _expression3.length > 1) {
1932
+ var _startPos3 = match.index;
1933
+ expressions.push({
1934
+ text: _expression3,
1935
+ start: _startPos3,
1936
+ end: _startPos3 + _expression3.length
1937
+ });
1938
+ }
1939
+ }
1940
+ };
1941
+ LatexExtractor.applyLatexFormat = function applyLatexFormat(content) {
1942
+ if (!content || content.trim().length === 0) {
1943
+ return content;
1944
+ }
1945
+ if (!this.hasAnyMathematicalContent(content)) {
1946
+ return content;
1947
+ }
1948
+ var existingMathBlocks = this.extractExistingMathContent(content);
1949
+ if (existingMathBlocks.length === 1 && existingMathBlocks[0].start === 0 && existingMathBlocks[0].end === content.length) {
1950
+ return content;
1951
+ }
1952
+ if (this.isAlreadyWrapped(content)) {
1953
+ return content;
1954
+ }
1955
+ var trimmedContent = content.trim();
1956
+ if (!trimmedContent.includes('\n') && this.hasAnyMathematicalContent(trimmedContent)) {
1957
+ var words = trimmedContent.toLowerCase().split(/\s+/);
1958
+ var englishWords = words.filter(function (word) {
1959
+ return /^[a-z]{3,}$/.test(word) && !['cos', 'sin', 'tan', 'log', 'exp', 'max', 'min'].includes(word);
1960
+ });
1961
+ if (englishWords.length === 0) {
1962
+ return "$$" + trimmedContent + "$$";
1963
+ }
1964
+ }
1965
+ if (!trimmedContent.includes('\n') && this.isLatexFormula(trimmedContent) && !/\b(?:the|is|are|and|or|of|to|in|on|at|by|for|with|from|into|onto|upon|over|under|above|below|between|among|through|during|before|after|since|until|while|where|when|why|how|what|who|which|that|this|these|those|some|many|few|all|no|not|very|more|most|less|least|better|best|worse|worst)\b/i.test(trimmedContent)) {
1966
+ return "$$" + trimmedContent + "$$";
1967
+ }
1968
+ var expressions = this.findLatexExpressions(content);
1969
+ var newExpressions = expressions.filter(function (expr) {
1970
+ return !existingMathBlocks.some(function (mathBlock) {
1971
+ return expr.start >= mathBlock.start && expr.end <= mathBlock.end;
1972
+ });
1973
+ });
1974
+ if (newExpressions.length === 0) {
1975
+ return content;
1976
+ }
1977
+ var result = content;
1978
+ var offset = 0;
1979
+ for (var _iterator5 = _createForOfIteratorHelperLoose(newExpressions), _step5; !(_step5 = _iterator5()).done;) {
1980
+ var expr = _step5.value;
1981
+ var adjustedStart = expr.start + offset;
1982
+ var adjustedEnd = expr.end + offset;
1983
+ var beforeStart = Math.max(0, adjustedStart - 2);
1984
+ var afterEnd = Math.min(result.length, adjustedEnd + 2);
1985
+ var context = result.substring(beforeStart, afterEnd);
1986
+ if (!context.includes('$$') && !context.includes('$')) {
1987
+ var wrappedExpr = "$$" + expr.text + "$$";
1988
+ result = result.substring(0, adjustedStart) + wrappedExpr + result.substring(adjustedEnd);
1989
+ offset += wrappedExpr.length - expr.text.length;
1990
+ }
1991
+ }
1992
+ return result;
1993
+ };
1994
+ LatexExtractor.applyLatexFormatSimple = function applyLatexFormatSimple(content) {
1995
+ if (!content || content.trim().length === 0) {
1996
+ return content;
1997
+ }
1998
+ if (!this.hasAnyMathematicalContent(content)) {
1999
+ return content;
2000
+ }
2001
+ if (this.isAlreadyWrapped(content)) {
2002
+ return content;
2003
+ }
2004
+ var trimmedContent = content.trim();
2005
+ if (!content.includes('\n') && this.hasAnyMathematicalContent(content)) {
2006
+ var words = content.toLowerCase().split(/\s+/);
2007
+ var englishWords = words.filter(function (word) {
2008
+ return /^[a-z]{3,}$/.test(word) && !['cos', 'sin', 'tan', 'log', 'exp', 'max', 'min'].includes(word);
2009
+ });
2010
+ if (englishWords.length === 0) {
2011
+ return "$$" + content + "$$";
2012
+ }
2013
+ }
2014
+ if (this.isLatexFormula(trimmedContent) && !/\b(?:the|is|are|and|or|of|to|in|on|at|by|for|with|from|that|this|these|those|states|theorem|equation|formula)\b/i.test(trimmedContent)) {
2015
+ return "$$" + trimmedContent + "$$";
2016
+ }
2017
+ if (/(?:Relevant|Derived)\s+equation:/i.test(content)) {
2018
+ var parts = content.split(/(?:Relevant|Derived)\s+equation:\s*/i);
2019
+ if (parts.length === 2) {
2020
+ var textPart = parts[0].trim();
2021
+ var formulaPart = parts[1].trim();
2022
+ if (this.isLatexFormula(formulaPart) && !this.isAlreadyWrapped(formulaPart)) {
2023
+ return textPart + "\n$$" + formulaPart + "$$";
2024
+ }
2025
+ }
2026
+ }
2027
+ var processedContent = this.processCommaSeparatedFormulas(content);
2028
+ if (processedContent !== content) {
2029
+ return processedContent;
2030
+ }
2031
+ var formulas = this.extractLatexFormulas(content);
2032
+ if (formulas.length > 0) {
2033
+ var result = content;
2034
+ var mainFormula = formulas.reduce(function (longest, current) {
2035
+ return current.length > longest.length ? current : longest;
2036
+ });
2037
+ if (!result.includes('$$') && !result.includes('$')) {
2038
+ var formulaIndex = result.indexOf(mainFormula);
2039
+ if (formulaIndex !== -1) {
2040
+ result = result.substring(0, formulaIndex) + ("$$" + mainFormula + "$$") + result.substring(formulaIndex + mainFormula.length);
2041
+ }
2042
+ }
2043
+ return result;
1683
2044
  }
1684
2045
  return content;
1685
2046
  };
2047
+ LatexExtractor.processCommaSeparatedFormulas = function processCommaSeparatedFormulas(content) {
2048
+ var _this2 = this;
2049
+ if (!this.hasAnyMathematicalContent(content)) {
2050
+ return content;
2051
+ }
2052
+ var result = content;
2053
+ var hasChanges = false;
2054
+ var beforeCommaPattern = /([a-zA-Z0-9_{}\\]+(?:\s*[=+\-*/^~≈]\s*[a-zA-Z0-9_{}\\().\s]+)*)\s*,/g;
2055
+ result = result.replace(beforeCommaPattern, function (match, formula) {
2056
+ if (_this2.isLatexFormula(formula.trim()) && !match.includes('$$') && !match.includes('$')) {
2057
+ hasChanges = true;
2058
+ return "$$" + formula.trim() + "$$,";
2059
+ }
2060
+ return match;
2061
+ });
2062
+ var afterCommaPattern = /,\s*([a-zA-Z0-9_{}\\]+(?:\s*[=+\-*/^~≈]\s*[a-zA-Z0-9_{}\\().\s]+)*)/g;
2063
+ result = result.replace(afterCommaPattern, function (match, formula) {
2064
+ if (_this2.isLatexFormula(formula.trim()) && !match.includes('$$') && !match.includes('$')) {
2065
+ hasChanges = true;
2066
+ return ", $$" + formula.trim() + "$$";
2067
+ }
2068
+ return match;
2069
+ });
2070
+ return hasChanges ? result : content;
2071
+ };
1686
2072
  return LatexExtractor;
1687
2073
  }();
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.filter(function (match) {
1692
- 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]/));
1693
- });
1694
- };
1695
- LatexExtractor.extractMultiLineFormulas = function (content) {
1696
- var formulas = content.split(/\\\\/);
1697
- return formulas.map(function (formula) {
1698
- var cleaned = formula.trim();
1699
- cleaned = cleaned.replace(/\.$/, "");
1700
- return cleaned;
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
- };
2074
+ LatexExtractor.LATEX_COMMANDS = ['\\frac', '\\sqrt', '\\sum', '\\prod', '\\int', '\\oint', '\\lim', '\\sin', '\\cos', '\\tan', '\\log', '\\ln', '\\exp', '\\alpha', '\\beta', '\\gamma', '\\delta', '\\epsilon', '\\varepsilon', '\\zeta', '\\eta', '\\theta', '\\vartheta', '\\iota', '\\kappa', '\\lambda', '\\mu', '\\nu', '\\xi', '\\pi', '\\varpi', '\\rho', '\\varrho', '\\sigma', '\\varsigma', '\\tau', "\\upsilon", '\\phi', '\\varphi', '\\chi', '\\psi', '\\omega', '\\Gamma', '\\Delta', '\\Theta', '\\Lambda', '\\Xi', '\\Pi', '\\Sigma', "\\Upsilon", '\\Phi', '\\Psi', '\\Omega', '\\to', '\\gets', '\\mapsto', '\\implies', '\\iff', '\\leftrightarrow', '\\longleftarrow', '\\longrightarrow', '\\longleftrightarrow', '\\Leftarrow', '\\Rightarrow', '\\Leftrightarrow', '\\le', '\\ge', '\\leq', '\\geq', '\\lt', '\\gt', '\\neq', '\\approx', '\\equiv', '\\sim', '\\cong', '\\leqslant', '\\geqslant', '\\parallel', '\\perp', '\\in', '\\notin', '\\subset', '\\subseteq', '\\cup', '\\cap', '\\emptyset', '\\forall', '\\exists', '\\nexists', '\\wedge', '\\vee', '\\neg', '\\partial', '\\nabla', '\\infty', '\\pm', '\\mp', '\\vec', '\\overrightarrow', "\\underrightarrow", '\\overline', "\\underline", '\\widehat', '\\widetilde', '\\overbrace', "\\underbrace", '\\mathbb', '\\mathrm', '\\mathcal', '\\mathfrak', '\\mathscr', '\\text', '\\textbf', '\\textit', '\\left', '\\right', '\\lfloor', '\\rfloor', '\\lceil', '\\rceil', '\\langle', '\\rangle', '\\cdot', '\\times', '\\div', '\\parallel', '\\angle', '\\bot', '\\newline', '\\ldots', '\\cdots', '\\vdots', '\\ddots'];
2075
+ LatexExtractor.LATEX_PATTERNS = [/[a-zA-Z0-9]_\{[^}]*\}/g, /[a-zA-Z0-9]\^\{[^}]*\}/g, /\\[a-zA-Z]+\s*\{[^}]*\}(?:\s*\{[^}]*\})*/g, /\\[a-zA-Z]+(?![a-zA-Z])/g, /\\frac\s*\{[^}]*\}\s*\{[^}]*\}/g, /\\sqrt(?:\[[^\]]*\])?\s*\{[^}]*\}/g, /\\vec\s*\{[^}]*\}/g, /\\(?:alpha|beta|gamma|delta|epsilon|varepsilon|zeta|eta|theta|vartheta|iota|kappa|lambda|mu|nu|xi|pi|varpi|rho|varrho|sigma|varsigma|tau|upsilon|phi|varphi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?![a-zA-Z])/g, /[a-zA-Z0-9_{}\\]+\s*=\s*[a-zA-Z0-9_{}\\+\-*/^().\s]+/g, /\\Delta\s*[a-zA-Z]/g, /[a-zA-Z]+_\{[a-zA-Z0-9]+\}/g, /[a-zA-Z0-9_{}\\]+\s*[+\-*/]\s*[a-zA-Z0-9_{}\\().\s]+/g, /,\s*([a-zA-Z0-9_{}\\]+(?:\s*[=+\-*/^]\s*[a-zA-Z0-9_{}\\().\s]*)*)/g, /([a-zA-Z0-9_{}\\]+(?:\s*[=+\-*/^]\s*[a-zA-Z0-9_{}\\().\s]*)*)\s*,/g, /\bto\s+([a-zA-Z0-9_{}\\]+(?:\s*[=+\-*/^~≈]\s*[a-zA-Z0-9_{}\\().\s]*)*)/g, /([a-zA-Z0-9_{}\\]+(?:\s*[=+\-*/^~≈]\s*[a-zA-Z0-9_{}\\().\s]*)*)\s+to\b/g];
1708
2076
 
1709
- var _excluded$3 = ["node"];
1710
- var MarkdownLatexRender = function MarkdownLatexRender(_ref) {
2077
+ var MarkdownRenderer = function MarkdownRenderer(_ref) {
1711
2078
  var content = _ref.content;
1712
- var updatedMarkdown = formatContent(content);
1713
- return React__default.createElement("span", null, React__default.createElement(ReactMarkdown, {
2079
+ var formattedContent = formatContent(content);
2080
+ return React__default.createElement(ReactMarkdown, {
1714
2081
  remarkPlugins: [remarkMath],
1715
- rehypePlugins: [rehypeKatex, rehypeRaw],
1716
- components: {
1717
- p: function p(_ref2) {
1718
- var props = _objectWithoutPropertiesLoose(_ref2, _excluded$3);
1719
- return React__default.createElement("span", Object.assign({}, props));
1720
- }
1721
- }
1722
- }, updatedMarkdown));
2082
+ rehypePlugins: [rehypeKatex, rehypeRaw]
2083
+ }, formattedContent);
1723
2084
  };
1724
2085
  function formatContent(content) {
1725
2086
  if (!content || content.trim() === "") {
1726
2087
  return content;
1727
2088
  }
1728
- var lines = content.split("\n");
2089
+ var processedContent = content.replace(/\s*\\\\\s*/g, '\n');
2090
+ var lines = processedContent.split("\n");
1729
2091
  var result = [];
1730
2092
  var i = 0;
1731
2093
  while (i < lines.length) {
1732
- var line = lines[i];
1733
- var formatText = LatexExtractor.ApplyLatexFormat(line);
1734
- var newline = formatText.trim();
1735
- if (newline !== line) {
1736
- result.push(newline);
2094
+ var line = lines[i].trim();
2095
+ if (line === '') {
2096
+ result.push('');
1737
2097
  i++;
1738
2098
  continue;
1739
2099
  }
1740
- result.push(line);
2100
+ var isEquationLabel = /\\textit\{.*(?:Relevant|Derived).*equation.*\}/i.test(line) || /^(?:Relevant|Derived)\s+equation:\s*$/i.test(line);
2101
+ if (isEquationLabel) {
2102
+ var processedLabel = line;
2103
+ if (line.includes('\\textit{') && !line.startsWith('$')) {
2104
+ processedLabel = "$" + line + "$";
2105
+ }
2106
+ result.push(processedLabel);
2107
+ i++;
2108
+ if (i < lines.length) {
2109
+ var equationLine = lines[i].trim();
2110
+ if (equationLine) {
2111
+ if (LatexExtractor.isAlreadyWrapped(equationLine)) {
2112
+ result.push(equationLine);
2113
+ } else {
2114
+ var formatText = LatexExtractor.applyLatexFormat(equationLine);
2115
+ result.push(formatText);
2116
+ }
2117
+ }
2118
+ i++;
2119
+ }
2120
+ continue;
2121
+ }
2122
+ if (LatexExtractor.isAlreadyWrapped(line)) {
2123
+ result.push(line);
2124
+ } else {
2125
+ var _formatText = LatexExtractor.applyLatexFormatSimple(line);
2126
+ result.push(_formatText);
2127
+ }
1741
2128
  i++;
1742
2129
  }
1743
2130
  return result.join("\n");
@@ -3335,7 +3722,7 @@ var CustomOption = function CustomOption(props) {
3335
3722
  }, props.data.label));
3336
3723
  };
3337
3724
 
3338
- var _excluded$4 = ["isDefault", "defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
3725
+ var _excluded$3 = ["isDefault", "defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
3339
3726
  var CustomSelect = function CustomSelect(_ref) {
3340
3727
  var isDefault = _ref.isDefault,
3341
3728
  options = _ref.options,
@@ -3343,7 +3730,7 @@ var CustomSelect = function CustomSelect(_ref) {
3343
3730
  scrollBottom = _ref.scrollBottom,
3344
3731
  value = _ref.value,
3345
3732
  isMulti = _ref.isMulti,
3346
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
3733
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$3);
3347
3734
  var initialValues = Array.isArray(value) ? options.filter(function (i) {
3348
3735
  return value.includes(i.value);
3349
3736
  }) : isMulti ? options === null || options === void 0 ? void 0 : options.filter(function (i) {
@@ -3370,7 +3757,7 @@ var CustomSelect = function CustomSelect(_ref) {
3370
3757
  }, rest));
3371
3758
  };
3372
3759
 
3373
- var _excluded$5 = ["isDefault", "defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
3760
+ var _excluded$4 = ["isDefault", "defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
3374
3761
  var CustomAsyncSelect = function CustomAsyncSelect(_ref) {
3375
3762
  var isDefault = _ref.isDefault,
3376
3763
  options = _ref.options,
@@ -3378,7 +3765,7 @@ var CustomAsyncSelect = function CustomAsyncSelect(_ref) {
3378
3765
  scrollBottom = _ref.scrollBottom,
3379
3766
  value = _ref.value,
3380
3767
  isMulti = _ref.isMulti,
3381
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
3768
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$4);
3382
3769
  var initialValues = Array.isArray(value) ? options.filter(function (i) {
3383
3770
  return value.includes(i.value);
3384
3771
  }) : isMulti ? options.filter(function (i) {
@@ -3405,14 +3792,14 @@ var CustomAsyncSelect = function CustomAsyncSelect(_ref) {
3405
3792
  }, rest));
3406
3793
  };
3407
3794
 
3408
- var _excluded$6 = ["defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
3795
+ var _excluded$5 = ["defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
3409
3796
  var CustomCreatable = function CustomCreatable(_ref) {
3410
3797
  var options = _ref.options,
3411
3798
  isDisabled = _ref.isDisabled,
3412
3799
  scrollBottom = _ref.scrollBottom,
3413
3800
  value = _ref.value,
3414
3801
  isMulti = _ref.isMulti,
3415
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$6);
3802
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$5);
3416
3803
  var initialValues = Array.isArray(value) ? options.filter(function (i) {
3417
3804
  return value.includes(i.value);
3418
3805
  }) : isMulti ? options.filter(function (i) {
@@ -3439,7 +3826,7 @@ var CustomCreatable = function CustomCreatable(_ref) {
3439
3826
  }, rest));
3440
3827
  };
3441
3828
 
3442
- var _excluded$7 = ["defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
3829
+ var _excluded$6 = ["defaultValue", "options", "isDisabled", "scrollBottom", "value", "isMulti"];
3443
3830
  var CustomSelectOption = function CustomSelectOption(_ref) {
3444
3831
  var defaultValue = _ref.defaultValue,
3445
3832
  options = _ref.options,
@@ -3447,7 +3834,7 @@ var CustomSelectOption = function CustomSelectOption(_ref) {
3447
3834
  scrollBottom = _ref.scrollBottom,
3448
3835
  value = _ref.value,
3449
3836
  isMulti = _ref.isMulti,
3450
- rest = _objectWithoutPropertiesLoose(_ref, _excluded$7);
3837
+ rest = _objectWithoutPropertiesLoose(_ref, _excluded$6);
3451
3838
  var initialValues = defaultValue !== null && typeof defaultValue !== "undefined" ? options.find(function (option) {
3452
3839
  return option.value === defaultValue;
3453
3840
  }) || null : null;
@@ -3527,7 +3914,7 @@ exports.DATE_TIME_MIN_VALUE = DATE_TIME_MIN_VALUE;
3527
3914
  exports.LayoutContext = LayoutContext;
3528
3915
  exports.Loading = Loading;
3529
3916
  exports.Login = Login;
3530
- exports.MarkdownLatexRender = MarkdownLatexRender;
3917
+ exports.MarkdownLatexRender = MarkdownRenderer;
3531
3918
  exports.NotFound = NotFound;
3532
3919
  exports.OPENSALT_BASE_URL = OPENSALT_BASE_URL;
3533
3920
  exports.ORGANIZATION_TEAM = ORGANIZATION_TEAM;