diff --git a/src/formats/parse-math-string.ts b/src/formats/parse-math-string.ts index 310af6a94..9e89291fa 100644 --- a/src/formats/parse-math-string.ts +++ b/src/formats/parse-math-string.ts @@ -130,7 +130,7 @@ function parseMathExpression( return `\\text{${m[1]}}${parseMathExpression(m[2], options)}`; } - m = s.match(/^([^a-zA-Z\(\{\[\_\^\\\s"]+)(.*)/); + m = s.match(/^([^a-zA-Z0-9\(\{\[\_\^\\\s"]+)(.*)/);; // A string of symbols... // Could be a binary or relational operator, etc... if (m) { diff --git a/test/math-ascii.test.ts b/test/math-ascii.test.ts index d06d81b17..36f9e1b49 100644 --- a/test/math-ascii.test.ts +++ b/test/math-ascii.test.ts @@ -81,4 +81,8 @@ describe('ASCII MATH', function () { equalASCIIMath('\\left\\lbrack1,1\\right\\rbrack', '[1,1]'); equalASCIIMath('\\left\\lbrace1,1\\right\\rbrace', '{1,1}'); equalASCIIMath('\\left(1,1\\right)', '(1,1)'); + + expect(convertAsciiMathToLatex('1/2')).toBe('\\frac{1}{2}'); + expect(convertAsciiMathToLatex('(1/2)')).toBe('\\left(\\frac{1}{2}\\right)'); + expect(convertAsciiMathToLatex('1/2sin x')).toBe('\\frac{1}{2}\\sin x'); });