diff --git a/lib/converters/latex-to-ast.js b/lib/converters/latex-to-ast.js index 4c82bdf..293d22a 100644 --- a/lib/converters/latex-to-ast.js +++ b/lib/converters/latex-to-ast.js @@ -143,7 +143,7 @@ import flatten from './flatten'; // Some of the latex commands that lead to spacing -const whitespace_rule = '\\s|\\\\,|\\\\!|\\\\ |\\\\>|\\\\;|\\\\:|\\\\quad\\b|\\\\qquad\\b'; +const whitespace_rule = '\\s|\\\\,|\\\\!|\\\\ |\\\\>|\\\\;|\\\\:|\\\\quad\\b|\\\\qquad\\b|\\\\text{.*?}'; const latex_rules = [ ['[0-9]+(\\.[0-9]*)?(E[+\\-]?[0-9]+)?', 'NUMBER'], diff --git a/spec/quick_latex-to-ast.spec.js b/spec/quick_latex-to-ast.spec.js index e0d513f..553c527 100644 --- a/spec/quick_latex-to-ast.spec.js +++ b/spec/quick_latex-to-ast.spec.js @@ -4,8 +4,9 @@ import { ParseError } from '../lib/converters/error'; var converter = new latexToAst(); var trees = { - + '1 * 3\\text{eggs}' : ['*', 1, 3], '\\frac{1}{2} x': ['*',['/',1,2],'x'], + '\\frac{1}{2\\text{foo}} x': ['*',['/',1,2],'x'], '1+x+3': ['+',1,'x',3], '1-x-3': ['+',1,['-','x'],['-',3]], "1 + - x": ['+',1,['-','x']],