diff --git a/web/reviewer.js b/web/reviewer.js index e20a40e7f..4f11b2b62 100644 --- a/web/reviewer.js +++ b/web/reviewer.js @@ -8,6 +8,7 @@ function _updateQA(html, onupdate, onshown) { qa.fadeTo(fadeTime, 0, function() { // update text qa.html(html); + _removeStylingFromMathjaxCloze(); onupdate(qa); // don't allow drags of images, which cause them to be deleted @@ -64,3 +65,19 @@ function _typeAnsPress() { pycmd("ans"); } } + +function _removeStylingFromMathjaxCloze() { + $(".cloze").each(function (i) { + if (_clozeIsInsideMathjax(this)) { + this.outerHTML = this.innerHTML; + } + }); +} + +function _clozeIsInsideMathjax(node) { + if (!node.previousSibling || node.previousSibling.nodeType !== 3) { + return; + } + // look for mathjax opening in previous text + return /\(|\$\$/.test(node.previousSibling.textContent); +} \ No newline at end of file