From 80ee507951914aef9df62d05d7d482cbb44c4729 Mon Sep 17 00:00:00 2001 From: Wu Cheng-Han Date: Fri, 18 Nov 2016 12:19:05 +0800 Subject: [PATCH] Fix mathjax with blockquote might have race condition --- public/js/extra.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/public/js/extra.js b/public/js/extra.js index 36d0e67..c0b2e58 100644 --- a/public/js/extra.js +++ b/public/js/extra.js @@ -286,17 +286,6 @@ function finishView(view) { if ($(value).children().length == 0) $(value).gist(viewAjaxCallback); }); - //mathjax - var mathjaxdivs = view.find('span.mathjax.raw').removeClass("raw").toArray(); - try { - if (mathjaxdivs.length > 1) { - MathJax.Hub.Queue(["Typeset", MathJax.Hub, mathjaxdivs]); - MathJax.Hub.Queue(viewAjaxCallback); - } else if (mathjaxdivs.length > 0) { - MathJax.Hub.Queue(["Typeset", MathJax.Hub, mathjaxdivs[0]]); - MathJax.Hub.Queue(viewAjaxCallback); - } - } catch (err) {} //sequence diagram var sequences = view.find("div.sequence-diagram.raw").removeClass("raw"); sequences.each(function (key, value) { @@ -508,6 +497,19 @@ function finishView(view) { else langDiv.html(result.value); } }); + //mathjax + var mathjaxdivs = view.find('span.mathjax.raw').removeClass("raw").toArray(); + try { + if (mathjaxdivs.length > 1) { + MathJax.Hub.Queue(["Typeset", MathJax.Hub, mathjaxdivs]); + MathJax.Hub.Queue(viewAjaxCallback); + } else if (mathjaxdivs.length > 0) { + MathJax.Hub.Queue(["Typeset", MathJax.Hub, mathjaxdivs[0]]); + MathJax.Hub.Queue(viewAjaxCallback); + } + } catch (err) { + console.warn(err); + } //render title document.title = renderTitle(view); }