Skip to content

Commit 5cd3ba0

Browse files
committed
simplify
1 parent 7be4e73 commit 5cd3ba0

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

devtools/test_dashboard/index-mathjax3.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<html>
33
<head>
44
<title>Plotly.js Devtools - MathJax v3 loaded with svg output</title>
5+
<p>MathJax $V^3$ with $svg$ output on the page as well as plotly graphs</p>
56
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans:600,400,300,200|Droid+Sans|PT+Sans+Narrow|Gravitas+One|Droid+Sans+Mono|Droid+Serif|Raleway|Old+Standard+TT"/>
67
<link rel="stylesheet" type="text/css" href="./style.css">
78
</head>
@@ -20,7 +21,7 @@
2021
</div>
2122
<div id="snapshot"></div>
2223

23-
<script src="../../node_modules/mathjax-v3/es5/tex-mml-svg.js"></script>
24+
<script src="../../node_modules/mathjax-v3/es5/tex-svg.js"></script>
2425
<script charset="utf-8" id="source" type="module">import "../../build/plotly.js"</script>
2526
<script charset="utf-8" src="../../build/test_dashboard-bundle.js"></script>
2627
</body>

devtools/test_dashboard/index-mathjax3chtml.html

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,44 +23,43 @@
2323

2424
<script>
2525
window.MathJax = window.MathJax || {
26+
// see https://github.com/mathjax/MathJax/issues/2705#issuecomment-859742446
2627
loader: {load: ['output/svg']},
2728
startup: {
2829
ready() {
29-
//
30-
// Get the MathJax modules that we need.
31-
//
30+
// Get the MathJax modules that we need.
3231
const {mathjax} = MathJax._.mathjax;
3332
const {SVG} = MathJax._.output.svg_ts;
34-
//
33+
3534
// Do the normal setup
36-
//
3735
MathJax.startup.defaultReady();
38-
//
39-
// Create an SVG output jax and a new MathDocument that uses it.
40-
//
36+
37+
// Create an SVG output jax and a new MathDocument that uses it.
4138
const svgOutput = new SVG(MathJax.config.svg);
4239
const svgDocument = mathjax.document(document, {
4340
...MathJax.config.options,
4441
InputJax: MathJax.startup.input,
4542
OutputJax: svgOutput
4643
});
47-
//
48-
// Define the SVG-based conversion methods
49-
//
44+
45+
// Define the SVG-based conversion methods
5046
MathJax.tex2svg = (math, options = {}) => {
5147
options.format = svgDocument.inputJax[0].name;
5248
return svgDocument.convert(math, options);
5349
};
50+
/*
5451
MathJax.tex2svgPromise = (math, options = {}) => {
5552
options.format = svgDocument.inputJax[0].name;
5653
return mathjax.handleRetriesFor(() => svgDocument.convert(math, options));
5754
};
55+
*/
5856
MathJax.svgStylesheet = () => svgOutput.styleSheet(svgDocument);
5957
}
6058
}
6159
};
6260
</script>
63-
<script src="../../node_modules/mathjax-v3/es5/tex-mml-chtml.js"></script>
61+
<script src="../../node_modules/mathjax-v3/es5/tex-chtml.js"></script>
62+
6463
<script charset="utf-8" id="source" type="module">import "../../build/plotly.js"</script>
6564
<script charset="utf-8" src="../../build/test_dashboard-bundle.js"></script>
6665
</body>

src/lib/svg_text_utils.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@ function texToSVG(_texString, _config, _callback) {
224224
}
225225
} else {
226226
originalRenderer = MathJax.config.startup.output;
227-
MathJax.config.startup.output = 'svg';
227+
if(originalRenderer !== 'svg') {
228+
MathJax.config.startup.output = 'svg';
229+
}
228230
}
229231
};
230232

@@ -306,10 +308,8 @@ function texToSVG(_texString, _config, _callback) {
306308
setConfig();
307309
setRenderer();
308310
MathJax.startup.defaultReady();
309-
MathJax.startup.promise.then(function() {
310-
initiateMathJax();
311-
finalizeMathJax();
312-
});
311+
initiateMathJax();
312+
finalizeMathJax();
313313
resetRenderer();
314314
resetConfig();
315315
}

test/jasmine/bundle_tests/mathjax_v3_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ describe('Test MathJax v3:', function() {
2323
mathJaxScriptTag.onerror = function() {
2424
fail('MathJax v3 failed to load');
2525
};
26-
mathJaxScriptTag.src = '/base/node_modules/mathjax-v3/es5/tex-mml-svg.js';
26+
mathJaxScriptTag.src = '/base/node_modules/mathjax-v3/es5/tex-svg.js';
2727
document.body.appendChild(mathJaxScriptTag);
2828
});
2929

0 commit comments

Comments
 (0)