Debian Codegraph @

ts/input/asciimath/mathjax2/legacy/jax/element/mml/jax.js

raw
1 /* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
2 /* vim: set ts=2 et sw=2 tw=80: */
3
4 /*************************************************************
5 *
6 * MathJax/jax/element/mml/jax.js
7 *
8 * Implements the MML ElementJax that holds the internal represetation
9 * of the mathematics on the page. Various InputJax will produce this
10 * format, and the OutputJax will display it in various formats.
11 *
12 * ---------------------------------------------------------------------
13 *
14 * Copyright (c) 2009-2017 The MathJax Consortium
15 *
16 * Licensed under the Apache License, Version 2.0 (the "License");
17 * you may not use this file except in compliance with the License.
18 * You may obtain a copy of the License at
19 *
20 * http://www.apache.org/licenses/LICENSE-2.0
21 *
22 * Unless required by applicable law or agreed to in writing, software
23 * distributed under the License is distributed on an "AS IS" BASIS,
24 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25 * See the License for the specific language governing permissions and
26 * limitations under the License.
27 */
28
29 MathJax.ElementJax.mml = MathJax.ElementJax({
30 mimeType: "jax/mml"
31 },{
32 id: "mml",
33 version: "2.7.2",
34 directory: MathJax.ElementJax.directory + "/mml",
35 extensionDir: MathJax.ElementJax.extensionDir + "/mml",
36 optableDir: MathJax.ElementJax.directory + "/mml/optable"
37 });
38
39 MathJax.ElementJax.mml.Augment({
40 Init: function () {
41 if (arguments.length === 1 && arguments[0].type === "math") {this.root = arguments[0]}
42 else {this.root = MathJax.ElementJax.mml.math.apply(this,arguments)}
43 if (this.root.attr && this.root.attr.mode) {
44 if (!this.root.display && this.root.attr.mode === "display") {
45 this.root.display = "block";
46 this.root.attrNames.push("display");
47 }
48 delete this.root.attr.mode;
49 for (var i = 0, m = this.root.attrNames.length; i < m; i++) {
50 if (this.root.attrNames[i] === "mode") {this.root.attrNames.splice(i,1); break}
51 }
52 }
53 }
54 },{
55 // VS Q: These two do what?
56 INHERIT: "_inherit_",
57 AUTO: "_auto_",
58 SIZE: {
59 INFINITY: "infinity",
60 SMALL: "small",
61 NORMAL: "normal",
62 BIG: "big"
63 },
64 COLOR: {
65 TRANSPARENT: "transparent"
66 },
67 VARIANT: {
68 NORMAL: "normal",
69 BOLD: "bold",
70 ITALIC: "italic",
71 BOLDITALIC: "bold-italic",
72 DOUBLESTRUCK: "double-struck",
73 FRAKTUR: "fraktur",
74 BOLDFRAKTUR: "bold-fraktur",
75 SCRIPT: "script",
76 BOLDSCRIPT: "bold-script",
77 SANSSERIF: "sans-serif",
78 BOLDSANSSERIF: "bold-sans-serif",
79 SANSSERIFITALIC: "sans-serif-italic",
80 SANSSERIFBOLDITALIC: "sans-serif-bold-italic",
81 MONOSPACE: "monospace",
82 INITIAL: "inital",
83 TAILED: "tailed",
84 LOOPED: "looped",
85 STRETCHED: "stretched",
86 CALIGRAPHIC: "-tex-caligraphic",
87 OLDSTYLE: "-tex-oldstyle"
88 },
89 FORM: {
90 PREFIX: "prefix",
91 INFIX: "infix",
92 POSTFIX: "postfix"
93 },
94 LINEBREAK: {
95 AUTO: "auto",
96 NEWLINE: "newline",
97 NOBREAK: "nobreak",
98 GOODBREAK: "goodbreak",
99 BADBREAK: "badbreak"
100 },
101 LINEBREAKSTYLE: {
102 BEFORE: "before",
103 AFTER: "after",
104 DUPLICATE: "duplicate",
105 INFIXLINBREAKSTYLE: "infixlinebreakstyle"
106 },
107 INDENTALIGN: {
108 LEFT: "left",
109 CENTER: "center",
110 RIGHT: "right",
111 AUTO: "auto",
112 ID: "id",
113 INDENTALIGN: "indentalign"
114 },
115 INDENTSHIFT: {
116 INDENTSHIFT: "indentshift"
117 },
118 LINETHICKNESS: {
119 THIN: "thin",
120 MEDIUM: "medium",
121 THICK: "thick"
122 },
123 NOTATION: {
124 LONGDIV: "longdiv",
125 ACTUARIAL: "actuarial",
126 RADICAL: "radical",
127 BOX: "box",
128 ROUNDEDBOX: "roundedbox",
129 CIRCLE: "circle",
130 LEFT: "left",
131 RIGHT: "right",
132 TOP: "top",
133 BOTTOM: "bottom",
134 UPDIAGONALSTRIKE: "updiagonalstrike",
135 DOWNDIAGONALSTRIKE: "downdiagonalstrike",
136 UPDIAGONALARROW: "updiagonalarrow",
137 VERTICALSTRIKE: "verticalstrike",
138 HORIZONTALSTRIKE: "horizontalstrike",
139 PHASORANGLE: "phasorangle",
140 MADRUWB: "madruwb"
141 },
142 ALIGN: {
143 TOP: "top",
144 BOTTOM: "bottom",
145 CENTER: "center",
146 BASELINE: "baseline",
147 AXIS: "axis",
148 LEFT: "left",
149 RIGHT: "right"
150 },
151 LINES: {
152 NONE: "none",
153 SOLID: "solid",
154 DASHED: "dashed"
155 },
156 SIDE: {
157 LEFT: "left",
158 RIGHT: "right",
159 LEFTOVERLAP: "leftoverlap",
160 RIGHTOVERLAP: "rightoverlap"
161 },
162 WIDTH: {
163 AUTO: "auto",
164 FIT: "fit"
165 },
166 ACTIONTYPE: {
167 TOGGLE: "toggle",
168 STATUSLINE: "statusline",
169 TOOLTIP: "tooltip",
170 INPUT: "input"
171 },
172 LENGTH: {
173 VERYVERYTHINMATHSPACE: "veryverythinmathspace",
174 VERYTHINMATHSPACE: "verythinmathspace",
175 THINMATHSPACE: "thinmathspace",
176 MEDIUMMATHSPACE: "mediummathspace",
177 THICKMATHSPACE: "thickmathspace",
178 VERYTHICKMATHSPACE: "verythickmathspace",
179 VERYVERYTHICKMATHSPACE: "veryverythickmathspace",
180 NEGATIVEVERYVERYTHINMATHSPACE: "negativeveryverythinmathspace",
181 NEGATIVEVERYTHINMATHSPACE: "negativeverythinmathspace",
182 NEGATIVETHINMATHSPACE: "negativethinmathspace",
183 NEGATIVEMEDIUMMATHSPACE: "negativemediummathspace",
184 NEGATIVETHICKMATHSPACE: "negativethickmathspace",
185 NEGATIVEVERYTHICKMATHSPACE: "negativeverythickmathspace",
186 NEGATIVEVERYVERYTHICKMATHSPACE: "negativeveryverythickmathspace"
187 },
188 OVERFLOW: {
189 LINBREAK: "linebreak",
190 SCROLL: "scroll",
191 ELIDE: "elide",
192 TRUNCATE: "truncate",
193 SCALE: "scale"
194 },
195 UNIT: {
196 EM: "em",
197 EX: "ex",
198 PX: "px",
199 IN: "in",
200 CM: "cm",
201 MM: "mm",
202 PT: "pt",
203 PC: "pc"
204 },
205 TEXCLASS: {
206 ORD: 0,
207 OP: 1,
208 BIN: 2,
209 REL: 3,
210 OPEN: 4,
211 CLOSE: 5,
212 PUNCT: 6,
213 INNER: 7,
214 VCENTER: 8,
215 NONE: -1
216 },
217 TEXCLASSNAMES: ["ORD", "OP", "BIN", "REL", "OPEN", "CLOSE", "PUNCT", "INNER", "VCENTER"],
218 skipAttributes: {
219 texClass:true, useHeight:true, texprimestyle:true
220 },
221 copyAttributes: {
222 displaystyle:1, scriptlevel:1, open:1, close:1, form:1,
223 actiontype: 1,
224 fontfamily:true, fontsize:true, fontweight:true, fontstyle:true,
225 color:true, background:true,
226 id:true, "class":1, href:true, style:true
227 },
228 copyAttributeNames: [
229 "displaystyle", "scriptlevel", "open", "close", "form", // force these to be copied
230 "actiontype",
231 "fontfamily", "fontsize", "fontweight", "fontstyle",
232 "color", "background",
233 "id", "class", "href", "style"
234 ],
235 nocopyAttributes: {
236 fontfamily: true, fontsize: true, fontweight: true, fontstyle: true,
237 color: true, background: true,
238 id: true, 'class': true, href: true, style: true,
239 xmlns: true
240 },
241 Error: function (message,def) {
242 var mml = this.merror(message),
243 dir = MathJax.Localization.fontDirection(),
244 font = MathJax.Localization.fontFamily();
245 if (def) {mml = mml.With(def)}
246 if (dir || font) {
247 mml = this.mstyle(mml);
248 if (dir) {mml.dir = dir}
249 if (font) {mml.style.fontFamily = "font-family: "+font}
250 }
251 return mml;
252 }
253 });
254
255 (function (MML) {
256
257 MML.mbase = MathJax.Object.Subclass({
258 type: "base", isToken: false,
259 defaults: {
260 mathbackground: MML.INHERIT,
261 mathcolor: MML.INHERIT,
262 dir: MML.INHERIT
263 },
264 noInherit: {},
265 noInheritAttribute: {
266 texClass: true
267 },
268 getRemoved: {},
269 linebreakContainer: false,
270
271 Init: function () {
272 this.data = [];
273 if (this.inferRow && !(arguments.length === 1 && arguments[0].inferred))
274 {this.Append(MML.mrow().With({inferred: true, notParent: true}))}
275 this.Append.apply(this,arguments);
276 },
277 With: function (def) {
278 for (var id in def) {if (def.hasOwnProperty(id)) {this[id] = def[id]}}
279 return this;
280 },
281 Append: function () {
282 if (this.inferRow && this.data.length) {
283 this.data[0].Append.apply(this.data[0],arguments);
284 } else {
285 for (var i = 0, m = arguments.length; i < m; i++)
286 {this.SetData(this.data.length,arguments[i])}
287 }
288 },
289 SetData: function (i,item) {
290 if (item != null) {
291 if (!(item instanceof MML.mbase))
292 {item = (this.isToken || this.isChars ? MML.chars(item) : MML.mtext(item))}
293 item.parent = this;
294 item.setInherit(this.inheritFromMe ? this : this.inherit);
295 }
296 this.data[i] = item;
297 },
298 Parent: function () {
299 var parent = this.parent;
300 while (parent && parent.notParent) {parent = parent.parent}
301 return parent;
302 },
303 Get: function (name,nodefault,noself) {
304 if (!noself) {
305 if (this[name] != null) {return this[name]}
306 if (this.attr && this.attr[name] != null) {return this.attr[name]}
307 }
308 // FIXME: should cache these values and get from cache
309 // (clear cache when appended to a new object?)
310 var parent = this.Parent();
311 if (parent && parent["adjustChild_"+name] != null) {
312 return (parent["adjustChild_"+name])(this.childPosition(),nodefault);
313 }
314 var obj = this.inherit; var root = obj;
315 while (obj) {
316 var value = obj[name]; if (value == null && obj.attr) {value = obj.attr[name]}
317 if (obj.removedStyles && obj.getRemoved[name] && value == null) value = obj.removedStyles[obj.getRemoved[name]];
318 if (value != null && obj.noInheritAttribute && !obj.noInheritAttribute[name]) {
319 var noInherit = obj.noInherit[this.type];
320 if (!(noInherit && noInherit[name])) {return value}
321 }
322 root = obj; obj = obj.inherit;
323 }
324 if (!nodefault) {
325 if (this.defaults[name] === MML.AUTO) {return this.autoDefault(name)}
326 if (this.defaults[name] !== MML.INHERIT && this.defaults[name] != null)
327 {return this.defaults[name]}
328 if (root) {return root.defaults[name]}
329 }
330 return null;
331 },
332 hasValue: function (name) {return (this.Get(name,true) != null)},
333 getValues: function () {
334 var values = {};
335 for (var i = 0, m = arguments.length; i < m; i++)
336 {values[arguments[i]] = this.Get(arguments[i])}
337 return values;
338 },
339 adjustChild_scriptlevel: function (i,nodef) {return this.Get("scriptlevel",nodef)}, // always inherit from parent
340 adjustChild_displaystyle: function (i,nodef) {return this.Get("displaystyle",nodef)}, // always inherit from parent
341 adjustChild_texprimestyle: function (i,nodef) {return this.Get("texprimestyle",nodef)}, // always inherit from parent
342 childPosition: function () {
343 var child = this, parent = child.parent;
344 while (parent.notParent) {child = parent; parent = child.parent}
345 for (var i = 0, m = parent.data.length; i < m; i++) {if (parent.data[i] === child) {return i}}
346 return null;
347 },
348 setInherit: function (obj) {
349 if (obj !== this.inherit && this.inherit == null) {
350 this.inherit = obj;
351 for (var i = 0, m = this.data.length; i < m; i++) {
352 if (this.data[i] && this.data[i].setInherit) {this.data[i].setInherit(obj)}
353 }
354 }
355 },
356 setTeXclass: function (prev) {
357 this.getPrevClass(prev);
358 return (typeof(this.texClass) !== "undefined" ? this : prev);
359 },
360 getPrevClass: function (prev) {
361 if (prev) {
362 this.prevClass = prev.Get("texClass");
363 this.prevLevel = prev.Get("scriptlevel");
364 }
365 },
366 updateTeXclass: function (core) {
367 if (core) {
368 this.prevClass = core.prevClass; delete core.prevClass;
369 this.prevLevel = core.prevLevel; delete core.prevLevel;
370 this.texClass = core.Get("texClass");
371 }
372 },
373 texSpacing: function () {
374 var prev = (this.prevClass != null ? this.prevClass : MML.TEXCLASS.NONE);
375 var tex = (this.Get("texClass") || MML.TEXCLASS.ORD);
376 if (prev === MML.TEXCLASS.NONE || tex === MML.TEXCLASS.NONE) {return ""}
377 if (prev === MML.TEXCLASS.VCENTER) {prev = MML.TEXCLASS.ORD}
378 if (tex === MML.TEXCLASS.VCENTER) {tex = MML.TEXCLASS.ORD}
379 var space = this.TEXSPACE[prev][tex];
380 if ((this.prevLevel > 0 || this.Get("scriptlevel") > 0) && space >= 0) {return ""}
381 return this.TEXSPACELENGTH[Math.abs(space)];
382 },
383 TEXSPACELENGTH:[
384 "",
385 MML.LENGTH.THINMATHSPACE,
386 MML.LENGTH.MEDIUMMATHSPACE,
387 MML.LENGTH.THICKMATHSPACE
388 ],
389 // See TeXBook Chapter 18 (p. 170)
390 TEXSPACE: [
391 [ 0,-1, 2, 3, 0, 0, 0, 1], // ORD
392 [-1,-1, 0, 3, 0, 0, 0, 1], // OP
393 [ 2, 2, 0, 0, 2, 0, 0, 2], // BIN
394 [ 3, 3, 0, 0, 3, 0, 0, 3], // REL
395 [ 0, 0, 0, 0, 0, 0, 0, 0], // OPEN
396 [ 0,-1, 2, 3, 0, 0, 0, 1], // CLOSE
397 [ 1, 1, 0, 1, 1, 1, 1, 1], // PUNCT
398 [ 1,-1, 2, 3, 1, 0, 1, 1] // INNER
399 ],
400 autoDefault: function (name) {return ""},
401 isSpacelike: function () {return false},
402 isEmbellished: function () {return false},
403 Core: function () {return this},
404 CoreMO: function () {return this},
405 childIndex: function(child) {
406 if (child == null) return;
407 for (var i = 0, m = this.data.length; i < m; i++) if (child === this.data[i]) return i;
408 },
409 CoreIndex: function () {
410 return (this.inferRow ? this.data[0]||this : this).childIndex(this.Core());
411 },
412 hasNewline: function () {
413 if (this.isEmbellished()) {return this.CoreMO().hasNewline()}
414 if (this.isToken || this.linebreakContainer) {return false}
415 for (var i = 0, m = this.data.length; i < m; i++) {
416 if (this.data[i] && this.data[i].hasNewline()) {return true}
417 }
418 return false;
419 },
420 array: function () {if (this.inferred) {return this.data} else {return [this]}},
421 toString: function () {return this.type+"("+this.data.join(",")+")"},
422 getAnnotation: function () {return null}
423 },{
424 childrenSpacelike: function () {
425 for (var i = 0, m = this.data.length; i < m; i++)
426 {if (!this.data[i].isSpacelike()) {return false}}
427 return true;
428 },
429 childEmbellished: function () {
430 return (this.data[0] && this.data[0].isEmbellished());
431 },
432 childCore: function () {return (this.inferRow && this.data[0] ? this.data[0].Core() : this.data[0])},
433 childCoreMO: function () {return (this.data[0] ? this.data[0].CoreMO() : null)},
434 setChildTeXclass: function (prev) {
435 if (this.data[0]) {
436 prev = this.data[0].setTeXclass(prev);
437 this.updateTeXclass(this.data[0]);
438 }
439 return prev;
440 },
441 setBaseTeXclasses: function (prev) {
442 this.getPrevClass(prev); this.texClass = null;
443 if (this.data[0]) {
444 if (this.isEmbellished() || this.data[0].isa(MML.mi)) {
445 prev = this.data[0].setTeXclass(prev);
446 this.updateTeXclass(this.Core());
447 } else {this.data[0].setTeXclass(); prev = this}
448 } else {prev = this}
449 for (var i = 1, m = this.data.length; i < m; i++)
450 {if (this.data[i]) {this.data[i].setTeXclass()}}
451 return prev;
452 },
453 setSeparateTeXclasses: function (prev) {
454 this.getPrevClass(prev);
455 for (var i = 0, m = this.data.length; i < m; i++)
456 {if (this.data[i]) {this.data[i].setTeXclass()}}
457 if (this.isEmbellished()) {this.updateTeXclass(this.Core())}
458 return this;
459 }
460 });
461
462 MML.mi = MML.mbase.Subclass({
463 type: "mi", isToken: true,
464 texClass: MML.TEXCLASS.ORD,
465 defaults: {
466 mathvariant: MML.AUTO,
467 mathsize: MML.INHERIT,
468 mathbackground: MML.INHERIT,
469 mathcolor: MML.INHERIT,
470 dir: MML.INHERIT
471 },
472 autoDefault: function (name) {
473 if (name === "mathvariant") {
474 var mi = (this.data[0]||"").toString();
475 return (mi.length === 1 ||
476 (mi.length === 2 && mi.charCodeAt(0) >= 0xD800 && mi.charCodeAt(0) < 0xDC00) ?
477 MML.VARIANT.ITALIC : MML.VARIANT.NORMAL);
478 }
479 return "";
480 },
481 setTeXclass: function (prev) {
482 this.getPrevClass(prev);
483 var name = this.data.join("");
484 if (name.length > 1 && name.match(/^[a-z][a-z0-9]*$/i) &&
485 this.texClass === MML.TEXCLASS.ORD) {
486 this.texClass = MML.TEXCLASS.OP;
487 this.autoOP = true;
488 }
489 return this;
490 }
491 });
492
493 MML.mn = MML.mbase.Subclass({
494 type: "mn", isToken: true,
495 texClass: MML.TEXCLASS.ORD,
496 defaults: {
497 mathvariant: MML.INHERIT,
498 mathsize: MML.INHERIT,
499 mathbackground: MML.INHERIT,
500 mathcolor: MML.INHERIT,
501 dir: MML.INHERIT
502 }
503 });
504
505 MML.mo = MML.mbase.Subclass({
506 type: "mo", isToken: true,
507 defaults: {
508 mathvariant: MML.INHERIT,
509 mathsize: MML.INHERIT,
510 mathbackground: MML.INHERIT,
511 mathcolor: MML.INHERIT,
512 dir: MML.INHERIT,
513 form: MML.AUTO,
514 fence: MML.AUTO,
515 separator: MML.AUTO,
516 lspace: MML.AUTO,
517 rspace: MML.AUTO,
518 stretchy: MML.AUTO,
519 symmetric: MML.AUTO,
520 maxsize: MML.AUTO,
521 minsize: MML.AUTO,
522 largeop: MML.AUTO,
523 movablelimits: MML.AUTO,
524 accent: MML.AUTO,
525 linebreak: MML.LINEBREAK.AUTO,
526 lineleading: MML.INHERIT,
527 linebreakstyle: MML.AUTO,
528 linebreakmultchar: MML.INHERIT,
529 indentalign: MML.INHERIT,
530 indentshift: MML.INHERIT,
531 indenttarget: MML.INHERIT,
532 indentalignfirst: MML.INHERIT,
533 indentshiftfirst: MML.INHERIT,
534 indentalignlast: MML.INHERIT,
535 indentshiftlast: MML.INHERIT,
536 texClass: MML.AUTO
537 },
538 defaultDef: {
539 form: MML.FORM.INFIX,
540 fence: false,
541 separator: false,
542 lspace: MML.LENGTH.THICKMATHSPACE,
543 rspace: MML.LENGTH.THICKMATHSPACE,
544 stretchy: false,
545 symmetric: false,
546 maxsize: MML.SIZE.INFINITY,
547 minsize: '0em', //'1em',
548 largeop: false,
549 movablelimits: false,
550 accent: false,
551 linebreak: MML.LINEBREAK.AUTO,
552 lineleading: "1ex",
553 linebreakstyle: "before",
554 indentalign: MML.INDENTALIGN.AUTO,
555 indentshift: "0",
556 indenttarget: "",
557 indentalignfirst: MML.INDENTALIGN.INDENTALIGN,
558 indentshiftfirst: MML.INDENTSHIFT.INDENTSHIFT,
559 indentalignlast: MML.INDENTALIGN.INDENTALIGN,
560 indentshiftlast: MML.INDENTSHIFT.INDENTSHIFT,
561 texClass: MML.TEXCLASS.REL // for MML, but TeX sets ORD explicitly
562 },
563 SPACE_ATTR: {lspace: 0x01, rspace: 0x02, form: 0x04},
564 useMMLspacing: 0x07,
565 autoDefault: function (name,nodefault) {
566 var def = this.def;
567 if (!def) {
568 if (name === "form") {this.useMMLspacing &= ~this.SPACE_ATTR.form; return this.getForm()}
569 var mo = this.data.join("");
570 var forms = [this.Get("form"),MML.FORM.INFIX,MML.FORM.POSTFIX,MML.FORM.PREFIX];
571 for (var i = 0, m = forms.length; i < m; i++) {
572 var data = this.OPTABLE[forms[i]][mo];
573 if (data) {def = this.makeDef(data); break}
574 }
575 if (!def) {def = this.CheckRange(mo)}
576 if (!def && nodefault) {def = {}} else {
577 if (!def) {def = MathJax.Hub.Insert({},this.defaultDef)}
578 if (this.parent) {this.def = def} else {def = MathJax.Hub.Insert({},def)}
579 def.form = forms[0];
580 }
581 }
582 this.useMMLspacing &= ~(this.SPACE_ATTR[name] || 0);
583 if (def[name] != null) {return def[name]}
584 else if (!nodefault) {return this.defaultDef[name]}
585 return "";
586 },
587 CheckRange: function (mo) {
588 var n = mo.charCodeAt(0);
589 if (n >= 0xD800 && n < 0xDC00) {n = (((n-0xD800)<<10)+(mo.charCodeAt(1)-0xDC00))+0x10000}
590 for (var i = 0, m = this.RANGES.length; i < m && this.RANGES[i][0] <= n; i++) {
591 if (n <= this.RANGES[i][1]) {
592 if (this.RANGES[i][3]) {
593 var file = MML.optableDir+"/"+this.RANGES[i][3]+".js";
594 this.RANGES[i][3] = null;
595 MathJax.Hub.RestartAfter(MathJax.Ajax.Require(file));
596 }
597 var data = MML.TEXCLASSNAMES[this.RANGES[i][2]];
598 data = this.OPTABLE.infix[mo] = MML.mo.OPTYPES[data === "BIN" ? "BIN3" : data];
599 return this.makeDef(data);
600 }
601 }
602 return null;
603 },
604 makeDef: function (data) {
605 if (data[2] == null) {data[2] = this.defaultDef.texClass}
606 if (!data[3]) {data[3] = {}}
607 var def = MathJax.Hub.Insert({},data[3]);
608 def.lspace = this.SPACE[data[0]]; def.rspace = this.SPACE[data[1]];
609 def.texClass = data[2];
610 if (def.texClass === MML.TEXCLASS.REL &&
611 (this.movablelimits || this.data.join("").match(/^[a-z]+$/i)))
612 {def.texClass = MML.TEXCLASS.OP} // mark named operators as OP
613 return def;
614 },
615 getForm: function () {
616 var core = this, parent = this.parent, Parent = this.Parent();
617 while (Parent && Parent.isEmbellished())
618 {core = parent; parent = Parent.parent; Parent = Parent.Parent()}
619 if (parent && parent.type === "mrow" && parent.NonSpaceLength() !== 1) {
620 if (parent.FirstNonSpace() === core) {return MML.FORM.PREFIX}
621 if (parent.LastNonSpace() === core) {return MML.FORM.POSTFIX}
622 }
623 return MML.FORM.INFIX;
624 },
625 isEmbellished: function () {return true},
626 hasNewline: function () {return (this.Get("linebreak") === MML.LINEBREAK.NEWLINE)},
627 CoreParent: function () {
628 var parent = this;
629 while (parent && parent.isEmbellished() &&
630 parent.CoreMO() === this && !parent.isa(MML.math)) {parent = parent.Parent()}
631 return parent;
632 },
633 CoreText: function (parent) {
634 if (!parent) {return ""}
635 if (parent.isEmbellished()) {return parent.CoreMO().data.join("")}
636 while ((((parent.isa(MML.mrow) || parent.isa(MML.TeXAtom) ||
637 parent.isa(MML.mstyle) || parent.isa(MML.mphantom)) &&
638 parent.data.length === 1) || parent.isa(MML.munderover)) &&
639 parent.data[0]) {parent = parent.data[0]}
640 if (!parent.isToken) {return ""} else {return parent.data.join("")}
641 },
642 remapChars: {
643 '*':"\u2217",
644 '"':"\u2033",
645 "\u00B0":"\u2218",
646 "\u00B2":"2",
647 "\u00B3":"3",
648 "\u00B4":"\u2032",
649 "\u00B9":"1"
650 },
651 remap: function (text,map) {
652 text = text.replace(/-/g,"\u2212");
653 if (map) {
654 text = text.replace(/'/g,"\u2032").replace(/`/g,"\u2035");
655 if (text.length === 1) {text = map[text]||text}
656 }
657 return text;
658 },
659 setTeXclass: function (prev) {
660 var values = this.getValues("form","lspace","rspace","fence"); // sets useMMLspacing
661 if (this.useMMLspacing) {this.texClass = MML.TEXCLASS.NONE; return this}
662 if (values.fence && !this.texClass) {
663 if (values.form === MML.FORM.PREFIX) {this.texClass = MML.TEXCLASS.OPEN}
664 if (values.form === MML.FORM.POSTFIX) {this.texClass = MML.TEXCLASS.CLOSE}
665 }
666 this.texClass = this.Get("texClass");
667 if (this.data.join("") === "\u2061") {
668 // force previous node to be texClass OP, and skip this node
669 if (prev) {prev.texClass = MML.TEXCLASS.OP; prev.fnOP = true}
670 this.texClass = this.prevClass = MML.TEXCLASS.NONE;
671 return prev;
672 }
673 return this.adjustTeXclass(prev);
674 },
675 adjustTeXclass: function (prev) {
676 if (this.texClass === MML.TEXCLASS.NONE) {return prev}
677 if (prev) {
678 if (prev.autoOP && (this.texClass === MML.TEXCLASS.BIN ||
679 this.texClass === MML.TEXCLASS.REL))
680 {prev.texClass = MML.TEXCLASS.ORD}
681 this.prevClass = prev.texClass || MML.TEXCLASS.ORD;
682 this.prevLevel = prev.Get("scriptlevel")
683 } else {this.prevClass = MML.TEXCLASS.NONE}
684 if (this.texClass === MML.TEXCLASS.BIN &&
685 (this.prevClass === MML.TEXCLASS.NONE ||
686 this.prevClass === MML.TEXCLASS.BIN ||
687 this.prevClass === MML.TEXCLASS.OP ||
688 this.prevClass === MML.TEXCLASS.REL ||
689 this.prevClass === MML.TEXCLASS.OPEN ||
690 this.prevClass === MML.TEXCLASS.PUNCT)) {
691 this.texClass = MML.TEXCLASS.ORD;
692 } else if (this.prevClass === MML.TEXCLASS.BIN &&
693 (this.texClass === MML.TEXCLASS.REL ||
694 this.texClass === MML.TEXCLASS.CLOSE ||
695 this.texClass === MML.TEXCLASS.PUNCT)) {
696 prev.texClass = this.prevClass = MML.TEXCLASS.ORD;
697 } else if (this.texClass === MML.TEXCLASS.BIN) {
698 //
699 // Check if node is the last one in its container since the rule
700 // above only takes effect if there is a node that follows.
701 //
702 var child = this, parent = this.parent;
703 while (parent && parent.parent && parent.isEmbellished() &&
704 (parent.data.length === 1 ||
705 (parent.type !== "mrow" && parent.Core() === child))) // handles msubsup and munderover
706 {child = parent; parent = parent.parent}
707 if (parent.data[parent.data.length-1] === child) this.texClass = MML.TEXCLASS.ORD;
708 }
709 return this;
710 }
711 });
712
713 MML.mtext = MML.mbase.Subclass({
714 type: "mtext", isToken: true,
715 isSpacelike: function () {return true},
716 texClass: MML.TEXCLASS.ORD,
717 defaults: {
718 mathvariant: MML.INHERIT,
719 mathsize: MML.INHERIT,
720 mathbackground: MML.INHERIT,
721 mathcolor: MML.INHERIT,
722 dir: MML.INHERIT
723 }
724 });
725
726 MML.mspace = MML.mbase.Subclass({
727 type: "mspace", isToken: true,
728 isSpacelike: function () {return true},
729 defaults: {
730 mathbackground: MML.INHERIT,
731 mathcolor: MML.INHERIT,
732 width: "0em",
733 height: "0ex",
734 depth: "0ex",
735 linebreak: MML.LINEBREAK.AUTO
736 },
737 hasDimAttr: function () {
738 return (this.hasValue("width") || this.hasValue("height") ||
739 this.hasValue("depth"));
740 },
741 hasNewline: function () {
742 // The MathML spec says that the linebreak attribute should be ignored
743 // if any dimensional attribute is set.
744 return (!this.hasDimAttr() &&
745 this.Get("linebreak") === MML.LINEBREAK.NEWLINE);
746 }
747 });
748
749 MML.ms = MML.mbase.Subclass({
750 type: "ms", isToken: true,
751 texClass: MML.TEXCLASS.ORD,
752 defaults: {
753 mathvariant: MML.INHERIT,
754 mathsize: MML.INHERIT,
755 mathbackground: MML.INHERIT,
756 mathcolor: MML.INHERIT,
757 dir: MML.INHERIT,
758 lquote: '"',
759 rquote: '"'
760 }
761 });
762
763 MML.mglyph = MML.mbase.Subclass({
764 type: "mglyph", isToken: true,
765 texClass: MML.TEXCLASS.ORD,
766 defaults: {
767 mathbackground: MML.INHERIT,
768 mathcolor: MML.INHERIT,
769 alt: "",
770 src: "",
771 width: MML.AUTO,
772 height: MML.AUTO,
773 valign: "0em"
774 }
775 });
776
777 MML.mrow = MML.mbase.Subclass({
778 type: "mrow",
779 isSpacelike: MML.mbase.childrenSpacelike,
780 inferred: false, notParent: false,
781 isEmbellished: function () {
782 var isEmbellished = false;
783 for (var i = 0, m = this.data.length; i < m; i++) {
784 if (this.data[i] == null) continue;
785 if (this.data[i].isEmbellished()) {
786 if (isEmbellished) {return false}
787 isEmbellished = true; this.core = i;
788 } else if (!this.data[i].isSpacelike()) {return false}
789 }
790 return isEmbellished;
791 },
792 NonSpaceLength: function () {
793 var n = 0;
794 for (var i = 0, m = this.data.length; i < m; i++)
795 {if (this.data[i] && !this.data[i].isSpacelike()) {n++}}
796 return n;
797 },
798 FirstNonSpace: function () {
799 for (var i = 0, m = this.data.length; i < m; i++)
800 {if (this.data[i] && !this.data[i].isSpacelike()) {return this.data[i]}}
801 return null;
802 },
803 LastNonSpace: function () {
804 for (var i = this.data.length-1; i >= 0; i--)
805 {if (this.data[0] && !this.data[i].isSpacelike()) {return this.data[i]}}
806 return null;
807 },
808 Core: function () {
809 if (!(this.isEmbellished()) || typeof(this.core) === "undefined") {return this}
810 return this.data[this.core];
811 },
812 CoreMO: function () {
813 if (!(this.isEmbellished()) || typeof(this.core) === "undefined") {return this}
814 return this.data[this.core].CoreMO();
815 },
816 toString: function () {
817 if (this.inferred) {return '[' + this.data.join(',') + ']'}
818 return this.SUPER(arguments).toString.call(this);
819 },
820 setTeXclass: function (prev) {
821 var i, m = this.data.length;
822 if ((this.open || this.close) && (!prev || !prev.fnOP)) {
823 //
824 // <mrow> came from \left...\right
825 // so treat as subexpression (tex class INNER)
826 //
827 this.getPrevClass(prev); prev = null;
828 for (i = 0; i < m; i++)
829 {if (this.data[i]) {prev = this.data[i].setTeXclass(prev)}}
830 if (!this.hasOwnProperty("texClass")) this.texClass = MML.TEXCLASS.INNER;
831 return this;
832 } else {
833 //
834 // Normal <mrow>, so treat as
835 // thorugh mrow is not there
836 //
837 for (i = 0; i < m; i++)
838 {if (this.data[i]) {prev = this.data[i].setTeXclass(prev)}}
839 if (this.data[0]) {this.updateTeXclass(this.data[0])}
840 return prev;
841 }
842 },
843 getAnnotation: function (name) {
844 if (this.data.length != 1) return null;
845 return this.data[0].getAnnotation(name);
846 }
847 });
848
849 MML.mfrac = MML.mbase.Subclass({
850 type: "mfrac", num: 0, den: 1,
851 linebreakContainer: true,
852 isEmbellished: MML.mbase.childEmbellished,
853 Core: MML.mbase.childCore,
854 CoreMO: MML.mbase.childCoreMO,
855 defaults: {
856 mathbackground: MML.INHERIT,
857 mathcolor: MML.INHERIT,
858 linethickness: MML.LINETHICKNESS.MEDIUM,
859 numalign: MML.ALIGN.CENTER,
860 denomalign: MML.ALIGN.CENTER,
861 bevelled: false
862 },
863 adjustChild_displaystyle: function (n) {return false},
864 adjustChild_scriptlevel: function (n) {
865 var level = this.Get("scriptlevel");
866 if (!this.Get("displaystyle") || level > 0) {level++}
867 return level;
868 },
869 adjustChild_texprimestyle: function (n) {
870 if (n == this.den) {return true}
871 return this.Get("texprimestyle");
872 },
873 setTeXclass: MML.mbase.setSeparateTeXclasses
874 });
875
876 MML.msqrt = MML.mbase.Subclass({
877 type: "msqrt",
878 inferRow: true,
879 linebreakContainer: true,
880 texClass: MML.TEXCLASS.ORD,
881 setTeXclass: MML.mbase.setSeparateTeXclasses,
882 adjustChild_texprimestyle: function (n) {return true}
883 });
884
885 MML.mroot = MML.mbase.Subclass({
886 type: "mroot",
887 linebreakContainer: true,
888 texClass: MML.TEXCLASS.ORD,
889 adjustChild_displaystyle: function (n) {
890 if (n === 1) {return false}
891 return this.Get("displaystyle");
892 },
893 adjustChild_scriptlevel: function (n) {
894 var level = this.Get("scriptlevel");
895 if (n === 1) {level += 2}
896 return level;
897 },
898 adjustChild_texprimestyle: function (n) {
899 if (n === 0) {return true};
900 return this.Get("texprimestyle");
901 },
902 setTeXclass: MML.mbase.setSeparateTeXclasses
903 });
904
905 MML.mstyle = MML.mbase.Subclass({
906 type: "mstyle",
907 isSpacelike: MML.mbase.childrenSpacelike,
908 isEmbellished: MML.mbase.childEmbellished,
909 Core: MML.mbase.childCore,
910 CoreMO: MML.mbase.childCoreMO,
911 inferRow: true,
912 defaults: {
913 scriptlevel: MML.INHERIT,
914 displaystyle: MML.INHERIT,
915 scriptsizemultiplier: Math.sqrt(1/2),
916 scriptminsize: "8pt",
917 mathbackground: MML.INHERIT,
918 mathcolor: MML.INHERIT,
919 dir: MML.INHERIT,
920 infixlinebreakstyle: MML.LINEBREAKSTYLE.BEFORE,
921 decimalseparator: "."
922 },
923 adjustChild_scriptlevel: function (n) {
924 var level = this.scriptlevel;
925 if (level == null) {
926 level = this.Get("scriptlevel");
927 } else if (String(level).match(/^ *[-+]/)) {
928 var LEVEL = this.Get("scriptlevel",null,true);
929 level = LEVEL + parseInt(level);
930 }
931 return level;
932 },
933 inheritFromMe: true,
934 noInherit: {
935 mpadded: {width: true, height: true, depth: true, lspace: true, voffset: true},
936 mtable: {width: true, height: true, depth: true, align: true}
937 },
938 getRemoved: {fontfamily:"fontFamily", fontweight:"fontWeight", fontstyle:"fontStyle", fontsize:"fontSize"},
939 setTeXclass: MML.mbase.setChildTeXclass
940 });
941
942 MML.merror = MML.mbase.Subclass({
943 type: "merror",
944 inferRow: true,
945 linebreakContainer: true,
946 texClass: MML.TEXCLASS.ORD
947 });
948
949 MML.mpadded = MML.mbase.Subclass({
950 type: "mpadded",
951 inferRow: true,
952 isSpacelike: MML.mbase.childrenSpacelike,
953 isEmbellished: MML.mbase.childEmbellished,
954 Core: MML.mbase.childCore,
955 CoreMO: MML.mbase.childCoreMO,
956 defaults: {
957 mathbackground: MML.INHERIT,
958 mathcolor: MML.INHERIT,
959 width: "",
960 height: "",
961 depth: "",
962 lspace: 0,
963 voffset: 0
964 },
965 setTeXclass: MML.mbase.setChildTeXclass
966 });
967
968 MML.mphantom = MML.mbase.Subclass({
969 type: "mphantom",
970 texClass: MML.TEXCLASS.ORD,
971 inferRow: true,
972 isSpacelike: MML.mbase.childrenSpacelike,
973 isEmbellished: MML.mbase.childEmbellished,
974 Core: MML.mbase.childCore,
975 CoreMO: MML.mbase.childCoreMO,
976 setTeXclass: MML.mbase.setChildTeXclass
977 });
978
979 MML.mfenced = MML.mbase.Subclass({
980 type: "mfenced",
981 defaults: {
982 mathbackground: MML.INHERIT,
983 mathcolor: MML.INHERIT,
984 open: '(',
985 close: ')',
986 separators: ','
987 },
988 addFakeNodes: function () {
989 var values = this.getValues("open","close","separators");
990 values.open = values.open.replace(/[ \t\n\r]/g,"");
991 values.close = values.close.replace(/[ \t\n\r]/g,"");
992 values.separators = values.separators.replace(/[ \t\n\r]/g,"");
993 //
994 // Create a fake node for the open item
995 //
996 if (values.open !== "") {
997 this.SetData("open",MML.mo(values.open).With({
998 fence:true, form:MML.FORM.PREFIX, texClass:MML.TEXCLASS.OPEN
999 }));
1000 //
1001 // Clear flag for using MML spacing even though form is specified
1002 //
1003 this.data.open.useMMLspacing = 0;
1004 }
1005 //
1006 // Create fake nodes for the separators
1007 //
1008 if (values.separators !== "") {
1009 while (values.separators.length < this.data.length)
1010 {values.separators += values.separators.charAt(values.separators.length-1)}
1011 for (var i = 1, m = this.data.length; i < m; i++) {
1012 if (this.data[i]) {
1013 this.SetData("sep"+i,MML.mo(values.separators.charAt(i-1)).With({separator:true}))
1014 this.data["sep"+i].useMMLspacing = 0;
1015 }
1016 }
1017 }
1018 //
1019 // Create fake node for the close item
1020 //
1021 if (values.close !== "") {
1022 this.SetData("close",MML.mo(values.close).With({
1023 fence:true, form:MML.FORM.POSTFIX, texClass:MML.TEXCLASS.CLOSE
1024 }));
1025 //
1026 // Clear flag for using MML spacing even though form is specified
1027 //
1028 this.data.close.useMMLspacing = 0;
1029 }
1030 },
1031 texClass: MML.TEXCLASS.OPEN,
1032 setTeXclass: function (prev) {
1033 this.addFakeNodes();
1034 this.getPrevClass(prev);
1035 if (this.data.open) {prev = this.data.open.setTeXclass(prev)}
1036 if (this.data[0]) {prev = this.data[0].setTeXclass(prev)}
1037 for (var i = 1, m = this.data.length; i < m; i++) {
1038 if (this.data["sep"+i]) {prev = this.data["sep"+i].setTeXclass(prev)}
1039 if (this.data[i]) {prev = this.data[i].setTeXclass(prev)}
1040 }
1041 if (this.data.close) {prev = this.data.close.setTeXclass(prev)}
1042 this.updateTeXclass(this.data.open);
1043 this.texClass = MML.TEXCLASS.INNER;
1044 return prev;
1045 }
1046 });
1047
1048 MML.menclose = MML.mbase.Subclass({
1049 type: "menclose",
1050 inferRow: true,
1051 linebreakContainer: true,
1052 defaults: {
1053 mathbackground: MML.INHERIT,
1054 mathcolor: MML.INHERIT,
1055 notation: MML.NOTATION.LONGDIV,
1056 texClass: MML.TEXCLASS.ORD
1057 },
1058 setTeXclass: MML.mbase.setSeparateTeXclasses
1059 });
1060
1061 MML.msubsup = MML.mbase.Subclass({
1062 type: "msubsup", base: 0, sub: 1, sup: 2,
1063 isEmbellished: MML.mbase.childEmbellished,
1064 Core: MML.mbase.childCore,
1065 CoreMO: MML.mbase.childCoreMO,
1066 defaults: {
1067 mathbackground: MML.INHERIT,
1068 mathcolor: MML.INHERIT,
1069 subscriptshift: "",
1070 superscriptshift: "",
1071 texClass: MML.AUTO
1072 },
1073 autoDefault: function (name) {
1074 if (name === "texClass")
1075 {return (this.isEmbellished() ? this.CoreMO().Get(name) : MML.TEXCLASS.ORD)}
1076 return 0;
1077 },
1078 adjustChild_displaystyle: function (n) {
1079 if (n > 0) {return false}
1080 return this.Get("displaystyle");
1081 },
1082 adjustChild_scriptlevel: function (n) {
1083 var level = this.Get("scriptlevel");
1084 if (n > 0) {level++}
1085 return level;
1086 },
1087 adjustChild_texprimestyle: function (n) {
1088 if (n === this.sub) {return true}
1089 return this.Get("texprimestyle");
1090 },
1091 setTeXclass: MML.mbase.setBaseTeXclasses
1092 });
1093
1094 MML.msub = MML.msubsup.Subclass({type: "msub"});
1095 MML.msup = MML.msubsup.Subclass({type: "msup", sub:2, sup:1});
1096 MML.mmultiscripts = MML.msubsup.Subclass({
1097 type: "mmultiscripts",
1098 adjustChild_texprimestyle: function (n) {
1099 if (n % 2 === 1) {return true}
1100 return this.Get("texprimestyle");
1101 }
1102 });
1103 MML.mprescripts = MML.mbase.Subclass({type: "mprescripts"});
1104 MML.none = MML.mbase.Subclass({type: "none"});
1105
1106 MML.munderover = MML.mbase.Subclass({
1107 type: "munderover",
1108 base: 0, under: 1, over: 2, sub: 1, sup: 2,
1109 ACCENTS: ["", "accentunder", "accent"],
1110 linebreakContainer: true,
1111 isEmbellished: MML.mbase.childEmbellished,
1112 Core: MML.mbase.childCore,
1113 CoreMO: MML.mbase.childCoreMO,
1114 defaults: {
1115 mathbackground: MML.INHERIT,
1116 mathcolor: MML.INHERIT,
1117 accent: MML.AUTO,
1118 accentunder: MML.AUTO,
1119 align: MML.ALIGN.CENTER,
1120 texClass: MML.AUTO,
1121 subscriptshift: "", // when converted to msubsup by moveablelimits
1122 superscriptshift: "" // when converted to msubsup by moveablelimits
1123 },
1124 autoDefault: function (name) {
1125 if (name === "texClass")
1126 {return (this.isEmbellished() ? this.CoreMO().Get(name) : MML.TEXCLASS.ORD)}
1127 if (name === "accent" && this.data[this.over]) {return this.data[this.over].CoreMO().Get("accent")}
1128 if (name === "accentunder" && this.data[this.under]) {return this.data[this.under].CoreMO().Get("accent")}
1129 return false;
1130 },
1131 adjustChild_displaystyle: function (n) {
1132 if (n > 0) {return false}
1133 return this.Get("displaystyle");
1134 },
1135 adjustChild_scriptlevel: function (n) {
1136 var level = this.Get("scriptlevel");
1137 var force = (this.data[this.base] && !this.Get("displaystyle") &&
1138 this.data[this.base].CoreMO().Get("movablelimits"));
1139 if (n == this.under && (force || !this.Get("accentunder"))) {level++}
1140 if (n == this.over && (force || !this.Get("accent"))) {level++}
1141 return level;
1142 },
1143 adjustChild_texprimestyle: function (n) {
1144 if (n === this.base && this.data[this.over]) {return true}
1145 return this.Get("texprimestyle");
1146 },
1147 setTeXclass: MML.mbase.setBaseTeXclasses
1148 });
1149
1150 MML.munder = MML.munderover.Subclass({type: "munder"});
1151 MML.mover = MML.munderover.Subclass({
1152 type: "mover", over: 1, under: 2, sup: 1, sub: 2,
1153 ACCENTS: ["", "accent", "accentunder"]
1154 });
1155
1156 MML.mtable = MML.mbase.Subclass({
1157 type: "mtable",
1158 defaults: {
1159 mathbackground: MML.INHERIT,
1160 mathcolor: MML.INHERIT,
1161 align: MML.ALIGN.AXIS,
1162 rowalign: MML.ALIGN.BASELINE,
1163 columnalign: MML.ALIGN.CENTER,
1164 groupalign: "{left}",
1165 alignmentscope: true,
1166 columnwidth: MML.WIDTH.AUTO,
1167 width: MML.WIDTH.AUTO,
1168 rowspacing: "1ex",
1169 columnspacing: ".8em",
1170 rowlines: MML.LINES.NONE,
1171 columnlines: MML.LINES.NONE,
1172 frame: MML.LINES.NONE,
1173 framespacing: "0.4em 0.5ex",
1174 equalrows: false,
1175 equalcolumns: false,
1176 displaystyle: false,
1177 side: MML.SIDE.RIGHT,
1178 minlabelspacing: "0.8em",
1179 texClass: MML.TEXCLASS.ORD,
1180 useHeight: 1
1181 },
1182 adjustChild_displaystyle: function () {
1183 return (this.displaystyle != null ? this.displaystyle : this.defaults.displaystyle);
1184 },
1185 inheritFromMe: true,
1186 noInherit: {
1187 mover: {align: true},
1188 munder: {align: true},
1189 munderover: {align: true},
1190 mtable: {
1191 align: true, rowalign: true, columnalign: true, groupalign: true,
1192 alignmentscope: true, columnwidth: true, width: true, rowspacing: true,
1193 columnspacing: true, rowlines: true, columnlines: true, frame: true,
1194 framespacing: true, equalrows: true, equalcolumns: true, displaystyle: true,
1195 side: true, minlabelspacing: true, texClass: true, useHeight: 1
1196 }
1197 },
1198 linebreakContainer: true,
1199 Append: function () {
1200 for (var i = 0, m = arguments.length; i < m; i++) {
1201 if (!((arguments[i] instanceof MML.mtr) ||
1202 (arguments[i] instanceof MML.mlabeledtr))) {arguments[i] = MML.mtr(arguments[i])}
1203 }
1204 this.SUPER(arguments).Append.apply(this,arguments);
1205 },
1206 setTeXclass: MML.mbase.setSeparateTeXclasses
1207 });
1208
1209 MML.mtr = MML.mbase.Subclass({
1210 type: "mtr",
1211 defaults: {
1212 mathbackground: MML.INHERIT,
1213 mathcolor: MML.INHERIT,
1214 rowalign: MML.INHERIT,
1215 columnalign: MML.INHERIT,
1216 groupalign: MML.INHERIT
1217 },
1218 inheritFromMe: true,
1219 noInherit: {
1220 mrow: {rowalign: true, columnalign: true, groupalign: true},
1221 mtable: {rowalign: true, columnalign: true, groupalign: true}
1222 },
1223 linebreakContainer: true,
1224 Append: function () {
1225 for (var i = 0, m = arguments.length; i < m; i++) {
1226 if (!(arguments[i] instanceof MML.mtd)) {arguments[i] = MML.mtd(arguments[i])}
1227 }
1228 this.SUPER(arguments).Append.apply(this,arguments);
1229 },
1230 setTeXclass: MML.mbase.setSeparateTeXclasses
1231 });
1232
1233 MML.mtd = MML.mbase.Subclass({
1234 type: "mtd",
1235 inferRow: true,
1236 linebreakContainer: true,
1237 isEmbellished: MML.mbase.childEmbellished,
1238 Core: MML.mbase.childCore,
1239 CoreMO: MML.mbase.childCoreMO,
1240 defaults: {
1241 mathbackground: MML.INHERIT,
1242 mathcolor: MML.INHERIT,
1243 rowspan: 1,
1244 columnspan: 1,
1245 rowalign: MML.INHERIT,
1246 columnalign: MML.INHERIT,
1247 groupalign: MML.INHERIT
1248 },
1249 setTeXclass: MML.mbase.setSeparateTeXclasses
1250 });
1251
1252 MML.maligngroup = MML.mbase.Subclass({
1253 type: "maligngroup",
1254 isSpacelike: function () {return true},
1255 defaults: {
1256 mathbackground: MML.INHERIT,
1257 mathcolor: MML.INHERIT,
1258 groupalign: MML.INHERIT
1259 },
1260 inheritFromMe: true,
1261 noInherit: {
1262 mrow: {groupalign: true},
1263 mtable: {groupalign: true}
1264 }
1265 });
1266
1267 MML.malignmark = MML.mbase.Subclass({
1268 type: "malignmark",
1269 defaults: {
1270 mathbackground: MML.INHERIT,
1271 mathcolor: MML.INHERIT,
1272 edge: MML.SIDE.LEFT
1273 },
1274 isSpacelike: function () {return true}
1275 });
1276
1277 MML.mlabeledtr = MML.mtr.Subclass({
1278 type: "mlabeledtr"
1279 });
1280
1281 MML.maction = MML.mbase.Subclass({
1282 type: "maction",
1283 defaults: {
1284 mathbackground: MML.INHERIT,
1285 mathcolor: MML.INHERIT,
1286 actiontype: MML.ACTIONTYPE.TOGGLE,
1287 selection: 1
1288 },
1289 selected: function () {return this.data[this.Get("selection")-1] || MML.NULL},
1290 isEmbellished: function () {return this.selected().isEmbellished()},
1291 isSpacelike: function () {return this.selected().isSpacelike()},
1292 Core: function () {return this.selected().Core()},
1293 CoreMO: function () {return this.selected().CoreMO()},
1294 setTeXclass: function (prev) {
1295 if (this.Get("actiontype") === MML.ACTIONTYPE.TOOLTIP && this.data[1]) {
1296 // Make sure tooltip has proper spacing when typeset (see issue #412)
1297 this.data[1].setTeXclass();
1298 }
1299 var selected = this.selected();
1300 prev = selected.setTeXclass(prev);
1301 this.updateTeXclass(selected);
1302 return prev;
1303 }
1304 });
1305
1306 MML.semantics = MML.mbase.Subclass({
1307 type: "semantics", notParent: true,
1308 isEmbellished: MML.mbase.childEmbellished,
1309 Core: MML.mbase.childCore,
1310 CoreMO: MML.mbase.childCoreMO,
1311 defaults: {
1312 definitionURL: null,
1313 encoding: null
1314 },
1315 setTeXclass: MML.mbase.setChildTeXclass,
1316 getAnnotation: function (name) {
1317 var encodingList = MathJax.Hub.config.MathMenu.semanticsAnnotations[name];
1318 if (encodingList) {
1319 for (var i = 0, m = this.data.length; i < m; i++) {
1320 var encoding = this.data[i].Get("encoding");
1321 if (encoding) {
1322 for (var j = 0, n = encodingList.length; j < n; j++) {
1323 if (encodingList[j] === encoding) return this.data[i];
1324 }
1325 }
1326 }
1327 }
1328 return null;
1329 }
1330 });
1331 MML.annotation = MML.mbase.Subclass({
1332 type: "annotation", isChars: true,
1333 linebreakContainer: true,
1334 defaults: {
1335 definitionURL: null,
1336 encoding: null,
1337 cd: "mathmlkeys",
1338 name: "",
1339 src: null
1340 }
1341 });
1342 MML["annotation-xml"] = MML.mbase.Subclass({
1343 type: "annotation-xml",
1344 linebreakContainer: true,
1345 defaults: {
1346 definitionURL: null,
1347 encoding: null,
1348 cd: "mathmlkeys",
1349 name: "",
1350 src: null
1351 }
1352 });
1353
1354 MML.math = MML.mstyle.Subclass({
1355 type: "math",
1356 defaults: {
1357 mathvariant: MML.VARIANT.NORMAL,
1358 mathsize: MML.SIZE.NORMAL,
1359 mathcolor: "", // should be "black", but allow it to inherit from surrounding text
1360 mathbackground: MML.COLOR.TRANSPARENT,
1361 dir: "ltr",
1362 scriptlevel: 0,
1363 displaystyle: MML.AUTO,
1364 display: "inline",
1365 maxwidth: "",
1366 overflow: MML.OVERFLOW.LINEBREAK,
1367 altimg: "",
1368 'altimg-width': "",
1369 'altimg-height': "",
1370 'altimg-valign': "",
1371 alttext: "",
1372 cdgroup: "",
1373 scriptsizemultiplier: Math.sqrt(1/2),
1374 scriptminsize: "8px", // should be 8pt, but that's too big
1375 infixlinebreakstyle: MML.LINEBREAKSTYLE.BEFORE,
1376 lineleading: "1ex",
1377 indentshift: "auto", // use user configuration
1378 indentalign: MML.INDENTALIGN.AUTO,
1379 indentalignfirst: MML.INDENTALIGN.INDENTALIGN,
1380 indentshiftfirst: MML.INDENTSHIFT.INDENTSHIFT,
1381 indentalignlast: MML.INDENTALIGN.INDENTALIGN,
1382 indentshiftlast: MML.INDENTSHIFT.INDENTSHIFT,
1383 decimalseparator: ".",
1384 texprimestyle: false // is it in TeX's C' style?
1385 },
1386 autoDefault: function (name) {
1387 if (name === "displaystyle") {return this.Get("display") === "block"}
1388 return "";
1389 },
1390 linebreakContainer: true,
1391 setTeXclass: MML.mbase.setChildTeXclass,
1392 getAnnotation: function (name) {
1393 if (this.data.length != 1) return null;
1394 return this.data[0].getAnnotation(name);
1395 }
1396 });
1397
1398 MML.chars = MML.mbase.Subclass({
1399 type: "chars",
1400 Append: function () {this.data.push.apply(this.data,arguments)},
1401 value: function () {return this.data.join("")},
1402 toString: function () {return this.data.join("")}
1403 });
1404
1405 MML.entity = MML.mbase.Subclass({
1406 type: "entity",
1407 Append: function () {this.data.push.apply(this.data,arguments)},
1408 value: function () {
1409 if (this.data[0].substr(0,2) === "#x") {return parseInt(this.data[0].substr(2),16)}
1410 else if (this.data[0].substr(0,1) === "#") {return parseInt(this.data[0].substr(1))}
1411 else {return 0} // FIXME: look up named entities from table
1412 },
1413 toString: function () {
1414 var n = this.value();
1415 if (n <= 0xFFFF) {return String.fromCharCode(n)}
1416 n -= 0x10000;
1417 return String.fromCharCode((n>>10)+0xD800, (n&0x3FF)+0xDC00);
1418 }
1419 });
1420
1421 MML.xml = MML.mbase.Subclass({
1422 type: "xml",
1423 Init: function () {
1424 this.div = document.createElement("div");
1425 return this.SUPER(arguments).Init.apply(this,arguments);
1426 },
1427 Append: function () {
1428 for (var i = 0, m = arguments.length; i < m; i++) {
1429 var node = this.Import(arguments[i]);
1430 this.data.push(node);
1431 this.div.appendChild(node);
1432 }
1433 },
1434 Import: function (node) {
1435 if (document.importNode) {return document.importNode(node,true)}
1436 //
1437 // IE < 9 doesn't have importNode, so fake it.
1438 //
1439 var nNode, i, m;
1440 if (node.nodeType === 1) { // ELEMENT_NODE
1441 nNode = document.createElement(node.nodeName);
1442 for (i = 0, m = node.attributes.length; i < m; i++) {
1443 var attribute = node.attributes[i];
1444 if (attribute.specified && attribute.nodeValue != null && attribute.nodeValue != '')
1445 {nNode.setAttribute(attribute.nodeName,attribute.nodeValue)}
1446 if (attribute.nodeName === "style") {nNode.style.cssText = attribute.nodeValue}
1447 }
1448 if (node.className) {nNode.className = node.className}
1449 } else if (node.nodeType === 3 || node.nodeType === 4) { // TEXT_NODE or CDATA_SECTION_NODE
1450 nNode = document.createTextNode(node.nodeValue);
1451 } else if (node.nodeType === 8) { // COMMENT_NODE
1452 nNode = document.createComment(node.nodeValue);
1453 } else {
1454 return document.createTextNode('');
1455 }
1456 for (i = 0, m = node.childNodes.length; i < m; i++)
1457 {nNode.appendChild(this.Import(node.childNodes[i]))}
1458 return nNode;
1459 },
1460 value: function () {return this.div},
1461 toString: function () {return this.div.innerHTML}
1462 });
1463
1464 MML.TeXAtom = MML.mbase.Subclass({
1465 type: "texatom",
1466 linebreakContainer: true,
1467 inferRow: true, notParent: true,
1468 texClass: MML.TEXCLASS.ORD,
1469 Core: MML.mbase.childCore,
1470 CoreMO: MML.mbase.childCoreMO,
1471 isEmbellished: MML.mbase.childEmbellished,
1472 setTeXclass: function (prev) {
1473 this.data[0].setTeXclass();
1474 return this.adjustTeXclass(prev);
1475 },
1476 adjustTeXclass: MML.mo.prototype.adjustTeXclass
1477 });
1478
1479 MML.NULL = MML.mbase().With({type:"null"});
1480
1481 var TEXCLASS = MML.TEXCLASS;
1482
1483 var MO = {
1484 ORD: [0,0,TEXCLASS.ORD],
1485 ORD11: [1,1,TEXCLASS.ORD],
1486 ORD21: [2,1,TEXCLASS.ORD],
1487 ORD02: [0,2,TEXCLASS.ORD],
1488 ORD55: [5,5,TEXCLASS.ORD],
1489 OP: [1,2,TEXCLASS.OP,{largeop: true, movablelimits: true, symmetric: true}],
1490 OPFIXED: [1,2,TEXCLASS.OP,{largeop: true, movablelimits: true}],
1491 INTEGRAL: [0,1,TEXCLASS.OP,{largeop: true, symmetric: true}],
1492 INTEGRAL2: [1,2,TEXCLASS.OP,{largeop: true, symmetric: true}],
1493 BIN3: [3,3,TEXCLASS.BIN],
1494 BIN4: [4,4,TEXCLASS.BIN],
1495 BIN01: [0,1,TEXCLASS.BIN],
1496 BIN5: [5,5,TEXCLASS.BIN],
1497 TALLBIN: [4,4,TEXCLASS.BIN,{stretchy: true}],
1498 BINOP: [4,4,TEXCLASS.BIN,{largeop: true, movablelimits: true}],
1499 REL: [5,5,TEXCLASS.REL],
1500 REL1: [1,1,TEXCLASS.REL,{stretchy: true}],
1501 REL4: [4,4,TEXCLASS.REL],
1502 RELSTRETCH: [5,5,TEXCLASS.REL,{stretchy: true}],
1503 RELACCENT: [5,5,TEXCLASS.REL,{accent: true}],
1504 WIDEREL: [5,5,TEXCLASS.REL,{accent: true, stretchy: true}],
1505 OPEN: [0,0,TEXCLASS.OPEN,{fence: true, stretchy: true, symmetric: true}],
1506 CLOSE: [0,0,TEXCLASS.CLOSE,{fence: true, stretchy: true, symmetric: true}],
1507 INNER: [0,0,TEXCLASS.INNER],
1508 PUNCT: [0,3,TEXCLASS.PUNCT],
1509 ACCENT: [0,0,TEXCLASS.ORD,{accent: true}],
1510 WIDEACCENT: [0,0,TEXCLASS.ORD,{accent: true, stretchy: true}]
1511 };
1512
1513 MML.mo.Augment({
1514 SPACE: [
1515 '0em',
1516 '0.1111em',
1517 '0.1667em',
1518 '0.2222em',
1519 '0.2667em',
1520 '0.3333em'
1521 ],
1522 RANGES: [
1523 [0x20,0x7F,TEXCLASS.REL,"BasicLatin"],
1524 [0xA0,0xFF,TEXCLASS.ORD,"Latin1Supplement"],
1525 [0x100,0x17F,TEXCLASS.ORD],
1526 [0x180,0x24F,TEXCLASS.ORD],
1527 [0x2B0,0x2FF,TEXCLASS.ORD,"SpacingModLetters"],
1528 [0x300,0x36F,TEXCLASS.ORD,"CombDiacritMarks"],
1529 [0x370,0x3FF,TEXCLASS.ORD,"GreekAndCoptic"],
1530 [0x1E00,0x1EFF,TEXCLASS.ORD],
1531 [0x2000,0x206F,TEXCLASS.PUNCT,"GeneralPunctuation"],
1532 [0x2070,0x209F,TEXCLASS.ORD],
1533 [0x20A0,0x20CF,TEXCLASS.ORD],
1534 [0x20D0,0x20FF,TEXCLASS.ORD,"CombDiactForSymbols"],
1535 [0x2100,0x214F,TEXCLASS.ORD,"LetterlikeSymbols"],
1536 [0x2150,0x218F,TEXCLASS.ORD],
1537 [0x2190,0x21FF,TEXCLASS.REL,"Arrows"],
1538 [0x2200,0x22FF,TEXCLASS.BIN,"MathOperators"],
1539 [0x2300,0x23FF,TEXCLASS.ORD,"MiscTechnical"],
1540 [0x2460,0x24FF,TEXCLASS.ORD],
1541 [0x2500,0x259F,TEXCLASS.ORD],
1542 [0x25A0,0x25FF,TEXCLASS.ORD,"GeometricShapes"],
1543 [0x2700,0x27BF,TEXCLASS.ORD,"Dingbats"],
1544 [0x27C0,0x27EF,TEXCLASS.ORD,"MiscMathSymbolsA"],
1545 [0x27F0,0x27FF,TEXCLASS.REL,"SupplementalArrowsA"],
1546 [0x2900,0x297F,TEXCLASS.REL,"SupplementalArrowsB"],
1547 [0x2980,0x29FF,TEXCLASS.ORD,"MiscMathSymbolsB"],
1548 [0x2A00,0x2AFF,TEXCLASS.BIN,"SuppMathOperators"],
1549 [0x2B00,0x2BFF,TEXCLASS.ORD,"MiscSymbolsAndArrows"],
1550 [0x1D400,0x1D7FF,TEXCLASS.ORD]
1551 ],
1552 OPTABLE: {
1553 prefix: {
1554 '\u2200': MO.ORD21, // for all
1555 '\u2202': MO.ORD21, // partial differential
1556 '\u2203': MO.ORD21, // there exists
1557 '\u2207': MO.ORD21, // nabla
1558 '\u220F': MO.OP, // n-ary product
1559 '\u2210': MO.OP, // n-ary coproduct
1560 '\u2211': MO.OP, // n-ary summation
1561 '\u2212': MO.BIN01, // minus sign
1562 '\u2213': MO.BIN01, // minus-or-plus sign
1563 '\u221A': [1,1,TEXCLASS.ORD,{stretchy: true}], // square root
1564 '\u2220': MO.ORD, // angle
1565 '\u222B': MO.INTEGRAL, // integral
1566 '\u222E': MO.INTEGRAL, // contour integral
1567 '\u22C0': MO.OP, // n-ary logical and
1568 '\u22C1': MO.OP, // n-ary logical or
1569 '\u22C2': MO.OP, // n-ary intersection
1570 '\u22C3': MO.OP, // n-ary union
1571 '\u2308': MO.OPEN, // left ceiling
1572 '\u230A': MO.OPEN, // left floor
1573 '\u27E8': MO.OPEN, // mathematical left angle bracket
1574 '\u27EE': MO.OPEN, // mathematical left flattened parenthesis
1575 '\u2A00': MO.OP, // n-ary circled dot operator
1576 '\u2A01': MO.OP, // n-ary circled plus operator
1577 '\u2A02': MO.OP, // n-ary circled times operator
1578 '\u2A04': MO.OP, // n-ary union operator with plus
1579 '\u2A06': MO.OP, // n-ary square union operator
1580 '\u00AC': MO.ORD21, // not sign
1581 '\u00B1': MO.BIN01, // plus-minus sign
1582 '(': MO.OPEN, // left parenthesis
1583 '+': MO.BIN01, // plus sign
1584 '-': MO.BIN01, // hyphen-minus
1585 '[': MO.OPEN, // left square bracket
1586 '{': MO.OPEN, // left curly bracket
1587 '|': MO.OPEN // vertical line
1588 },
1589 postfix: {
1590 '!': [1,0,TEXCLASS.CLOSE], // exclamation mark
1591 '&': MO.ORD, // ampersand
1592 '\u2032': MO.ORD02, // prime
1593 '\u203E': MO.WIDEACCENT, // overline
1594 '\u2309': MO.CLOSE, // right ceiling
1595 '\u230B': MO.CLOSE, // right floor
1596 '\u23DE': MO.WIDEACCENT, // top curly bracket
1597 '\u23DF': MO.WIDEACCENT, // bottom curly bracket
1598 '\u266D': MO.ORD02, // music flat sign
1599 '\u266E': MO.ORD02, // music natural sign
1600 '\u266F': MO.ORD02, // music sharp sign
1601 '\u27E9': MO.CLOSE, // mathematical right angle bracket
1602 '\u27EF': MO.CLOSE, // mathematical right flattened parenthesis
1603 '\u02C6': MO.WIDEACCENT, // modifier letter circumflex accent
1604 '\u02C7': MO.WIDEACCENT, // caron
1605 '\u02C9': MO.WIDEACCENT, // modifier letter macron
1606 '\u02CA': MO.ACCENT, // modifier letter acute accent
1607 '\u02CB': MO.ACCENT, // modifier letter grave accent
1608 '\u02D8': MO.ACCENT, // breve
1609 '\u02D9': MO.ACCENT, // dot above
1610 '\u02DC': MO.WIDEACCENT, // small tilde
1611 '\u0302': MO.WIDEACCENT, // combining circumflex accent
1612 '\u00A8': MO.ACCENT, // diaeresis
1613 '\u00AF': MO.WIDEACCENT, // macron
1614 ')': MO.CLOSE, // right parenthesis
1615 ']': MO.CLOSE, // right square bracket
1616 '^': MO.WIDEACCENT, // circumflex accent
1617 '_': MO.WIDEACCENT, // low line
1618 '`': MO.ACCENT, // grave accent
1619 '|': MO.CLOSE, // vertical line
1620 '}': MO.CLOSE, // right curly bracket
1621 '~': MO.WIDEACCENT // tilde
1622 },
1623 infix: {
1624 '': MO.ORD, // empty <mo>
1625 '%': [3,3,TEXCLASS.ORD], // percent sign
1626 '\u2022': MO.BIN4, // bullet
1627 '\u2026': MO.INNER, // horizontal ellipsis
1628 '\u2044': MO.TALLBIN, // fraction slash
1629 '\u2061': MO.ORD, // function application
1630 '\u2062': MO.ORD, // invisible times
1631 '\u2063': [0,0,TEXCLASS.ORD,{linebreakstyle:"after", separator: true}], // invisible separator
1632 '\u2064': MO.ORD, // invisible plus
1633 '\u2190': MO.WIDEREL, // leftwards arrow
1634 '\u2191': MO.RELSTRETCH, // upwards arrow
1635 '\u2192': MO.WIDEREL, // rightwards arrow
1636 '\u2193': MO.RELSTRETCH, // downwards arrow
1637 '\u2194': MO.WIDEREL, // left right arrow
1638 '\u2195': MO.RELSTRETCH, // up down arrow
1639 '\u2196': MO.RELSTRETCH, // north west arrow
1640 '\u2197': MO.RELSTRETCH, // north east arrow
1641 '\u2198': MO.RELSTRETCH, // south east arrow
1642 '\u2199': MO.RELSTRETCH, // south west arrow
1643 '\u21A6': MO.WIDEREL, // rightwards arrow from bar
1644 '\u21A9': MO.WIDEREL, // leftwards arrow with hook
1645 '\u21AA': MO.WIDEREL, // rightwards arrow with hook
1646 '\u21BC': MO.WIDEREL, // leftwards harpoon with barb upwards
1647 '\u21BD': MO.WIDEREL, // leftwards harpoon with barb downwards
1648 '\u21C0': MO.WIDEREL, // rightwards harpoon with barb upwards
1649 '\u21C1': MO.WIDEREL, // rightwards harpoon with barb downwards
1650 '\u21CC': MO.WIDEREL, // rightwards harpoon over leftwards harpoon
1651 '\u21D0': MO.WIDEREL, // leftwards double arrow
1652 '\u21D1': MO.RELSTRETCH, // upwards double arrow
1653 '\u21D2': MO.WIDEREL, // rightwards double arrow
1654 '\u21D3': MO.RELSTRETCH, // downwards double arrow
1655 '\u21D4': MO.WIDEREL, // left right double arrow
1656 '\u21D5': MO.RELSTRETCH, // up down double arrow
1657 '\u2208': MO.REL, // element of
1658 '\u2209': MO.REL, // not an element of
1659 '\u220B': MO.REL, // contains as member
1660 '\u2212': MO.BIN4, // minus sign
1661 '\u2213': MO.BIN4, // minus-or-plus sign
1662 '\u2215': MO.TALLBIN, // division slash
1663 '\u2216': MO.BIN4, // set minus
1664 '\u2217': MO.BIN4, // asterisk operator
1665 '\u2218': MO.BIN4, // ring operator
1666 '\u2219': MO.BIN4, // bullet operator
1667 '\u221D': MO.REL, // proportional to
1668 '\u2223': MO.REL, // divides
1669 '\u2225': MO.REL, // parallel to
1670 '\u2227': MO.BIN4, // logical and
1671 '\u2228': MO.BIN4, // logical or
1672 '\u2229': MO.BIN4, // intersection
1673 '\u222A': MO.BIN4, // union
1674 '\u223C': MO.REL, // tilde operator
1675 '\u2240': MO.BIN4, // wreath product
1676 '\u2243': MO.REL, // asymptotically equal to
1677 '\u2245': MO.REL, // approximately equal to
1678 '\u2248': MO.REL, // almost equal to
1679 '\u224D': MO.REL, // equivalent to
1680 '\u2250': MO.REL, // approaches the limit
1681 '\u2260': MO.REL, // not equal to
1682 '\u2261': MO.REL, // identical to
1683 '\u2264': MO.REL, // less-than or equal to
1684 '\u2265': MO.REL, // greater-than or equal to
1685 '\u226A': MO.REL, // much less-than
1686 '\u226B': MO.REL, // much greater-than
1687 '\u227A': MO.REL, // precedes
1688 '\u227B': MO.REL, // succeeds
1689 '\u2282': MO.REL, // subset of
1690 '\u2283': MO.REL, // superset of
1691 '\u2286': MO.REL, // subset of or equal to
1692 '\u2287': MO.REL, // superset of or equal to
1693 '\u228E': MO.BIN4, // multiset union
1694 '\u2291': MO.REL, // square image of or equal to
1695 '\u2292': MO.REL, // square original of or equal to
1696 '\u2293': MO.BIN4, // square cap
1697 '\u2294': MO.BIN4, // square cup
1698 '\u2295': MO.BIN4, // circled plus
1699 '\u2296': MO.BIN4, // circled minus
1700 '\u2297': MO.BIN4, // circled times
1701 '\u2298': MO.BIN4, // circled division slash
1702 '\u2299': MO.BIN4, // circled dot operator
1703 '\u22A2': MO.REL, // right tack
1704 '\u22A3': MO.REL, // left tack
1705 '\u22A4': MO.ORD55, // down tack
1706 '\u22A5': MO.REL, // up tack
1707 '\u22A8': MO.REL, // true
1708 '\u22C4': MO.BIN4, // diamond operator
1709 '\u22C5': MO.BIN4, // dot operator
1710 '\u22C6': MO.BIN4, // star operator
1711 '\u22C8': MO.REL, // bowtie
1712 '\u22EE': MO.ORD55, // vertical ellipsis
1713 '\u22EF': MO.INNER, // midline horizontal ellipsis
1714 '\u22F1': [5,5,TEXCLASS.INNER], // down right diagonal ellipsis
1715 '\u25B3': MO.BIN4, // white up-pointing triangle
1716 '\u25B5': MO.BIN4, // white up-pointing small triangle
1717 '\u25B9': MO.BIN4, // white right-pointing small triangle
1718 '\u25BD': MO.BIN4, // white down-pointing triangle
1719 '\u25BF': MO.BIN4, // white down-pointing small triangle
1720 '\u25C3': MO.BIN4, // white left-pointing small triangle
1721 '\u2758': MO.REL, // light vertical bar
1722 '\u27F5': MO.WIDEREL, // long leftwards arrow
1723 '\u27F6': MO.WIDEREL, // long rightwards arrow
1724 '\u27F7': MO.WIDEREL, // long left right arrow
1725 '\u27F8': MO.WIDEREL, // long leftwards double arrow
1726 '\u27F9': MO.WIDEREL, // long rightwards double arrow
1727 '\u27FA': MO.WIDEREL, // long left right double arrow
1728 '\u27FC': MO.WIDEREL, // long rightwards arrow from bar
1729 '\u2A2F': MO.BIN4, // vector or cross product
1730 '\u2A3F': MO.BIN4, // amalgamation or coproduct
1731 '\u2AAF': MO.REL, // precedes above single-line equals sign
1732 '\u2AB0': MO.REL, // succeeds above single-line equals sign
1733 '\u00B1': MO.BIN4, // plus-minus sign
1734 '\u00B7': MO.BIN4, // middle dot
1735 '\u00D7': MO.BIN4, // multiplication sign
1736 '\u00F7': MO.BIN4, // division sign
1737 '*': MO.BIN3, // asterisk
1738 '+': MO.BIN4, // plus sign
1739 ',': [0,3,TEXCLASS.PUNCT,{linebreakstyle:"after", separator: true}], // comma
1740 '-': MO.BIN4, // hyphen-minus
1741 '.': [3,3,TEXCLASS.ORD], // full stop
1742 '/': MO.ORD11, // solidus
1743 ':': [1,2,TEXCLASS.REL], // colon
1744 ';': [0,3,TEXCLASS.PUNCT,{linebreakstyle:"after", separator: true}], // semicolon
1745 '<': MO.REL, // less-than sign
1746 '=': MO.REL, // equals sign
1747 '>': MO.REL, // greater-than sign
1748 '?': [1,1,TEXCLASS.CLOSE], // question mark
1749 '\\': MO.ORD, // reverse solidus
1750 '^': MO.ORD11, // circumflex accent
1751 '_': MO.ORD11, // low line
1752 '|': [2,2,TEXCLASS.ORD,{fence: true, stretchy: true, symmetric: true}], // vertical line
1753 '#': MO.ORD, // #
1754 '$': MO.ORD, // $
1755 '\u002E': [0,3,TEXCLASS.PUNCT,{separator: true}], // \ldotp
1756 '\u02B9': MO.ORD, // prime
1757 '\u0300': MO.ACCENT, // \grave
1758 '\u0301': MO.ACCENT, // \acute
1759 '\u0303': MO.WIDEACCENT, // \tilde
1760 '\u0304': MO.ACCENT, // \bar
1761 '\u0306': MO.ACCENT, // \breve
1762 '\u0307': MO.ACCENT, // \dot
1763 '\u0308': MO.ACCENT, // \ddot
1764 '\u030C': MO.ACCENT, // \check
1765 '\u0332': MO.WIDEACCENT, // horizontal line
1766 '\u0338': MO.REL4, // \not
1767 '\u2015': [0,0,TEXCLASS.ORD,{stretchy: true}], // horizontal line
1768 '\u2017': [0,0,TEXCLASS.ORD,{stretchy: true}], // horizontal line
1769 '\u2020': MO.BIN3, // \dagger
1770 '\u2021': MO.BIN3, // \ddagger
1771 '\u20D7': MO.ACCENT, // \vec
1772 '\u2111': MO.ORD, // \Im
1773 '\u2113': MO.ORD, // \ell
1774 '\u2118': MO.ORD, // \wp
1775 '\u211C': MO.ORD, // \Re
1776 '\u2205': MO.ORD, // \emptyset
1777 '\u221E': MO.ORD, // \infty
1778 '\u2305': MO.BIN3, // barwedge
1779 '\u2306': MO.BIN3, // doublebarwedge
1780 '\u2322': MO.REL4, // \frown
1781 '\u2323': MO.REL4, // \smile
1782 '\u2329': MO.OPEN, // langle
1783 '\u232A': MO.CLOSE, // rangle
1784 '\u23AA': MO.ORD, // \bracevert
1785 '\u23AF': [0,0,TEXCLASS.ORD,{stretchy: true}], // \underline
1786 '\u23B0': MO.OPEN, // \lmoustache
1787 '\u23B1': MO.CLOSE, // \rmoustache
1788 '\u2500': MO.ORD, // horizontal line
1789 '\u25EF': MO.BIN3, // \bigcirc
1790 '\u2660': MO.ORD, // \spadesuit
1791 '\u2661': MO.ORD, // \heartsuit
1792 '\u2662': MO.ORD, // \diamondsuit
1793 '\u2663': MO.ORD, // \clubsuit
1794 '\u3008': MO.OPEN, // langle
1795 '\u3009': MO.CLOSE, // rangle
1796 '\uFE37': MO.WIDEACCENT, // horizontal brace down
1797 '\uFE38': MO.WIDEACCENT // horizontal brace up
1798 }
1799 }
1800 },{
1801 OPTYPES: MO
1802 });
1803
1804 //
1805 // These are not in the W3C table, but FF works this way,
1806 // and it makes sense, so add it here
1807 //
1808 var OPTABLE = MML.mo.prototype.OPTABLE;
1809 OPTABLE.infix["^"] = MO.WIDEREL;
1810 OPTABLE.infix["_"] = MO.WIDEREL;
1811 OPTABLE.prefix["\u2223"] = MO.OPEN;
1812 OPTABLE.prefix["\u2225"] = MO.OPEN;
1813 OPTABLE.postfix["\u2223"] = MO.CLOSE;
1814 OPTABLE.postfix["\u2225"] = MO.CLOSE;
1815
1816 })(MathJax.ElementJax.mml);
1817
1818 MathJax.ElementJax.mml.loadComplete("jax.js");