From 040ddd652c8c2c5b889e15abd974d13cc27ef76c Mon Sep 17 00:00:00 2001 From: Peter Krautzberger Date: Mon, 23 Nov 2015 21:56:07 +0100 Subject: [PATCH] plainTeX output jax: check MathML input for TeX and asciimath annotation and use it. --- unpacked/jax/output/PlainSource/jax.js | 32 ++++++++++---------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/unpacked/jax/output/PlainSource/jax.js b/unpacked/jax/output/PlainSource/jax.js index c49c6a76e..da6b2d323 100644 --- a/unpacked/jax/output/PlainSource/jax.js +++ b/unpacked/jax/output/PlainSource/jax.js @@ -136,30 +136,22 @@ // Typeset the math // this.initPlainSource(math, span); - // math.setTeXclass(); - // try {math.toPreviewHTML(span)} catch (err) { - // if (err.restart) {while (span.firstChild) {span.removeChild(span.firstChild)}} - // throw err; - // } - - //NEWSTUFF if (jax.inputJax === "MathML") { - console.log("Yay! MathML!"); - if (jax.root.data[0].data.length > 0) { - if (jax.root.data[0].data[0].type === "semantics") { - if (jax.root.data[0].data[0].data[1].attr.encoding === "application/x-tex"){ - span.innerHTML = jax.root.data[0].data[0].data[1].data[0].data[0]; - console.log("yay Annotation TeX"); - } + if ((jax.root.data[0].data.length > 0) && (jax.root.data[0].data[0].type === "semantics")) { + var annotations = jax.root.data[0].data[0].data.map(function(node) { + return node.attr.encoding; + }); + var texIndex = annotations.indexOf("application/x-tex"); + var asciiIndex = annotations.indexOf("text/x-asciimath"); + if (texIndex > -1) { + source = jax.root.data[0].data[0].data[texIndex].data[0].data[0]; + } else if (asciiIndex > -1) { + source = jax.root.data[0].data[0].data[asciiIndex].data[0].data[0]; } - - } else { - span.innerHTML = jax.originalText; } + } else { + span.innerHTML = jax.originalText; } - // span.innerHTML = jax.originalText; - - // // Put it in place, and remove the processing marker