diff --git a/unpacked/MathJax.js b/unpacked/MathJax.js index e2db6defb..f8b22b17e 100644 --- a/unpacked/MathJax.js +++ b/unpacked/MathJax.js @@ -3105,11 +3105,13 @@ MathJax.Hub.Startup = { isMac: (navigator.platform.substr(0,3) === "Mac"), isPC: (navigator.platform.substr(0,3) === "Win"), isMSIE: ("ActiveXObject" in window && "clipboardData" in window), + isEdge: ("MSGestureEvent" in window && "chrome" in window && + window.chrome.loadTimes == null), isFirefox: (!!AGENT.match(/Gecko\//) && !AGENT.match(/like Gecko/)), isSafari: (!!AGENT.match(/ (Apple)?WebKit\//) && !AGENT.match(/ like iPhone /) && - (!window.chrome || window.chrome.loadTimes == null)), - isChrome: (window.chrome != null && window.chrome.loadTimes != null), - isOpera: (window.opera != null && window.opera.version != null), + (!window.chrome || window.chrome.app == null)), + isChrome: ("chrome" in window && window.chrome.loadTimes != null), + isOpera: ("opera" in window && window.opera.version != null), isKonqueror: ("konqueror" in window && navigator.vendor == "KDE"), versionAtLeast: function (v) { var bv = (this.version).split('.'); v = (new String(v)).split('.'); @@ -3137,7 +3139,7 @@ MathJax.Hub.Startup = { HUB.Browser = HUB.Insert(new String(browser),BROWSERS); var VERSION = new RegExp( ".*(Version/| Trident/.*; rv:)((?:\\d+\\.)+\\d+)|" + // for Safari, Opera10, and IE11+ - ".*("+browser+")"+(browser == "MSIE" ? " " : "/")+"((?:\\d+\\.)*\\d+)|"+ // for one of the main browser + ".*("+browser+")"+(browser == "MSIE" ? " " : "/")+"((?:\\d+\\.)*\\d+)|"+ // for one of the main browsers "(?:^|\\(| )([a-z][-a-z0-9._: ]+|(?:Apple)?WebKit)/((?:\\d+\\.)+\\d+)"); // for unrecognized browser var MATCH = VERSION.exec(xAGENT) || ["","","","unknown","0.0"]; HUB.Browser.name = (MATCH[1] != "" ? browser : (MATCH[3] || MATCH[5])); @@ -3191,8 +3193,15 @@ MathJax.Hub.Startup = { AGENT.match(/ Fennec\//) != null || AGENT.match(/Mobile/) != null); }, + Chrome: function (browser) { + browser.noContextMenu = browser.isMobile = !!navigator.userAgent.match(/ Mobile[ \/]/); + }, Opera: function (browser) {browser.version = opera.version()}, + Edge: function (browser) { + browser.isMobile = !!navigator.userAgent.match(/ Phone/); + }, MSIE: function (browser) { + browser.isMobile = !!navigator.userAgent.match(/ Phone/); browser.isIE9 = !!(document.documentMode && (window.performance || window.msPerformance)); MathJax.HTML.setScriptBug = !browser.isIE9 || document.documentMode < 9; MathJax.Hub.msieHTMLCollectionBug = (document.documentMode < 9); diff --git a/unpacked/extensions/HelpDialog.js b/unpacked/extensions/HelpDialog.js index 292f15d1f..e26d0367e 100644 --- a/unpacked/extensions/HelpDialog.js +++ b/unpacked/extensions/HelpDialog.js @@ -161,8 +161,8 @@ ]], ["a",{href:"http://www.mathjax.org/"},["www.mathjax.org"]], ["span",{id: "MathJax_HelpClose", onclick: HELP.Remove, - onkeydown: HELP.Keydown, tabIndex: 0, "aria-label": "Close", - "aria-describedby": LOCALE._(["HelpDialog","CloseWindow"],"Close window")}, + onkeydown: HELP.Keydown, tabIndex: 0, role: "button", + "aria-label": LOCALE._(["HelpDialog","CloseWindow"],"Close window")}, [["span",{},["\u00D7"]]] ] ])); diff --git a/unpacked/extensions/MathML/mml3.js b/unpacked/extensions/MathML/mml3.js index 575953eea..90a98f59b 100644 --- a/unpacked/extensions/MathML/mml3.js +++ b/unpacked/extensions/MathML/mml3.js @@ -72,17 +72,661 @@ MathJax.Hub.Register.StartupHook("MathML Jax Ready",function () { }); /* - * The following is taken from mml3mj.xsl - * (https://web-xslt.googlecode.com/svn/trunk/ctop/mml3mj.xsl) + * The following is derived from mml3mj.xsl + * (https://github.com/davidcarlisle/web-xslt/blob/master/ctop/mml3mj.xsl) * which is Copyright (c) David Carlisle 2008-2015. * It is used by permission of David Carlisle, who has agreed to allow it to * be released under the Apache License, Version 2.0. */ - var mml3Stylesheet = ' this[\'node-set\'] = function (x) { return x; })(][}{)(][}{\)(}{><top right 0decimalpoint decimalpoint.decimalpoint*0.1em0.15em0.2em0.15em0)(/\\:=top)'; + var BROWSER = MathJax.Hub.Browser; + var exslt = ''; + if (BROWSER.isEdge || BROWSER.isMSIE) { + exslt = 'urn:schemas-microsoft-com:xslt' + } else { + exslt = 'http://exslt.org/common'; + } + var mml3Stylesheet = + '' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + ' ' + + '' + + ' ' + + ' ltr' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + ' ' + + '' + + ' )' + + '' + + ' (' + + '' + + '' + + ' ]' + + '' + + '' + + ' [' + + '' + + '' + + ' }' + + '' + + '' + + ' {' + + '' + + '' + + ' ' + + '' + + ' )' + + '' + + ' (' + + '' + + '' + + ' ]' + + '' + + '' + + ' [' + + '' + + '' + + ' }' + + '' + + '' + + ' {' + + '' + + ' ' + + ' ' + + ' \' + + ' ' + + ' ' + + '' + + ' ' + + ' ' + + ' ' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + '' + + ' ' + + ' ' + + ' ' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + ')' + + '(' + + '}' + + '{' + + '>' + + '<' + + '' + + '' + + '' + + ' top right' + + '' + + '' + + ' ' + + ' ' + + ' ' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' 0' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + '' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' decimalpoint' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' decimalpoint' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' .' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' decimalpoint' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' *' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' 0.1em' + + ' 0.15em' + + ' 0.2em' + + ' ' + + ' 0.15em' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' 0' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' )' + + ' ' + + ' (' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' /' + + ' ' + + ' \' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' :' + + ' ' + + ' =' + + ' ' + + ' ' + + ' ' + + ' ' + + ' top' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' )' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + ' ' + + '' + + '' + + ' ' + + ' ' + + ' ' + + ''; + /* * End of mml3mj.xsl material. */ - + var mml3; if (window.XSLTProcessor) { // standard method: just use an XSLTProcessor and parse the stylesheet @@ -121,6 +765,18 @@ MathJax.Hub.Register.StartupHook("MathML Jax Ready",function () { // No XSLT support. Do not change the content. MATHML.mml3XSLT = null; } + + // Tweak CSS to avoid some browsers rearranging HTML output + MathJax.Ajax.Styles({ + ".MathJax .mi, .MathJax .mo, .MathJax .mn, .MathJax .mtext": { + direction: "ltr", + display: "inline-block" + }, + ".MathJax .ms, .MathJax .mspace, .MathJax .mglyph": { + direction: "ltr", + display: "inline-block" + } + }); MathJax.Hub.Startup.signal.Post("MathML mml3.js Ready"); }); diff --git a/unpacked/extensions/MathMenu.js b/unpacked/extensions/MathMenu.js index 9e47031c6..2bef958ac 100644 --- a/unpacked/extensions/MathMenu.js +++ b/unpacked/extensions/MathMenu.js @@ -295,7 +295,7 @@ onmouseup: MENU.Mouseup, ondblclick: FALSE, ondragstart: FALSE, onselectstart: FALSE, oncontextmenu: FALSE, menuItem: this, className: "MathJax_Menu", onkeydown: MENU.Keydown, - role: "navigation" + role: "menu" }); if (event.type === "contextmenu" || event.type === "mouseover") menu.className += " MathJax_ContextMenu"; @@ -614,7 +614,8 @@ {onmouseup: MENU.Mouseup, ondragstart: FALSE, onselectstart: FALSE, onselectend: FALSE, ontouchstart: MENU.Touchstart, ontouchend: MENU.Touchend, - className: "MathJax_MenuItem", menuItem: this}, + className: "MathJax_MenuItem", role: this.role, + menuItem: this}, def); }, @@ -695,14 +696,12 @@ * Abstract class of menu items that are focusable and perform some action */ MENU.ENTRY = MENU.ITEM.Subclass({ - role: "menuitem", // Aria role. Attributes: function(def) { def = HUB.Insert( {onmouseover: MENU.Mouseover, onmouseout: MENU.Mouseout, - onmousedown: MENU.Mousedown, role: this.role, - onkeydown: MENU.Keydown, + onmousedown: MENU.Mousedown, onkeydown: MENU.Keydown, "aria-disabled": !!this.disabled}, def); def = this.SUPER(arguments).Attributes.call(this, def); @@ -814,6 +813,11 @@ marker: "\u25BA", // the submenu arrow markerRTL: "\u25C4", // the submenu arrow for RTL + Attributes: function(def) { + def = HUB.Insert({"aria-haspopup": "true"}, def); + def = this.SUPER(arguments).Attributes.call(this, def); + return def; + }, Init: function (name,def) { if (!(name instanceof Array)) {name = [name,name]} // make [id,label] pair this.name = name; var i = 1; @@ -907,6 +911,12 @@ marker: (isPC ? "\u25CF" : "\u2713"), // the checkmark role: "menuitemradio", + Attributes: function(def) { + var checked = CONFIG.settings[this.variable] === this.value ? "true" : "false"; + def = HUB.Insert({"aria-checked": checked}, def); + def = this.SUPER(arguments).Attributes.call(this, def); + return def; + }, Init: function (name,variable,def) { if (!(name instanceof Array)) {name = [name,name]} // make [id,label] pair this.name = name; this.variable = variable; this.With(def); @@ -914,7 +924,9 @@ }, Label: function (def,menu) { var span = {className:"MathJax_MenuRadioCheck" + this.rtlClass()}; - if (CONFIG.settings[this.variable] !== this.value) {span = {style:{display:"none"}}} + if (CONFIG.settings[this.variable] !== this.value) { + span = {style:{display:"none"}}; + } return [["span",span,[this.marker]]," "+this.Name()]; }, Mouseup: function (event,menu) { @@ -922,8 +934,9 @@ var child = menu.parentNode.childNodes; for (var i = 0, m = child.length; i < m; i++) { var item = child[i].menuItem; - if (item && item.variable === this.variable) - {child[i].firstChild.style.display = "none"} + if (item && item.variable === this.variable) { + child[i].firstChild.style.display = "none"; + } } menu.firstChild.display = ""; CONFIG.settings[this.variable] = this.value; @@ -945,6 +958,12 @@ marker: "\u2713", // the checkmark role: "menuitemcheckbox", + Attributes: function(def) { + var checked = CONFIG.settings[this.variable] ? "true" : "false"; + def = HUB.Insert({"aria-checked": checked}, def); + def = this.SUPER(arguments).Attributes.call(this, def); + return def; + }, Init: function (name,variable,def) { if (!(name instanceof Array)) {name = [name,name]} // make [id,label] pair this.name = name; this.variable = variable; this.With(def); @@ -994,6 +1013,13 @@ * A rule in a menu */ MENU.ITEM.RULE = MENU.ITEM.Subclass({ + role: "separator", + + Attributes: function(def) { + def = HUB.Insert({"aria-orientation": "vertical"}, def); + def = this.SUPER(arguments).Attributes.call(this, def); + return def; + }, Label: function (def,menu) { def.className += " MathJax_MenuRule"; return null; @@ -1035,8 +1061,8 @@ ["a",{href:"http://www.mathjax.org/"},["www.mathjax.org"]], ["span",{className:"MathJax_MenuClose",id:"MathJax_AboutClose", onclick:MENU.About.Remove, - onkeydown: MENU.About.Keydown, tabIndex: 0, - "aria-label": "Close", "aria-describedby": _("CloseWindow","Close window")}, + onkeydown: MENU.About.Keydown, tabIndex: 0, role: "button", + "aria-label": _("CloseWindow","Close window")}, [["span",{},"\u00D7"]]] ]); if (event.type === "mouseup") about.className += " MathJax_MousePost"; @@ -1230,6 +1256,7 @@ if (BROWSER.isChrome && BROWSER.version.substr(0,3) !== "24.") {message = MESSAGE.MML.WebKit} else if (BROWSER.isSafari && !BROWSER.versionAtLeast("5.0")) {message = MESSAGE.MML.WebKit} else if (BROWSER.isMSIE) {if (!BROWSER.hasMathPlayer) {message = MESSAGE.MML.MSIE}} + else if (BROWSER.isEdge) {message = MESSAGE.MML.WebKit} else {message = MESSAGE.MML[BROWSER]} warned = "warnedMML"; } diff --git a/unpacked/extensions/TeX/AMSmath.js b/unpacked/extensions/TeX/AMSmath.js index 545135362..c6d974b21 100644 --- a/unpacked/extensions/TeX/AMSmath.js +++ b/unpacked/extensions/TeX/AMSmath.js @@ -134,14 +134,14 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () { aligned: ['AlignedAMSArray',null,null,null,'rlrlrlrlrlrl',COLS([0,2,0,2,0,2,0,2,0,2,0]),".5em",'D'], gathered: ['AlignedAMSArray',null,null,null,'c',null,".5em",'D'], - subarray: ['Array',null,null,null,null,COLS([0,0,0,0]),"0.1em",'S',1], + subarray: ['Array',null,null,null,null,COLS([0]),"0.1em",'S',1], smallmatrix: ['Array',null,null,null,'c',COLS([1/3]),".2em",'S',1], 'equation': ['EquationBegin','Equation',true], 'equation*': ['EquationBegin','EquationStar',false], - eqnarray: ['AMSarray',null,true,true, 'rcl',MML.LENGTH.THICKMATHSPACE,".5em"], - 'eqnarray*': ['AMSarray',null,false,true,'rcl',MML.LENGTH.THICKMATHSPACE,".5em"] + eqnarray: ['AMSarray',null,true,true, 'rcl',COLS([0]),".5em"], + 'eqnarray*': ['AMSarray',null,false,true,'rcl',COLS([0]),".5em"] }, delimiter: { diff --git a/unpacked/jax/output/CommonHTML/autoload/mmultiscripts.js b/unpacked/jax/output/CommonHTML/autoload/mmultiscripts.js index e412a1c91..1a1914e17 100644 --- a/unpacked/jax/output/CommonHTML/autoload/mmultiscripts.js +++ b/unpacked/jax/output/CommonHTML/autoload/mmultiscripts.js @@ -45,7 +45,7 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () { // var base, bbox; if (stretch) { - base = node.getElementsByTagName("mjx-base")[0]; + base = CHTML.getNode(node,"mjx-base"); } else { this.CHTMLaddChild(node,0,{type:"mjx-base", noBBox:true, forceChild:true}); base = node.firstChild; @@ -137,10 +137,10 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () { // CHTMLgetScripts: function (BOX,BBOX,stretch,node) { if (stretch) { - BOX.sub = node.getElementsByTagName("mjx-sub")[0]; - BOX.sup = node.getElementsByTagName("mjx-sup")[0]; - BOX.presub = node.getElementsByTagName("mjx-presub")[0]; - BOX.presup = node.getElementsByTagName("mjx-presup")[0]; + BOX.sub = CHTML.getNode(node,"mjx-sub"); + BOX.sup = CHTML.getNode(node,"mjx-sup"); + BOX.presub = CHTML.getNode(node,"mjx-presub"); + BOX.presup = CHTML.getNode(node,"mjx-presup"); BBOX.sub = this.CHTMLbbox.sub; BBOX.sup = this.CHTMLbbox.sup; BBOX.presub = this.CHTMLbbox.presub; @@ -182,7 +182,7 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () { BBOX = state.BBOX[type] = CHTML.BBOX.empty(); if (state.w) { BOX.style.paddingLeft = CHTML.Em(state.w); - BBOX.w = BBOX.r = state.w; + BBOX.w = BBOX.r = state.w; BBOX.x = state.w; } } data.toCommonHTML(BOX); @@ -198,7 +198,7 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () { // right-justify the scripts, otherwise, left-justify them. // CHTMLpadScript: function (type,w,bbox,state) { - if (!bbox) bbox = {w:0, fake:1}; + if (!bbox) bbox = {w:0, fake:1, rscale:1}; var BBOX = state.BBOX[type], dx = 0, dw = 0; if (BBOX) { if (bbox.rscale*bbox.w < w) { @@ -252,7 +252,7 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () { CHTMLplaceSubSup: function (sub,sbox,sup,Sbox,x,delta,u,v,s) { sub.style.paddingRight = CHTML.Em(s); sbox.w += s; sup.style.paddingBottom = CHTML.Em(u+v-Sbox.d-sbox.h); - sup.style.paddingLeft = CHTML.Em(delta); + sup.style.paddingLeft = CHTML.Em(delta+(Sbox.x||0)); sup.style.paddingRight = CHTML.Em(s); Sbox.w += s; sup.parentNode.style.verticalAlign = CHTML.Em(-v); this.CHTML.combine(sbox,x,-v); @@ -272,7 +272,7 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () { CHTMLplacePresubPresup: function (presub,pbox,presup,Pbox,delta,u,v,s) { presub.style.paddingLeft = CHTML.Em(s); presup.style.paddingBottom = CHTML.Em(u+v-Pbox.d-pbox.h); - presup.style.paddingLeft = CHTML.Em(delta+s); + presup.style.paddingLeft = CHTML.Em(delta+s+(Pbox.x||0)); presup.style.paddingRight = CHTML.Em(-delta); presup.parentNode.style.verticalAlign = CHTML.Em(-v); this.CHTML.combine(pbox,s,-v); diff --git a/unpacked/jax/output/CommonHTML/autoload/multiline.js b/unpacked/jax/output/CommonHTML/autoload/multiline.js index 3b30c07f4..fcccc549a 100644 --- a/unpacked/jax/output/CommonHTML/autoload/multiline.js +++ b/unpacked/jax/output/CommonHTML/autoload/multiline.js @@ -505,9 +505,9 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () { // if (end.length === 0) { var NODE = this.CHTMLnodeElement(), - stack = NODE.getElementsByTagName("mjx-stack")[0], - sup = NODE.getElementsByTagName("mjx-sup")[0], - sub = NODE.getElementsByTagName("mjx-sub")[0]; + stack = CHTML.getNode(NODE,"mjx-stack"), + sup = CHTML.getNode(NODE,"mjx-sup"), + sub = CHTML.getNode(NODE,"mjx-sub"); if (stack) node.appendChild(stack); else if (sup) node.appendChild(sup); else if (sub) node.appendChild(sub); @@ -569,9 +569,9 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () { // if (start.length < 1) { NODE = this.CHTMLnodeElement(); - var prestack = NODE.getElementsByTagName("mjx-prestack")[0], - presup = NODE.getElementsByTagName("mjx-presup")[0], - presub = NODE.getElementsByTagName("mjx-presub")[0]; + var prestack = CHTML.getNode(NODE,"mjx-prestack"), + presup = CHTML.getNode(NODE,"mjx-presup"), + presub = CHTML.getNode(NODE,"mjx-presub"); if (prestack) node.appendChild(prestack); else if (presup) node.appendChild(presup); else if (presub) node.appendChild(presub); @@ -598,9 +598,9 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () { // if (end.length === 0) { NODE = this.CHTMLnodeElement(); - var stack = NODE.getElementsByTagName("mjx-stack")[0], - sup = NODE.getElementsByTagName("mjx-sup")[0], - sub = NODE.getElementsByTagName("mjx-sub")[0]; + var stack = CHTML.getNode(NODE,"mjx-stack"), + sup = CHTML.getNode(NODE,"mjx-sup"), + sub = CHTML.getNode(NODE,"mjx-sub"); if (stack) node.appendChild(stack); else if (sup) node.appendChild(sup); else if (sub) node.appendChild(sub); diff --git a/unpacked/jax/output/CommonHTML/jax.js b/unpacked/jax/output/CommonHTML/jax.js index f3d070fba..236695eaf 100644 --- a/unpacked/jax/output/CommonHTML/jax.js +++ b/unpacked/jax/output/CommonHTML/jax.js @@ -325,8 +325,9 @@ if (!def) def = {}; if (def.isMathJax == null) def.isMathJax = true; if (def.className) def.className = type+" "+def.className; else def.className = type; + type = "span"; } - return this.HTMLElement("span",def,content); + return this.HTMLElement(type,def,content); }, addElement: function (node,type,def,content) { return node.appendChild(this.Element(type,def,content)); @@ -335,6 +336,22 @@ ucMatch: HTML.ucMatch, setScript: HTML.setScript, + // + // This replaces node.getElementsByTagName(type)[0] + // and should be replaced by that if we go back to using + // custom tags + // + getNode: (document.getElementsByClassName ? + function (node,type) {return node.getElementsByClassName(type)[0]} : + function (node,type) { + var nodes = node.getElementsByTagName("span"); + var name = RegExp("\\b"+type+"\\b"); + for (var i = 0, m = nodes.length; i < m; i++) { + if (name.test(nodes[i].className)) return nodes[i]; + } + } + ), + /********************************************/ @@ -361,7 +378,7 @@ // Remove any existing output // prev = script.previousSibling; - if (prev && prev.nodeName.toLowerCase() === "mjx-chtml") + if (prev && prev.className && String(prev.className).substr(0,9) === "mjx-chtml") prev.parentNode.removeChild(prev); // // Add the node for the math and mark it as being processed @@ -1328,7 +1345,7 @@ if (child) { var type = options.childNodes; if (type) { - if (type instanceof Array) type = type[i]; + if (type instanceof Array) type = type[i]||"span"; node = CHTML.addElement(node,type); } cnode = child.toCommonHTML(node,options.childOptions); @@ -1667,6 +1684,9 @@ MML.math.Augment({ toCommonHTML: function (node) { node = this.CHTMLdefaultNode(node); + var alttext = this.Get("alttext"); + if (alttext && !node.getAttribute("aria-label")) node.setAttribute("aria-label",alttext); + if (!node.getAttribute("role")) node.setAttribute("role","math"); if (this.CHTML.pwidth) { node.parentNode.style.width = this.CHTML.pwidth; node.parentNode.style.minWidth = this.CHTML.mwidth; @@ -2032,9 +2052,9 @@ // var base, under, over, nodes = []; if (stretch) { - base = node.getElementsByTagName("mjx-op")[0]; - under = node.getElementsByTagName("mjx-under")[0]; - over = node.getElementsByTagName("mjx-over")[0]; + base = CHTML.getNode(node,"mjx-op"); + under = CHTML.getNode(node,"mjx-under"); + over = CHTML.getNode(node,"mjx-over"); nodes[0] = base; nodes[1] = under||over; nodes[2] = over; } else { var types = ["mjx-op","mjx-under","mjx-over"]; @@ -2232,9 +2252,9 @@ // var base, sub, sup; if (stretch) { - base = node.getElementsByTagName("mjx-base")[0]; - sub = node.getElementsByTagName("mjx-sub")[0]; - sup = node.getElementsByTagName("mjx-sup")[0]; + base = CHTML.getNode(node,"mjx-base"); + sub = CHTML.getNode(node,"mjx-sub"); + sup = CHTML.getNode(node,"mjx-sup"); } else { var types = ["mjx-base","mjx-sub","mjx-sup"]; if (this.sup === 1) types[1] = types[2]; diff --git a/unpacked/jax/output/SVG/jax.js b/unpacked/jax/output/SVG/jax.js index 658934313..912a489bc 100644 --- a/unpacked/jax/output/SVG/jax.js +++ b/unpacked/jax/output/SVG/jax.js @@ -2100,9 +2100,8 @@ // Add it to the MathJax span // var alttext = this.Get("alttext"); - if (alttext && !svg.element.getAttribute("aria-label")) span.setAttribute("aria-label",alttext); - if (!svg.element.getAttribute("role")) span.setAttribute("role","math"); -// span.setAttribute("tabindex",0); // causes focus outline, so disable for now + if (alttext && !svg.element.getAttribute("aria-label")) svg.element.setAttribute("aria-label",alttext); + if (!svg.element.getAttribute("role")) svg.element.setAttribute("role","img"); svg.element.setAttribute("focusable","false"); span.appendChild(svg.element); svg.element = null;