Skip to content

Commit 8f18918

Browse files
authored
Fix #307 (#314)
* [test] add test for #307 * [main] user configuration with autload-all should enable color extension Fixes #307
1 parent 408f0ff commit 8f18918

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

lib/main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ function ConfigureMathJax() {
422422
//
423423
// Reset the color extension after `autoload-all`
424424
//
425-
if (MathJax.AuthorConfig.extensions.indexOf("TeX/color.js") == -1) {
425+
if (MathJax.AuthorConfig.extensions.indexOf("TeX/color.js") == -1 && MathJax.AuthorConfig.extensions.indexOf("TeX/autoload-all.js") == -1) {
426426
MathJax.Hub.Register.StartupHook("TeX autoload-all Ready",function () {
427427
var macros = MathJax.InputJax.TeX.Definitions.macros;
428428
macros.color = "Color";

test/userconfig-autoload.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+
4+
tape('User config: autoload-all should enable color extension', function(t) {
5+
t.plan(1);
6+
7+
var tex = '\\definecolor{myorange}{RGB}{255,165,100}\\color{myorange}e^{i \\pi}\\color{Black} = -1';
8+
mjAPI.config( {
9+
extensions: 'TeX/autoload-all', // a convenience option to add MathJax extensions
10+
});
11+
mjAPI.start();
12+
13+
mjAPI.typeset({
14+
math: tex,
15+
format: "inline-TeX",
16+
mml: true
17+
}, function(data) {
18+
t.ok(!data.errors, 'definecolor should be a known function');
19+
});
20+
});

0 commit comments

Comments
 (0)