Skip to content

Commit 5dd56ee

Browse files
committed
remove mathjax render queue
1 parent 3c8d51f commit 5dd56ee

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

src/lib/svg_text_utils.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,14 @@ var inlineMath = [['$', '$'], ['\\(', '\\)']];
196196
// and reuse the same document for all render calls.
197197
var mathjaxReadyPromise = null;
198198

199+
// Verify that the MathJax output is set to SVG
200+
function mathjaxOutputIsSvg() {
201+
var doc = MathJax.startup && MathJax.startup.document;
202+
return !!(doc && doc.outputJax && doc.outputJax.name === 'SVG');
203+
}
204+
199205
function ensureMathJax(MathJaxVersion) {
200-
if(mathjaxReadyPromise) return mathjaxReadyPromise;
206+
if(mathjaxReadyPromise && mathjaxOutputIsSvg()) return mathjaxReadyPromise;
201207

202208
var config = MathJax.config;
203209
var origTex = config.tex;
@@ -230,9 +236,6 @@ function ensureMathJax(MathJaxVersion) {
230236
return mathjaxReadyPromise;
231237
}
232238

233-
// Serialize MathJax renders in a queue so they don't interfere with each other
234-
var mathjaxQueue = Promise.resolve();
235-
236239
function texToSVG(_texString, _config, _callback) {
237240
const MathJaxVersion = parseInt(
238241
(MathJax.version || '').split('.')[0]
@@ -247,14 +250,7 @@ function texToSVG(_texString, _config, _callback) {
247250
return Promise.resolve();
248251
}
249252

250-
var result = mathjaxQueue.then(function() {
251-
return renderTex(_texString, _config, _callback, MathJaxVersion);
252-
});
253-
254-
// swallow rejections so one failed render doesn't prevent subsequent renders
255-
mathjaxQueue = result.catch(function() {});
256-
257-
return result;
253+
return renderTex(_texString, _config, _callback, MathJaxVersion);
258254
}
259255

260256
function renderTex(_texString, _config, _callback, MathJaxVersion) {

0 commit comments

Comments
 (0)