Skip to content

Commit b4a72b9

Browse files
committed
Prevent the color extension from auto-loading
Fixes #175
1 parent 0ecf8ee commit b4a72b9

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

lib/main.js

+14
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,20 @@ function ConfigureMathJax() {
426426

427427
});
428428

429+
//
430+
// Reset the color extension after `autoload-all`
431+
//
432+
if (MathJax.AuthorConfig.extensions.indexOf("TeX/color.js") == -1) {
433+
MathJax.Hub.Register.StartupHook("TeX autoload-all Ready",function () {
434+
var macros = MathJax.InputJax.TeX.Definitions.macros;
435+
macros.color = "Color";
436+
delete macros.textcolor;
437+
delete macros.colorbox;
438+
delete macros.fcolorbox;
439+
delete macros.definecolor;
440+
});
441+
}
442+
429443
//
430444
// Start the typesetting queue when MathJax is ready
431445
// (reseting the counters so that the initial math doesn't affect them)

test/issue175.js

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
var tape = require('tape');
2+
var mjAPI = require("../lib/main.js");
3+
var jsdom = require('jsdom').jsdom;
4+
5+
tape('color extension should be reset', function(t) {
6+
t.plan(1);
7+
mjAPI.start();
8+
var tex = '\\colorbox{green}{x}';
9+
10+
mjAPI.typeset({
11+
math: tex,
12+
format: "TeX",
13+
mml: true
14+
}, function(data) {
15+
t.ok(data.errors);
16+
});
17+
});

0 commit comments

Comments
 (0)