jax.js 58 KB

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