From 3ba3857ef677c291fa2025269252250e1838ad4b Mon Sep 17 00:00:00 2001 From: Ashp116 Date: Sun, 1 Dec 2024 20:12:21 -0500 Subject: [PATCH] FIX: Resolved the issue #2530 --- src/formats/parse-math-string.ts | 2 +- test/math-ascii.test.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) 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'); });