jax.js 63 KB

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