Skip to content

Commit fbed4bd

Browse files
committed
Merge develop into issue1544
2 parents 47a072f + 4db3f74 commit fbed4bd

File tree

52 files changed

+654
-532
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+654
-532
lines changed

unpacked/MathJax.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -2505,6 +2505,11 @@ MathJax.Hub.Startup = {
25052505
Config: function () {
25062506
this.queue.Push(["Post",this.signal,"Begin Config"]);
25072507
//
2508+
// Make sure root is set before loading any files
2509+
//
2510+
if (MathJax.AuthorConfig && MathJax.AuthorConfig.root)
2511+
MathJax.Ajax.config.root = MathJax.AuthorConfig.root;
2512+
//
25082513
// If a locale is given as a parameter,
25092514
// set the locale and the default menu value for the locale
25102515
//
@@ -2554,15 +2559,15 @@ MathJax.Hub.Startup = {
25542559
//
25552560
ConfigBlocks: function () {
25562561
var scripts = document.getElementsByTagName("script");
2557-
var last = null, queue = MathJax.Callback.Queue();
2562+
var queue = MathJax.Callback.Queue();
25582563
for (var i = 0, m = scripts.length; i < m; i++) {
25592564
var type = String(scripts[i].type).replace(/ /g,"");
25602565
if (type.match(/^text\/x-mathjax-config(;.*)?$/) && !type.match(/;executed=true/)) {
25612566
scripts[i].type += ";executed=true";
2562-
last = queue.Push(scripts[i].innerHTML+";\n1;");
2567+
queue.Push(scripts[i].innerHTML+";\n1;");
25632568
}
25642569
}
2565-
return last;
2570+
return queue.Push(function () {MathJax.Ajax.config.root = MathJax.Hub.config.root});
25662571
},
25672572

25682573
//

unpacked/extensions/MathML/content-mathml.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,18 @@ MathJax.Extension["MathML/content-mathml"] = (function(HUB) {
190190
*/
191191
appendToken: function(parentNode,name,textContent) {
192192
var element = CToP.createElement(name);
193-
element.appendChild(document.createTextNode(textContent));
193+
if (name === 'mn' && textContent.substr(0,1) === "-") {
194+
//
195+
// use <mrow><mo>&#x2212;</mo><mn>n</mn></mrow> instead of <mn>-n</mn>
196+
//
197+
element.appendChild(document.createTextNode(textContent.substr(1)));
198+
var mrow = CToP.createElement('mrow');
199+
CToP.appendToken(mrow,'mo','\u2212');
200+
mrow.appendChild(element);
201+
element = mrow;
202+
} else {
203+
element.appendChild(document.createTextNode(textContent));
204+
}
194205
parentNode.appendChild(element);
195206
return element;
196207
},

unpacked/extensions/TeX/AMSmath.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,10 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
145145
},
146146

147147
delimiter: {
148-
'\\lvert': ['2223',{texClass:MML.TEXCLASS.OPEN}],
149-
'\\rvert': ['2223',{texClass:MML.TEXCLASS.CLOSE}],
150-
'\\lVert': ['2225',{texClass:MML.TEXCLASS.OPEN}],
151-
'\\rVert': ['2225',{texClass:MML.TEXCLASS.CLOSE}]
148+
'\\lvert': ['007C',{texClass:MML.TEXCLASS.OPEN}],
149+
'\\rvert': ['007C',{texClass:MML.TEXCLASS.CLOSE}],
150+
'\\lVert': ['2016',{texClass:MML.TEXCLASS.OPEN}],
151+
'\\rVert': ['2016',{texClass:MML.TEXCLASS.CLOSE}]
152152
}
153153
},null,true);
154154

unpacked/extensions/TeX/newcommand.js

+10-7
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,12 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
5151
* Implement \newcommand{\name}[n][default]{...}
5252
*/
5353
NewCommand: function (name) {
54-
var cs = this.trimSpaces(this.GetArgument(name)),
54+
var CS = this.GetArgument(name), cs = this.trimSpaces(CS),
5555
n = this.GetBrackets(name),
5656
opt = this.GetBrackets(name),
5757
def = this.GetArgument(name);
5858
if (cs.charAt(0) === "\\") {cs = cs.substr(1)}
59+
if (cs === "" && CS.substr(CS.length-1,1) === " ") {cs += " "}
5960
if (!cs.match(/^(.|[a-z]+)$/i)) {
6061
TEX.Error(["IllegalControlSequenceName",
6162
"Illegal control sequence name for %1",name]);
@@ -120,10 +121,11 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
120121
name = this.GetCSname(name);
121122
macro = this.csFindMacro(name);
122123
if (!macro) {
123-
if (TEXDEF.mathchar0mi[name]) {macro = ["csMathchar0mi",TEXDEF.mathchar0mi[name]]} else
124-
if (TEXDEF.mathchar0mo[name]) {macro = ["csMathchar0mo",TEXDEF.mathchar0mo[name]]} else
125-
if (TEXDEF.mathchar7[name]) {macro = ["csMathchar7",TEXDEF.mathchar7[name]]} else
126-
if (TEXDEF.delimiter["\\"+name] != null) {macro = ["csDelimiter",TEXDEF.delimiter["\\"+name]]}
124+
if (TEXDEF.mathchar0mi[name]) {macro = ["csMathchar0mi",TEXDEF.mathchar0mi[name]]} else
125+
if (TEXDEF.mathchar0mo[name]) {macro = ["csMathchar0mo",TEXDEF.mathchar0mo[name]]} else
126+
if (TEXDEF.mathchar7[name]) {macro = ["csMathchar7",TEXDEF.mathchar7[name]]} else
127+
if (TEXDEF.delimiter["\\"+name] != null) {macro = ["csDelimiter",TEXDEF.delimiter["\\"+name]]} else
128+
return;
127129
}
128130
} else {macro = ["Macro",c]; this.i++}
129131
this.setDef(cs,macro);
@@ -145,8 +147,9 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
145147
TEX.Error(["MissingCS",
146148
"%1 must be followed by a control sequence", cmd])
147149
}
148-
var cs = this.trimSpaces(this.GetArgument(cmd));
149-
return cs.substr(1);
150+
var cs = this.GetArgument(cmd), CS = this.trimSpaces(cs);
151+
if (CS == "\\" && cs.substr(cs.length-1,1) === " ") {CS += " "}
152+
return CS.substr(1);
150153
},
151154

152155
/*

unpacked/extensions/asciimath2jax.js

+23-16
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,21 @@ MathJax.Extension.asciimath2jax = {
4848
// are ignored. Note that this is a regular expression,
4949
// so be sure to quote any regexp special characters
5050

51-
preview: "AsciiMath" // set to "none" to not insert MathJax_Preview spans
51+
preview: "AsciiMath" // set to "none" to not insert MathJax_Preview spans
5252
// or set to an array specifying an HTML snippet
5353
// to use the same preview for every equation.
5454

5555
},
5656

57+
//
58+
// Tags to ignore when searching for AsciiMath in the page
59+
//
60+
ignoreTags: {
61+
br: (MathJax.Hub.Browser.isMSIE && document.documentMode < 9 ? "\n" : " "),
62+
wbr: "",
63+
"#comment": ""
64+
},
65+
5766
PreProcess: function (element) {
5867
if (!this.configured) {
5968
this.config = MathJax.Hub.CombineConfig("asciimath2jax",this.config);
@@ -132,8 +141,7 @@ MathJax.Extension.asciimath2jax = {
132141
if (this.search.matched) {element = this.encloseMath(element)}
133142
if (element) {
134143
do {prev = element; element = element.nextSibling}
135-
while (element && (element.nodeName.toLowerCase() === 'br' ||
136-
element.nodeName.toLowerCase() === '#comment'));
144+
while (element && this.ignoreTags[element.nodeName.toLowerCase()] != null);
137145
if (!element || element.nodeName !== '#text') {return prev}
138146
}
139147
}
@@ -172,25 +180,24 @@ MathJax.Extension.asciimath2jax = {
172180
},
173181

174182
encloseMath: function (element) {
175-
var search = this.search, close = search.close, CLOSE, math;
183+
var search = this.search, close = search.close, CLOSE, math, next;
176184
if (search.cpos === close.length) {close = close.nextSibling}
177185
else {close = close.splitText(search.cpos)}
178186
if (!close) {CLOSE = close = MathJax.HTML.addText(search.close.parentNode,"")}
179187
search.close = close;
180188
math = (search.opos ? search.open.splitText(search.opos) : search.open);
181-
while (math.nextSibling && math.nextSibling !== close) {
182-
if (math.nextSibling.nodeValue !== null) {
183-
if (math.nextSibling.nodeName === "#comment") {
184-
math.nodeValue += math.nextSibling.nodeValue.replace(/^\[CDATA\[((.|\n|\r)*)\]\]$/,"$1");
189+
while ((next = math.nextSibling) && next !== close) {
190+
if (next.nodeValue !== null) {
191+
if (next.nodeName === "#comment") {
192+
math.nodeValue += next.nodeValue.replace(/^\[CDATA\[((.|\n|\r)*)\]\]$/,"$1");
185193
} else {
186194
math.nodeValue += math.nextSibling.nodeValue;
187195
}
188-
} else if (this.msieNewlineBug) {
189-
math.nodeValue += (math.nextSibling.nodeName.toLowerCase() === "br" ? "\n" : " ");
190196
} else {
191-
math.nodeValue += " ";
197+
var ignore = this.ignoreTags[next.nodeName.toLowerCase()];
198+
math.nodeValue += (ignore == null ? " " : ignore);
192199
}
193-
math.parentNode.removeChild(math.nextSibling);
200+
math.parentNode.removeChild(next);
194201
}
195202
var AM = math.nodeValue.substr(search.olen,math.nodeValue.length-search.olen-search.clen);
196203
math.parentNode.removeChild(math);
@@ -207,11 +214,13 @@ MathJax.Extension.asciimath2jax = {
207214
},
208215

209216
createPreview: function (mode,asciimath) {
217+
var previewClass = MathJax.Hub.config.preRemoveClass;
210218
var preview = this.config.preview;
211219
if (preview === "none") return;
220+
if ((this.search.close.previousSibling||{}).className === previewClass) return;
212221
if (preview === "AsciiMath") {preview = [this.filterPreview(asciimath)]}
213222
if (preview) {
214-
preview = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass},preview);
223+
preview = MathJax.HTML.Element("span",{className:previewClass},preview);
215224
this.insertNode(preview);
216225
}
217226
},
@@ -224,9 +233,7 @@ MathJax.Extension.asciimath2jax = {
224233
return script;
225234
},
226235

227-
filterPreview: function (asciimath) {return asciimath},
228-
229-
msieNewlineBug: (MathJax.Hub.Browser.isMSIE && (document.documentMode||0) < 9)
236+
filterPreview: function (asciimath) {return asciimath}
230237

231238
};
232239

unpacked/extensions/jsMath2jax.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,13 @@ MathJax.Extension.jsMath2jax = {
7373
},
7474

7575
createPreview: function (node) {
76+
var previewClass = MathJax.Hub.config.preRemoveClass;
7677
var preview = this.config.preview;
78+
if (preview === "none") return;
79+
if ((node.previousSibling||{}).className === previewClass) return;
7780
if (preview === "TeX") {preview = [this.filterPreview(node.innerHTML)]}
7881
if (preview) {
79-
preview = MathJax.HTML.Element("span",{className: MathJax.Hub.config.preRemoveClass},preview);
82+
preview = MathJax.HTML.Element("span",{className:previewClass},preview);
8083
node.parentNode.insertBefore(preview,node);
8184
}
8285
},

unpacked/extensions/mml2jax.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ MathJax.Extension.mml2jax = {
203203
var preview = this.config.preview;
204204
if (preview === "none") return;
205205
var isNodePreview = false;
206+
var previewClass = MathJax.Hub.config.preRemoveClass;
207+
if ((script.previousSibling||{}).className === previewClass) return;
206208
if (preview === "mathml") {
207209
isNodePreview = true;
208210
// mathml preview does not work with IE < 9, so fallback to alttext.
@@ -225,10 +227,10 @@ MathJax.Extension.mml2jax = {
225227
if (preview) {
226228
var span;
227229
if (isNodePreview) {
228-
span = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass});
230+
span = MathJax.HTML.Element("span",{className:previewClass});
229231
span.appendChild(preview);
230232
} else {
231-
span = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass},preview);
233+
span = MathJax.HTML.Element("span",{className:previewClass},preview);
232234
}
233235
script.parentNode.insertBefore(span,script);
234236
}

unpacked/extensions/tex2jax.js

+24-17
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,15 @@ MathJax.Extension.tex2jax = {
7272

7373
},
7474

75+
//
76+
// Tags to ignore when searching for TeX in the page
77+
//
78+
ignoreTags: {
79+
br: (MathJax.Hub.Browser.isMSIE && document.documentMode < 9 ? "\n" : " "),
80+
wbr: "",
81+
"#comment": ""
82+
},
83+
7584
PreProcess: function (element) {
7685
if (!this.configured) {
7786
this.config = MathJax.Hub.CombineConfig("tex2jax",this.config);
@@ -164,8 +173,7 @@ MathJax.Extension.tex2jax = {
164173
if (this.search.matched) {element = this.encloseMath(element)}
165174
if (element) {
166175
do {prev = element; element = element.nextSibling}
167-
while (element && (element.nodeName.toLowerCase() === 'br' ||
168-
element.nodeName.toLowerCase() === '#comment'));
176+
while (element && this.ignoreTags[element.nodeName.toLowerCase()] != null);
169177
if (!element || element.nodeName !== '#text')
170178
{return (this.search.close ? this.prevEndMatch() : prev)}
171179
}
@@ -242,25 +250,24 @@ MathJax.Extension.tex2jax = {
242250
},
243251

244252
encloseMath: function (element) {
245-
var search = this.search, close = search.close, CLOSE, math;
253+
var search = this.search, close = search.close, CLOSE, math, next;
246254
if (search.cpos === close.length) {close = close.nextSibling}
247255
else {close = close.splitText(search.cpos)}
248256
if (!close) {CLOSE = close = MathJax.HTML.addText(search.close.parentNode,"")}
249257
search.close = close;
250258
math = (search.opos ? search.open.splitText(search.opos) : search.open);
251-
while (math.nextSibling && math.nextSibling !== close) {
252-
if (math.nextSibling.nodeValue !== null) {
253-
if (math.nextSibling.nodeName === "#comment") {
254-
math.nodeValue += math.nextSibling.nodeValue.replace(/^\[CDATA\[((.|\n|\r)*)\]\]$/,"$1");
259+
while ((next = math.nextSibling) && next !== close) {
260+
if (next.nodeValue !== null) {
261+
if (next.nodeName === "#comment") {
262+
math.nodeValue += next.nodeValue.replace(/^\[CDATA\[((.|\n|\r)*)\]\]$/,"$1");
255263
} else {
256-
math.nodeValue += math.nextSibling.nodeValue;
264+
math.nodeValue += next.nodeValue;
257265
}
258-
} else if (this.msieNewlineBug) {
259-
math.nodeValue += (math.nextSibling.nodeName.toLowerCase() === "br" ? "\n" : " ");
260266
} else {
261-
math.nodeValue += " ";
267+
var ignore = this.ignoreTags[next.nodeName.toLowerCase()];
268+
math.nodeValue += (ignore == null ? " " : ignore);
262269
}
263-
math.parentNode.removeChild(math.nextSibling);
270+
math.parentNode.removeChild(next);
264271
}
265272
var TeX = math.nodeValue.substr(search.olen,math.nodeValue.length-search.olen-search.clen);
266273
math.parentNode.removeChild(math);
@@ -277,11 +284,13 @@ MathJax.Extension.tex2jax = {
277284
},
278285

279286
createPreview: function (mode,tex) {
287+
var previewClass = MathJax.Hub.config.preRemoveClass;
280288
var preview = this.config.preview;
281289
if (preview === "none") return;
290+
if ((this.search.close.previousSibling||{}).className === previewClass) return;
282291
if (preview === "TeX") {preview = [this.filterPreview(tex)]}
283292
if (preview) {
284-
preview = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass},preview);
293+
preview = MathJax.HTML.Element("span",{className:previewClass},preview);
285294
this.insertNode(preview);
286295
}
287296
},
@@ -294,10 +303,8 @@ MathJax.Extension.tex2jax = {
294303
return script;
295304
},
296305

297-
filterPreview: function (tex) {return tex},
298-
299-
msieNewlineBug: (MathJax.Hub.Browser.isMSIE && document.documentMode < 9)
300-
306+
filterPreview: function (tex) {return tex}
307+
301308
};
302309

303310
// We register the preprocessors with the following priorities:

unpacked/jax/input/MathML/jax.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,14 @@
142142
value = this.filterAttribute(name,value);
143143
var defaults = (mml.type === "mstyle" ? MML.math.prototype.defaults : mml.defaults);
144144
if (value != null) {
145-
if (value.toLowerCase() === "true") {value = true}
146-
else if (value.toLowerCase() === "false") {value = false}
145+
var val = value.toLowerCase();
146+
if (val === "true" || val === "false") {
147+
if (typeof (defaults[name]) === "boolean" || defaults[name] === MML.INHERIT ||
148+
(defaults[name] === MML.AUTO &&
149+
(mml.defaultDef == null || typeof(mml.defaultDef[name]) === "boolean"))) {
150+
value = (val === "true");
151+
}
152+
}
147153
if (defaults[name] != null || MML.copyAttributes[name])
148154
{mml[name] = value} else {mml.attr[name] = value}
149155
mml.attrNames.push(name);

unpacked/jax/input/TeX/jax.js

+13-9
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,10 @@
5353
else if (top) {
5454
this.data.push(item);
5555
if (item.env) {
56-
for (var id in this.env)
57-
{if (this.env.hasOwnProperty(id)) {item.env[id] = this.env[id]}}
56+
if (item.copyEnv !== false) {
57+
for (var id in this.env)
58+
{if (this.env.hasOwnProperty(id)) {item.env[id] = this.env[id]}}
59+
}
5860
this.env = item.env;
5961
} else {item.env = this.env}
6062
}
@@ -256,9 +258,9 @@
256258
});
257259

258260
STACKITEM.array = STACKITEM.Subclass({
259-
type: "array", isOpen: true, arraydef: {},
261+
type: "array", isOpen: true, copyEnv: false, arraydef: {},
260262
Init: function () {
261-
this.table = []; this.row = []; this.env = {}; this.frame = []; this.hfill = [];
263+
this.table = []; this.row = []; this.frame = []; this.hfill = [];
262264
this.SUPER(arguments).Init.apply(this,arguments);
263265
},
264266
checkItem: function (item) {
@@ -712,8 +714,8 @@
712714
'\\arrowvert': '23D0',
713715
'\\Arrowvert': '2016',
714716
'\\bracevert': '23AA', // non-standard
715-
'\\Vert': ['2225',{texClass:MML.TEXCLASS.ORD}],
716-
'\\|': ['2225',{texClass:MML.TEXCLASS.ORD}],
717+
'\\Vert': ['2016',{texClass:MML.TEXCLASS.ORD}],
718+
'\\|': ['2016',{texClass:MML.TEXCLASS.ORD}],
717719
'\\vert': ['|',{texClass:MML.TEXCLASS.ORD}],
718720
'\\uparrow': '2191',
719721
'\\downarrow': '2193',
@@ -2214,9 +2216,11 @@
22142216
*/
22152217
fenced: function (open,mml,close) {
22162218
var mrow = MML.mrow().With({open:open, close:close, texClass:MML.TEXCLASS.INNER});
2217-
mrow.Append(MML.mo(open).With({fence:true, stretchy:true, texClass:MML.TEXCLASS.OPEN}));
2218-
if (mml.type === "mrow") {mrow.Append.apply(mrow,mml.data)} else {mrow.Append(mml)}
2219-
mrow.Append(MML.mo(close).With({fence:true, stretchy:true, texClass:MML.TEXCLASS.CLOSE}));
2219+
mrow.Append(
2220+
MML.mo(open).With({fence:true, stretchy:true, symmetric:true, texClass:MML.TEXCLASS.OPEN}),
2221+
mml,
2222+
MML.mo(close).With({fence:true, stretchy:true, symmetric:true, texClass:MML.TEXCLASS.CLOSE})
2223+
);
22202224
return mrow;
22212225
},
22222226
/*

0 commit comments

Comments
 (0)