diff --git a/lib/main.js b/lib/main.js index 9baef798..81e6c473 100644 --- a/lib/main.js +++ b/lib/main.js @@ -115,8 +115,8 @@ var CHTMLSTYLES; // filled in when CommonHTML is loaded // the jax to be loaded completely) // function GetWindow() { -var virtualConsole = new jsdom.VirtualConsole(); -virtualConsole.sendTo(console); + var virtualConsole = new jsdom.VirtualConsole(); + virtualConsole.sendTo(console); window = new JSDOM('',{ virtualConsole: virtualConsole, userAgent: "Node.js", @@ -141,7 +141,6 @@ function ConfigureMathJax() { // // Load all input jax and preprocessors // Load AMS extensions and the autoload extension for TeX - // Allow $...$ delimiters and don't create previews for any preprocessor, // Create stand-alone SVG elements with font caches by default // (users can override that) // @@ -478,6 +477,18 @@ function ConfigureMathJax() { }); + // + // Set up None output jax (for when only MathML output is needed) + // + MathJax.OutputJax.None = MathJax.OutputJax({ + id: "None", + preTranslate: function () {}, + Translate: function () {}, + postTranslate: function () {} + }); + MathJax.OutputJax.None.loadComplete("jax.js"); + MathJax.OutputJax.None.Register("jax/mml"); + // // Reset the color extension after `autoload-all` // @@ -497,14 +508,14 @@ function ConfigureMathJax() { // (reseting the counters so that the initial math doesn't affect them) // MathJax.Hub.Register.StartupHook("End",function () { - MathJax.OutputJax.SVG.resetGlyphs(true); + if (MathJax.OutputJax.SVG.resetGlyphs) MathJax.OutputJax.SVG.resetGlyphs(true); MathJax.ElementJax.mml.ID = 0; serverState = STATE.READY; MathJax.Hub.Queue(StartQueue); }); } }; - + if (extensions) { // // Parse added extensions list and add to standard ones @@ -592,7 +603,7 @@ function AddError(message,nopush) { function GetMML(result) { if (!data.mml && !data.mmlNode) return; var jax = MathJax.Hub.getAllJax()[0]; - if (data.speakText && !jax.root.alttext){ + if (data.speakText && !jax.root.alttext) { jax.root.alttext = result.speakText; var attrNames = jax.root.attrNames; if (attrNames && attrNames.indexOf("alttext") === -1) { @@ -749,7 +760,13 @@ function StartQueue() { // GetState(data.state); - var renderer = ( (data.html || data.htmlNode || data.css) ? "CommonHTML" : "SVG"); + // + // Get the renderer to use + // + var renderer = ( + (data.html || data.htmlNode || data.css) ? "CommonHTML" : + (data.svg || data.svgNode) ? "SVG" : "None" + ); // // Set up a timeout timer to restart MathJax if it runs too long, @@ -780,7 +797,7 @@ function GetState(state) { MML = MathJax.ElementJax.mml, AMS = MathJax.Extension["TeX/AMSmath"], HUB = MathJax.Hub, HTML = MathJax.HTML, - GLYPH = SVG.BBOX.GLYPH; + GLYPH = (SVG.BBOX||{}).GLYPH; if (state && state.AMS) { AMS.startNumber = state.AMS.startNumber; @@ -793,7 +810,7 @@ function GetState(state) { ID = state.ID; } else { if (state) {state.AMS = {}} - SVG.resetGlyphs(true); + if (SVG.resetGlyphs) SVG.resetGlyphs(true); if (data.useGlobalCache) { state.glyphs = {}; state.defs = HTML.Element("defs"); @@ -826,7 +843,7 @@ function ReturnResult(result) { var state = data.state; if (state) { var AMS = MathJax.Extension["TeX/AMSmath"]; - var GLYPH = MathJax.OutputJax.SVG.BBOX.GLYPH; + var GLYPH = (MathJax.OutputJax.SVG||{}).BBOX.GLYPH; state.AMS.startNumber = AMS.startNumber; state.AMS.labels = AMS.labels; state.AMS.IDs = AMS.IDs;