jax.js 64 KB

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