www

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

commit 040ddd652c8c2c5b889e15abd974d13cc27ef76c
parent b28461f032af330604cd71db868905ec6860c563
Author: Peter Krautzberger <p.krautzberger@gmail.com>
Date:   Mon, 23 Nov 2015 21:56:07 +0100

plainTeX output jax: check  MathML input for TeX and asciimath annotation and use it.

Diffstat:
Munpacked/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 @@ -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