@@ -74,7 +74,8 @@ var STATE = {
74
74
STOPPED : 1 , // no DOM or MathJax available
75
75
STARTED : 2 , // DOM loaded, MathJax starting up
76
76
READY : 3 , // MathJax initialized and ready to process math
77
- BUSY : 4 // MathJax currently processing math
77
+ BUSY : 4 , // MathJax currently processing math
78
+ RESTART : 5 , // start() called while MathJax is starting up
78
79
} ;
79
80
80
81
//
@@ -519,11 +520,15 @@ function ConfigureMathJax() {
519
520
MathJax . Hub . Register . StartupHook ( "End" , function ( ) {
520
521
if ( MathJax . OutputJax . SVG . resetGlyphs ) MathJax . OutputJax . SVG . resetGlyphs ( true ) ;
521
522
MathJax . ElementJax . mml . ID = 0 ;
522
- serverState = STATE . READY ;
523
- MathJax . Hub . Queue (
523
+ if ( serverState === STATE . RESTART ) {
524
+ setTimeout ( RestartMathJax , 100 ) ;
525
+ } else {
526
+ serverState = STATE . READY ;
527
+ MathJax . Hub . Queue (
524
528
function ( ) { sErrors = errors } ,
525
529
StartQueue
526
530
) ;
531
+ }
527
532
} ) ;
528
533
}
529
534
} ;
@@ -947,9 +952,17 @@ exports.typeset = function (data, callback) {
947
952
948
953
//
949
954
// Manually start MathJax (this is done automatically
950
- // when the first typeset() call is made)
951
- //
952
- exports . start = function ( ) { RestartMathJax ( ) }
955
+ // when the first typeset() call is made), but delay
956
+ // restart if we are already starting up (prevents
957
+ // multiple calls to start() from causing confusion).
958
+ //
959
+ exports . start = function ( ) {
960
+ if ( serverState === STATE . STARTED ) {
961
+ serverState = STATE . RESTART ;
962
+ } else if ( serverState !== STATE . ABORT ) {
963
+ RestartMathJax ( ) ;
964
+ }
965
+ }
953
966
954
967
//
955
968
// Configure MathJax and the API
0 commit comments