Skip to content

Commit

Permalink
Merge pull request #413 from mathjax/develop
Browse files Browse the repository at this point in the history
Version 2.1.1
  • Loading branch information
dpvc authored Jun 5, 2018
2 parents a3c7182 + e9a6f00 commit 08f566c
Show file tree
Hide file tree
Showing 33 changed files with 643 additions and 518 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ node_js:
- '7'
- '8'
- '9'
- '10'
- stable
sudo: false
script:
Expand Down
33 changes: 25 additions & 8 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ var STATE = {
STOPPED: 1, // no DOM or MathJax available
STARTED: 2, // DOM loaded, MathJax starting up
READY: 3, // MathJax initialized and ready to process math
BUSY: 4 // MathJax currently processing math
BUSY: 4, // MathJax currently processing math
RESTART: 5, // start() called while MathJax is starting up
};

//
Expand All @@ -91,6 +92,7 @@ var document, window, content, html; // the DOM elements
var queue = []; // queue of typesetting requests of the form [data,callback]
var data, callback, originalData; // the current queue item
var errors = []; // errors collected durring the typesetting
var sErrors = []; // errors collected durring MathJax startup
var ID = 0; // id for this SVG element

//
Expand Down Expand Up @@ -518,8 +520,15 @@ function ConfigureMathJax() {
MathJax.Hub.Register.StartupHook("End",function () {
if (MathJax.OutputJax.SVG.resetGlyphs) MathJax.OutputJax.SVG.resetGlyphs(true);
MathJax.ElementJax.mml.ID = 0;
serverState = STATE.READY;
MathJax.Hub.Queue(StartQueue);
if (serverState === STATE.RESTART) {
setTimeout(RestartMathJax, 100);
} else {
serverState = STATE.READY;
MathJax.Hub.Queue(
function () {sErrors = errors},
StartQueue
);
}
});
}
};
Expand All @@ -528,7 +537,7 @@ function ConfigureMathJax() {
//
// Parse added extensions list and add to standard ones
//
var extensionList = extensions.split(/s*,\s*/);
var extensionList = extensions.split(/\s*,\s*/);
for (var i = 0; i < extensionList.length; i++) {
var matches = extensionList[i].match(/^(.*?)(\.js)?$/);
window.MathJax.extensions.push(matches[1] + '.js');
Expand Down Expand Up @@ -730,7 +739,7 @@ function GetSVG(result) {
//
function StartQueue() {
data = callback = originalData = null; // clear existing equation, if any
errors = []; // clear any errors
errors = sErrors; sErrors = []; // clear any errors
if (!queue.length) return; // return if nothing to do

serverState = STATE.BUSY;
Expand Down Expand Up @@ -943,9 +952,17 @@ exports.typeset = function (data, callback) {

//
// Manually start MathJax (this is done automatically
// when the first typeset() call is made)
//
exports.start = function () {RestartMathJax()}
// when the first typeset() call is made), but delay
// restart if we are already starting up (prevents
// multiple calls to start() from causing confusion).
//
exports.start = function () {
if (serverState === STATE.STARTED) {
serverState = STATE.RESTART;
} else if (serverState !== STATE.ABORT) {
RestartMathJax();
}
}

//
// Configure MathJax and the API
Expand Down
Loading

0 comments on commit 08f566c

Please sign in to comment.