@@ -115,8 +115,8 @@ var CHTMLSTYLES; // filled in when CommonHTML is loaded
115115// the jax to be loaded completely)
116116//
117117function GetWindow ( ) {
118- var virtualConsole = new jsdom . VirtualConsole ( ) ;
119- virtualConsole . sendTo ( console ) ;
118+ var virtualConsole = new jsdom . VirtualConsole ( ) ;
119+ virtualConsole . sendTo ( console ) ;
120120 window = new JSDOM ( '' , {
121121 virtualConsole : virtualConsole ,
122122 userAgent : "Node.js" ,
@@ -141,7 +141,6 @@ function ConfigureMathJax() {
141141 //
142142 // Load all input jax and preprocessors
143143 // Load AMS extensions and the autoload extension for TeX
144- // Allow $...$ delimiters and don't create previews for any preprocessor,
145144 // Create stand-alone SVG elements with font caches by default
146145 // (users can override that)
147146 //
@@ -478,6 +477,18 @@ function ConfigureMathJax() {
478477
479478 } ) ;
480479
480+ //
481+ // Set up None output jax (for when only MathML output is needed)
482+ //
483+ MathJax . OutputJax . None = MathJax . OutputJax ( {
484+ id : "None" ,
485+ preTranslate : function ( ) { } ,
486+ Translate : function ( ) { } ,
487+ postTranslate : function ( ) { }
488+ } ) ;
489+ MathJax . OutputJax . None . loadComplete ( "jax.js" ) ;
490+ MathJax . OutputJax . None . Register ( "jax/mml" ) ;
491+
481492 //
482493 // Reset the color extension after `autoload-all`
483494 //
@@ -497,14 +508,14 @@ function ConfigureMathJax() {
497508 // (reseting the counters so that the initial math doesn't affect them)
498509 //
499510 MathJax . Hub . Register . StartupHook ( "End" , function ( ) {
500- MathJax . OutputJax . SVG . resetGlyphs ( true ) ;
511+ if ( MathJax . OutputJax . SVG . resetGlyphs ) MathJax . OutputJax . SVG . resetGlyphs ( true ) ;
501512 MathJax . ElementJax . mml . ID = 0 ;
502513 serverState = STATE . READY ;
503514 MathJax . Hub . Queue ( StartQueue ) ;
504515 } ) ;
505516 }
506517 } ;
507-
518+
508519 if ( extensions ) {
509520 //
510521 // Parse added extensions list and add to standard ones
@@ -592,7 +603,7 @@ function AddError(message,nopush) {
592603function GetMML ( result ) {
593604 if ( ! data . mml && ! data . mmlNode ) return ;
594605 var jax = MathJax . Hub . getAllJax ( ) [ 0 ] ;
595- if ( data . speakText && ! jax . root . alttext ) {
606+ if ( data . speakText && ! jax . root . alttext ) {
596607 jax . root . alttext = result . speakText ;
597608 var attrNames = jax . root . attrNames ;
598609 if ( attrNames && attrNames . indexOf ( "alttext" ) === - 1 ) {
@@ -749,7 +760,13 @@ function StartQueue() {
749760 //
750761 GetState ( data . state ) ;
751762
752- var renderer = ( ( data . html || data . htmlNode || data . css ) ? "CommonHTML" : "SVG" ) ;
763+ //
764+ // Get the renderer to use
765+ //
766+ var renderer = (
767+ ( data . html || data . htmlNode || data . css ) ? "CommonHTML" :
768+ ( data . svg || data . svgNode ) ? "SVG" : "None"
769+ ) ;
753770
754771 //
755772 // Set up a timeout timer to restart MathJax if it runs too long,
@@ -780,7 +797,7 @@ function GetState(state) {
780797 MML = MathJax . ElementJax . mml ,
781798 AMS = MathJax . Extension [ "TeX/AMSmath" ] ,
782799 HUB = MathJax . Hub , HTML = MathJax . HTML ,
783- GLYPH = SVG . BBOX . GLYPH ;
800+ GLYPH = ( SVG . BBOX || { } ) . GLYPH ;
784801
785802 if ( state && state . AMS ) {
786803 AMS . startNumber = state . AMS . startNumber ;
@@ -793,7 +810,7 @@ function GetState(state) {
793810 ID = state . ID ;
794811 } else {
795812 if ( state ) { state . AMS = { } }
796- SVG . resetGlyphs ( true ) ;
813+ if ( SVG . resetGlyphs ) SVG . resetGlyphs ( true ) ;
797814 if ( data . useGlobalCache ) {
798815 state . glyphs = { } ;
799816 state . defs = HTML . Element ( "defs" ) ;
@@ -826,7 +843,7 @@ function ReturnResult(result) {
826843 var state = data . state ;
827844 if ( state ) {
828845 var AMS = MathJax . Extension [ "TeX/AMSmath" ] ;
829- var GLYPH = MathJax . OutputJax . SVG . BBOX . GLYPH ;
846+ var GLYPH = ( MathJax . OutputJax . SVG || { } ) . BBOX . GLYPH ;
830847 state . AMS . startNumber = AMS . startNumber ;
831848 state . AMS . labels = AMS . labels ;
832849 state . AMS . IDs = AMS . IDs ;
0 commit comments