mirror of
https://github.com/ankitects/anki.git
synced 2025-09-19 14:32:22 -04:00
hack around clozes breaking mathjax
This commit is contained in:
parent
21b770cb10
commit
4c286fa3f7
1 changed files with 17 additions and 0 deletions
|
@ -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);
|
||||
}
|
Loading…
Reference in a new issue