www

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

commit 850f736aa7f8cd08ce2b01b1b47dafa00edc15c4
parent 86a908bda83afa31aae841b8e79b30404bcd3d2b
Author: Frédéric Wang <fred.wang@free.fr>
Date:   Fri, 30 Aug 2013 11:27:12 +0200

Add preview=mathml,altimg to the mml2jax preprocessor. #557

Diffstat:
Munpacked/extensions/mml2jax.js | 23+++++++++++++++++------
1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/unpacked/extensions/mml2jax.js b/unpacked/extensions/mml2jax.js @@ -181,13 +181,24 @@ MathJax.Extension.mml2jax = { createPreview: function (math,script) { var preview = this.config.preview; if (preview === "none") return; - if (preview === "alttext") { - var text = math.getAttribute("alttext"); - if (text != null) {preview = [this.filterPreview(text)]} else {preview = null} - } + if (preview === "mathml") {preview = math} + else if (preview === "alttext" || preview === "altimg") { + var alttext = this.filterPreview(math.getAttribute("alttext")); + if (preview === "alttext") { + if (alttext != null) {preview = MathJax.HTML.TextNode(alttext)} else {preview = null} + } else { + var src = math.getAttribute("altimg"); + if (src != null) { + // FIXME: use altimg-valign when display="inline"? + var style = {width: math.getAttribute("altimg-width"), height: math.getAttribute("altimg-height")}; + preview = MathJax.HTML.Element("img",{src:src,alt:alttext,style:style}); + } else {preview = null} + } + } if (preview) { - preview = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass},preview); - script.parentNode.insertBefore(preview,script); + var span = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass}); + span.appendChild(preview); + script.parentNode.insertBefore(span,script); } },