Skip to content

Commit 52ed4f8

Browse files
committed
Add autoload-all extension to predefine macros to autoload the extensions that define them (so MathJax will be able to access all the macros it knows about); update color extension so that it works with this extension better
1 parent 0bc0a8c commit 52ed4f8

File tree

4 files changed

+89
-1
lines changed

4 files changed

+89
-1
lines changed

extensions/TeX/autoload-all.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* /MathJax/extensions/TeX/autoload-all.js
3+
*
4+
* Copyright (c) 2010 Design Science, Inc.
5+
*
6+
* Part of the MathJax library.
7+
* See http://www.mathjax.org for details.
8+
*
9+
* Licensed under the Apache License, Version 2.0;
10+
* you may not use this file except in compliance with the License.
11+
*
12+
* http://www.apache.org/licenses/LICENSE-2.0
13+
*/
14+
15+
MathJax.Extension["TeX/autoload-all"]={version:"2.0"};MathJax.Hub.Register.StartupHook("TeX Jax Ready",function(){var h=MathJax.InputJax.TeX,c=h.Definitions.macros,g=h.Definitions.environment;var f={action:["mathtip","texttip","toggle"],AMSmath:["mathring","nobreakspace","negmedspace","negthickspace","intI","iiiint","idotsint","dddot","ddddot","sideset","boxed","substack","injlim","projlim","varliminf","varlimsup","varinjlim","varprojlim","DeclareMathOperator","operatorname","genfrac","tfrac","dfrac","binom","tbinom","dbinom","cfrac","shoveleft","shoveright","xrightarrow","xleftarrow"],begingroup:["begingroup","endgroup","gdef","global"],cancel:["cancel","bcancel","xcancel","cancelto"],color:["color","colorbox","fcolorbox"],enclose:["enclose"],extpfeil:["Newextarrow","xlongequal","xmapsto","xtofrom","xtwoheadleftarrow","xtwoheadrightarrow"],mhchem:["ce","cee","cf"]};for(var b in f){if(f.hasOwnProperty(b)){var e=f[b];for(var d=0,a=e.length;d<a;d++){c[e[d]]=["Extension",b]}}}g.subarray=["ExtensionEnv",null,"AMSmath"];g.smallmatrix=["ExtensionEnv",null,"AMSmath"];g.equation=["ExtensionEnv",null,"AMSmath"];g["equation*"]=["ExtensionEnv",null,"AMSmath"];MathJax.Hub.Startup.signal.Post("TeX autoload-all Ready")});MathJax.Callback.Queue(["Require",MathJax.Ajax,"[MathJax]/extensions/TeX/AMSsymbols.js"],["loadComplete",MathJax.Ajax,"[MathJax]/extensions/TeX/autoload-all.js"]);
16+

extensions/TeX/color.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
/*************************************************************
2+
*
3+
* MathJax/extensions/TeX/autoload-all.js
4+
*
5+
* Provides pre-defined macros to autoload all the extensions
6+
* so that all macros that MathJax knows about are available.
7+
*
8+
* ---------------------------------------------------------------------
9+
*
10+
* Copyright (c) 2012 Design Science, Inc.
11+
*
12+
* Licensed under the Apache License, Version 2.0 (the "License");
13+
* you may not use this file except in compliance with the License.
14+
* You may obtain a copy of the License at
15+
*
16+
* http://www.apache.org/licenses/LICENSE-2.0
17+
*
18+
* Unless required by applicable law or agreed to in writing, software
19+
* distributed under the License is distributed on an "AS IS" BASIS,
20+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21+
* See the License for the specific language governing permissions and
22+
* limitations under the License.
23+
*/
24+
25+
MathJax.Extension["TeX/autoload-all"] = {
26+
version: "2.0"
27+
};
28+
29+
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
30+
var TEX = MathJax.InputJax.TeX,
31+
MACROS = TEX.Definitions.macros,
32+
ENVS = TEX.Definitions.environment;
33+
34+
35+
var EXTENSIONS = {
36+
action: ["mathtip","texttip","toggle"],
37+
AMSmath: ["mathring","nobreakspace","negmedspace","negthickspace","intI",
38+
"iiiint","idotsint","dddot","ddddot","sideset","boxed",
39+
"substack","injlim","projlim","varliminf","varlimsup",
40+
"varinjlim","varprojlim","DeclareMathOperator","operatorname",
41+
"genfrac","tfrac","dfrac","binom","tbinom","dbinom","cfrac",
42+
"shoveleft","shoveright","xrightarrow","xleftarrow"],
43+
begingroup: ["begingroup","endgroup","gdef","global"],
44+
cancel: ["cancel","bcancel","xcancel","cancelto"],
45+
color: ["color","colorbox","fcolorbox"],
46+
enclose: ["enclose"],
47+
extpfeil: ["Newextarrow","xlongequal","xmapsto","xtofrom",
48+
"xtwoheadleftarrow","xtwoheadrightarrow"],
49+
mhchem: ["ce","cee","cf"]
50+
};
51+
52+
for (var name in EXTENSIONS) {if (EXTENSIONS.hasOwnProperty(name)) {
53+
var macros = EXTENSIONS[name];
54+
for (var i = 0, m = macros.length; i < m; i++) {
55+
MACROS[macros[i]] = ["Extension",name];
56+
}
57+
}}
58+
59+
ENVS["subarray"] = ['ExtensionEnv',null,'AMSmath'];
60+
ENVS["smallmatrix"] = ['ExtensionEnv',null,'AMSmath'];
61+
ENVS["equation"] = ['ExtensionEnv',null,'AMSmath'];
62+
ENVS["equation*"] = ['ExtensionEnv',null,'AMSmath'];
63+
64+
MathJax.Hub.Startup.signal.Post("TeX autoload-all Ready");
65+
66+
});
67+
68+
MathJax.Callback.Queue(
69+
["Require",MathJax.Ajax,"[MathJax]/extensions/TeX/AMSsymbols.js"],
70+
["loadComplete",MathJax.Ajax,"[MathJax]/extensions/TeX/autoload-all.js"]
71+
);

unpacked/extensions/TeX/color.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
167167

168168
COLOR.TEX = TEX; // for reference in getColor above
169169

170+
TEX.Definitions.macros.color = "Color";
170171
TEX.Definitions.macros.definecolor = "DefineColor";
171172
TEX.Definitions.macros.colorbox = "ColorBox";
172173
TEX.Definitions.macros.fcolorbox = "fColorBox";

0 commit comments

Comments
 (0)