Skip to content

Commit 187ffd0

Browse files
committed
wrap mathjax_config into function
... so that one can call it after dynamically adding MathJax <script> on page.
1 parent ea6e76f commit 187ffd0

File tree

2 files changed

+16
-22
lines changed

2 files changed

+16
-22
lines changed

src/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ require('es6-promise').polyfill();
1818
require('../build/plotcss');
1919

2020
// inject default MathJax config
21-
require('./fonts/mathjax_config');
21+
require('./fonts/mathjax_config')();
2222

2323
// include registry module and expose register method
2424
var Registry = require('./registry');

src/fonts/mathjax_config.js

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,20 @@
1010

1111
/* global MathJax:false */
1212

13-
/**
14-
* Check and configure MathJax
15-
*/
16-
if(typeof MathJax !== 'undefined') {
17-
exports.MathJax = true;
18-
19-
var globalConfig = (window.PlotlyConfig || {}).MathJaxConfig !== 'local';
13+
module.exports = function() {
14+
if(typeof MathJax !== 'undefined') {
15+
var globalConfig = (window.PlotlyConfig || {}).MathJaxConfig !== 'local';
2016

21-
if(globalConfig) {
22-
MathJax.Hub.Config({
23-
messageStyle: 'none',
24-
skipStartupTypeset: true,
25-
displayAlign: 'left',
26-
tex2jax: {
27-
inlineMath: [['$', '$'], ['\\(', '\\)']]
28-
}
29-
});
30-
MathJax.Hub.Configured();
17+
if(globalConfig) {
18+
MathJax.Hub.Config({
19+
messageStyle: 'none',
20+
skipStartupTypeset: true,
21+
displayAlign: 'left',
22+
tex2jax: {
23+
inlineMath: [['$', '$'], ['\\(', '\\)']]
24+
}
25+
});
26+
MathJax.Hub.Configured();
27+
}
3128
}
32-
33-
} else {
34-
exports.MathJax = false;
35-
}
29+
};

0 commit comments

Comments
 (0)