From 6d283451fd8c0373c6cd330322c99d95cc7e042e Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Fri, 22 Aug 2014 15:44:03 -0400 Subject: [PATCH] Add support for \{, \} and \\ inside \text{}, since {, }, and \ are used by MathJax in determining the extent of the \text box. This helps with issues #375 and #790. --- unpacked/jax/input/TeX/jax.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/unpacked/jax/input/TeX/jax.js b/unpacked/jax/input/TeX/jax.js index 9ed03e83b..2cd1a89ca 100644 --- a/unpacked/jax/input/TeX/jax.js +++ b/unpacked/jax/input/TeX/jax.js @@ -1973,7 +1973,7 @@ InternalMath: function (text,level) { var def = {displaystyle: false}; if (level != null) {def.scriptlevel = level} if (this.stack.env.font) {def.mathvariant = this.stack.env.font} - if (!text.match(/\\?\$|\\\(|\\(eq)?ref\s*\{/)) {return [this.InternalText(text,def)]} + if (!text.match(/\\?[${}\\]|\\\(|\\(eq)?ref\s*\{/)) {return [this.InternalText(text,def)]} var i = 0, k = 0, c, match = ''; var mml = []; while (i < text.length) { @@ -2001,8 +2001,8 @@ } else if (c === ')' && match === ')') { mml.push(MML.TeXAtom(TEX.Parse(text.slice(k,i-2),{}).mml().With(def))); match = ''; k = i; - } else if (c === '$' && match === '') { - i--; text = text.substr(0,i-1) + text.substr(i); // remove \ from \$ + } else if (c.match(/[${}\\]/) && match === '') { + i--; text = text.substr(0,i-1) + text.substr(i); // remove \ from \$, \{, \}, or \\ } } }