Prevent use of id's in previews from confusing HTMLspanElement() calls.

This commit is contained in:
Davide P. Cervone 2014-12-28 12:02:34 -05:00
parent 81b87c1ea3
commit edce81f691

View File

@ -668,11 +668,16 @@
//
this.initImg(span);
this.initHTML(math,span);
math.setTeXclass();
try {math.toHTML(span,div)} catch (err) {
this.savePreview(script);
try {
math.setTeXclass();
math.toHTML(span,div);
} catch (err) {
if (err.restart) {while (span.firstChild) {span.removeChild(span.firstChild)}}
this.restorePreview(script);
throw err;
}
this.restorePreview(script);
//
// Put it in place, and remove the processing marker
//
@ -701,6 +706,25 @@
}
}
},
//
// MathML previews can contain the same ID's as the HTML output,
// which confuses HTMLspanElement(), so remove the preview temporarily
// and restore it after typesetting the math.
//
savePreview: function (script) {
var preview = script.MathJax.preview;
if (preview) {
script.MathJax.tmpPreview = document.createElement("span");
preview.parentNode.replaceChild(script.MathJax.tmpPreview,preview);
}
},
restorePreview: function (script) {
var tmpPreview = script.MathJax.tmpPreview;
if (tmpPreview) {
tmpPreview.parentNode.replaceChild(script.MathJax.preview,tmpPreview);
delete script.MathJax.tmpPreview;
}
},
postTranslate: function (state,partial) {
var scripts = state.jax[this.id];