From 68cce3a472381050c86fe7488db7da204e77ab46 Mon Sep 17 00:00:00 2001 From: benweet Date: Fri, 2 May 2014 19:28:41 +0100 Subject: [PATCH] Updated mathjax extension --- public/res/extensions/mathJax.js | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/public/res/extensions/mathJax.js b/public/res/extensions/mathJax.js index 46e45587..dcde78c9 100644 --- a/public/res/extensions/mathJax.js +++ b/public/res/extensions/mathJax.js @@ -91,15 +91,21 @@ define([ blocks[i] = "@@" + math.length + "@@"; math.push(block) } else if(start) { + // Ignore inline maths that are actually multiline (fixes #136) + if(end == inline && block.charAt(0) == '\n') { + if(last) { + i = last; + processMath(start, i, unescape); + } + start = end = last = null; + braces = 0; + } // // If we are in math, look for the end delimiter, // but don't go past double line breaks, and // and balance braces within the math. // - if(end == inline && block.charAt(0) == '\n') { - // This should fix #136 by ignoring inline maths that are actually multiline - start = end = last = null; - } else if(block === end) { + else if(block === end) { if(braces) { last = i } else { @@ -107,7 +113,12 @@ define([ } } else { if(block.match(/\n.*\n/)) { - last && (i = last, processMath(start, i, unescape)), start = end = last = null, braces = 0 + if(last) { + i = last; + processMath(start, i, unescape); + } + start = end = last = null; + braces = 0; } else { if("{" === block) { braces++