Skip to content

Commit 51bafd3

Browse files
authored
Merge pull request #317 from mathjax/309
sanitize user configuration
2 parents 87c3768 + 010b7cc commit 51bafd3

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

lib/main.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,6 @@ function ConfigureMathJax() {
145145
jax: ["input/TeX", "input/MathML", "input/AsciiMath", "output/SVG", "output/CommonHTML"],
146146
extensions: ["toMathML.js"],
147147
TeX: {extensions: window.Array("AMSmath.js","AMSsymbols.js","autoload-all.js")},
148-
tex2jax: {inlineMath: [['$','$'],['\\(','\\)']], preview:"none"},
149-
mml2jax: {preview:"none"},
150-
asciimath2jax: {preview:"none"},
151148
SVG: {useFontCache: true, useGlobalCache: false, EqnChunk: 1000000, EqnDelay: 0},
152149
CommonHTML: {EqnChunk: 1000000, EqnDelay: 0, undefinedFamily:"monospace"},
153150

@@ -473,7 +470,11 @@ function ConfigureMathJax() {
473470
}
474471
if (MathJaxConfig) {
475472
adjustArrays(MathJaxConfig);
476-
Insert(window.MathJax,MathJaxConfig);
473+
// merge the defaults into the user configuration (to sanitize)
474+
window.MathJax = Insert(Insert({},MathJaxConfig),window.MathJax);
475+
if (MathJaxConfig.extensions) {
476+
window.MathJax.extensions = window.MathJax.extensions.concat(MathJaxConfig.extensions);
477+
}
477478
}
478479
}
479480

@@ -656,7 +657,7 @@ function StartQueue() {
656657

657658
//
658659
// Get the math data and callback
659-
// and set the content with the proper delimiters
660+
// and set the content with the proper script type
660661
//
661662
var item = queue.shift();
662663
data = item[0]; callback = item[1];
@@ -696,7 +697,7 @@ function StartQueue() {
696697
timer = setTimeout(RestartMathJax,data.timeout);
697698
HUB.Queue(
698699
$$(SetRenderer,renderer),
699-
$$("Typeset",HUB),
700+
$$("Process",HUB),
700701
$$(TypesetDone,result),
701702
$$(GetSpeech,result),
702703
$$(GetMML,result),

test/userconfig-jax.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
var tape = require('tape');
2+
var mjAPI = require('../lib/main.js');
3+
var jsdom = require('jsdom').jsdom;
4+
5+
tape('User configuration with jax array', function (t) {
6+
t.plan(1);
7+
8+
mjAPI.config({
9+
MathJax: {
10+
jax: ["input/MathML", "output/SVG"]
11+
}
12+
});
13+
mjAPI.typeset({
14+
math: '<math><mn>1</mn></math>',
15+
format: 'MathML',
16+
svg: true
17+
}, function (data) {
18+
t.ok(!data.errors, 'No errors');
19+
});
20+
});

0 commit comments

Comments
 (0)