diff --git a/layout/_third-party/math/mathjax.swig b/layout/_third-party/math/mathjax.swig index f695c1a530..47cb650e00 100644 --- a/layout/_third-party/math/mathjax.swig +++ b/layout/_third-party/math/mathjax.swig @@ -18,22 +18,29 @@ } } }); + MathJax.Hub.Register.StartupHook('TeX Jax Ready', function() { MathJax.InputJax.TeX.prefilterHooks.Add(function(data) { if (data.display) { var next = data.script.nextSibling; - while (next && next.nodeName.toLowerCase() === '#text') { next = next.nextSibling } - if (next && next.nodeName.toLowerCase() === 'br') { next.parentNode.removeChild(next) } + while (next && next.nodeName.toLowerCase() === '#text') { + next = next.nextSibling; + } + if (next && next.nodeName.toLowerCase() === 'br') { + next.parentNode.removeChild(next); + } } }); }); - -