11/*********************************************************************
22 *
33 * mj-single-svg.js
4- *
4+ *
55 * Implements an API to MathJax in node.js so that MathJax can be
66 * used server-side to generate SVG, MathML, or images (the latter
77 * requires an external library, batik, to do the svg to png
@@ -82,8 +82,8 @@ var STATE = {
8282
8383//
8484// The MathJaxPath is normaized against file:/// so that Windows paths are correct
85- //
86- var MathJaxPath = url . resolve ( "file:///" , "file:" + require . resolve ( 'MathJax /unpacked/MathJax' ) ) ;
85+ //
86+ var MathJaxPath = url . resolve ( "file:///" , "file:" + require . resolve ( 'mathjax /unpacked/MathJax' ) ) ;
8787var BatikRasterizerPath = path . resolve ( __dirname , '..' , 'batik/batik-rasterizer.jar' ) ;
8888var MathJaxConfig ; // configuration for when starting MathJax
8989var MathJax ; // filled in once MathJax is loaded
@@ -133,13 +133,13 @@ function GetWindow() {
133133 // Node's url.resolve() has a problem with resolving a file:// URL when
134134 // the base URL is "about:blank", so force it to be something else (HACK)
135135 // since jsdom 3.x sets the base to "about:blank".
136- //
136+ //
137137 if ( document . _URL === "about:blank" ) document . _URL = "file:///blank.html" ;
138138}
139139
140140//
141141// Set up a Mathjax configuration within the window
142- //
142+ //
143143function ConfigureMathJax ( ) {
144144 window . MathJax = {
145145 //
@@ -170,11 +170,11 @@ function ConfigureMathJax() {
170170 Event :{ } , Touch :{ } , Hover :{ } // fake structure to avid errors
171171 } ;
172172 MathJax . Ajax . loaded [ MathJax . Ajax . fileURL ( "[MathJax]/extensions/MathEvents.js" ) ] = true ;
173-
173+
174174 //
175175 // When creating stylesheets, no need to wait for them
176176 // to become active, so just do the callback
177- //
177+ //
178178 MathJax . Ajax . timer . create = function ( callback , node ) {
179179 callback = MathJax . Callback ( callback ) ;
180180 callback ( this . STATUS . OK ) ;
@@ -194,7 +194,7 @@ function ConfigureMathJax() {
194194 MathJax . Message . Clear = function ( ) { } ;
195195 MathJax . Message . Remove = function ( ) { } ;
196196 MathJax . Message . Init = function ( ) { } ;
197-
197+
198198 //
199199 // Trap Math Processing Errors
200200 //
@@ -220,14 +220,14 @@ function ConfigureMathJax() {
220220 MathJax . Hub . Register . MessageHook ( "file load error" , function ( message ) {
221221 AddError ( "File load error: " + message [ 1 ] ) ;
222222 } ) ;
223-
223+
224224 //
225225 // Set the delays to 0 (we don't need to update the screen)
226226 //
227227 MathJax . Hub . processSectionDelay = 0 ;
228228 MathJax . Hub . processUpdateTime = 10000000 ; // don't interrupt processing of output
229229 MathJax . Hub . processUpdateDelay = 0 ;
230-
230+
231231 //
232232 // Adjust the SVG output jax
233233 //
@@ -300,7 +300,7 @@ function ConfigureMathJax() {
300300 state . SVGdelay = false ;
301301 }
302302 } ) ;
303-
303+
304304 //
305305 // TEXT boxes use getBBox, which isn't implemented, so
306306 // use a monspace font and fake the size. Since these
@@ -344,7 +344,7 @@ function ConfigureMathJax() {
344344 delete STYLES [ ".mjx-chartest .mjx-box" ] ;
345345 delete STYLES [ ".mjx-test" ] ;
346346 delete STYLES [ ".mjx-ex-boxtest" ] ;
347-
347+
348348 CHTML . Augment ( {
349349 //
350350 // Set up the default ex-size and width
@@ -422,7 +422,7 @@ function ConfigureMathJax() {
422422 getHDW : function ( c , name , styles ) {
423423 return { h :.8 , d :.2 , w :c . length * .5 } ;
424424 }
425-
425+
426426 } ) ;
427427
428428 } ) ;
@@ -581,7 +581,7 @@ function GetSVG(result) {
581581 node = MathJax . HTML . Element ( "title" , { id :id + "-Title" } , [ "Equation" ] ) ;
582582 svg . insertBefore ( node , svg . firstChild ) ;
583583 }
584-
584+
585585 //
586586 // SVG data is modified to add linebreaks for readability,
587587 // and to put back the xlink namespace that is removed in HTML5
@@ -645,7 +645,7 @@ function GetPNG(result) {
645645
646646//
647647// Start typesetting the queued expressions
648- //
648+ //
649649function StartQueue ( ) {
650650 data = callback = null ; // clear existing equation, if any
651651 errors = [ ] ; // clear any errors
@@ -686,9 +686,9 @@ function StartQueue() {
686686
687687 //
688688 // Set the state from data.state or clear it
689- //
689+ //
690690 GetState ( data . state ) ;
691-
691+
692692 var renderer = ( data . html ? "CommonHTML" : "SVG" ) ;
693693
694694 //
@@ -714,7 +714,7 @@ function StartQueue() {
714714//
715715// Update the MathJax values from the state,
716716// or clear them if there is no state.
717- //
717+ //
718718function GetState ( state ) {
719719 var SVG = MathJax . OutputJax . SVG ,
720720 TEX = MathJax . InputJax . TeX ,
@@ -749,7 +749,7 @@ function GetState(state) {
749749// When the expression is typeset,
750750// clear the timeout timer, if any,
751751// and update the MathJax state,
752- //
752+ //
753753function TypesetDone ( result ) {
754754 if ( timer ) { clearTimeout ( timer ) ; timer = null }
755755 html . removeAttribute ( "xmlns:" + data . xmlns ) ;
@@ -797,14 +797,14 @@ function RerenderSVG(result) {
797797 ) ;
798798 }
799799}
800-
800+
801801
802802/********************************************************************/
803803
804804//
805805// If MathJax times out, discard the DOM
806806// and load a new one (get a fresh MathJax)
807- //
807+ //
808808function RestartMathJax ( ) {
809809 if ( timer ) {
810810 MathJax . Hub . queue . queue = [ ] ; // clear MathJax queue, so pending operations won't fire
@@ -821,7 +821,7 @@ function RestartMathJax() {
821821
822822//
823823// The API call to typeset an equation
824- //
824+ //
825825// %%% cache results?
826826// %%% check types and values of parameters
827827//
0 commit comments