www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit edce81f6914d665572f809171d2253aad9d22c8f
parent 81b87c1ea3f49b0fbb30639a556be967435a9850
Author: Davide P. Cervone <dpvc@union.edu>
Date:   Sun, 28 Dec 2014 12:02:34 -0500

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

Diffstat:
Munpacked/jax/output/HTML-CSS/jax.js | 28++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/unpacked/jax/output/HTML-CSS/jax.js b/unpacked/jax/output/HTML-CSS/jax.js @@ -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];