diff --git a/unpacked/MathJax.js b/unpacked/MathJax.js index c5f456373..84a1a9fe4 100644 --- a/unpacked/MathJax.js +++ b/unpacked/MathJax.js @@ -659,6 +659,8 @@ MathJax.cdnFileVersions = {}; // can be used to specify revisions for individua var PATH = {}; PATH[BASENAME] = ""; // empty path gets the root URL + PATH.Contrib = (String(location.protocol).match(/^https?:/) ? "" : "http:") + + "//cdn.mathjax.org/mathjax/contrib"; // the third-party extensions BASE.Ajax = { loaded: {}, // files already loaded diff --git a/unpacked/extensions/AssistiveMML.js b/unpacked/extensions/AssistiveMML.js index 6d6dea6f8..ce320454f 100644 --- a/unpacked/extensions/AssistiveMML.js +++ b/unpacked/extensions/AssistiveMML.js @@ -115,7 +115,8 @@ while (state.i < m) { jax = state.jax[state.i]; frame = document.getElementById(jax.inputID+"-Frame"); - if (jax.outputJax !== "NativeMML" && frame && !frame.getAttribute("data-mathml")) { + if (jax.outputJax !== "NativeMML" && jax.outputJax !== "PlainSource" && + frame && !frame.getAttribute("data-mathml")) { try { mml = jax.root.toMathML("").replace(/\n */g,"").replace(//g,""); } catch (err) { diff --git a/unpacked/extensions/HTML-CSS/handle-floats.js b/unpacked/extensions/HTML-CSS/handle-floats.js index b919a0540..beba99a83 100644 --- a/unpacked/extensions/HTML-CSS/handle-floats.js +++ b/unpacked/extensions/HTML-CSS/handle-floats.js @@ -41,42 +41,9 @@ MathJax.Extension["HTML-CSS/handle-floats"] = { }; // -// Make the display DIV be a table-cell -// Use padding to get the separation, since table cells don't do margin -// Make the width large (it will shrink to fit the remaining room) +// This file is now obsolete, since the HTML-CSS output already handles +// floating elements properly. // -MathJax.Hub.Config({ - "HTML-CSS": { - styles: { - ".MathJax_Display": { - display: "table-cell", - padding: "1em 0 ! important", - width: (MathJax.Hub.Browser.isMSIE && (document.documentMode||0) < 8 ? "100%" : "1000em") - } - } - } -}); - -// -// Two consecutive equations would end up side-by-side, so force a separator -// (Needed by IE8, IE9, and Firefox, at least). -// -MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () { - var HTMLCSS = MathJax.OutputJax["HTML-CSS"], - TRANSLATE = HTMLCSS.Translate; - HTMLCSS.Augment({ - Translate: function (script,state) { - TRANSLATE.apply(this,arguments); - if (script.MathJax.elementJax.HTMLCSS.display) { - var next = script.nextSibling; - if (!next || next.className !== "MathJax_MSIE_Separator") { - var span = HTMLCSS.Element("span",{className:"MathJax_MSIE_Separator"}); - script.parentNode.insertBefore(span,next); - } - } - } - }); - MathJax.Hub.Startup.signal.Post("HTML-CSS handle-floats Ready"); -}); +MathJax.Hub.Startup.signal.Post("HTML-CSS handle-floats Ready"); MathJax.Ajax.loadComplete("[MathJax]/extensions/HTML-CSS/handle-floats.js"); diff --git a/unpacked/extensions/TeX/mediawiki-texvc.js b/unpacked/extensions/TeX/mediawiki-texvc.js index e43351f2a..e31fdec21 100644 --- a/unpacked/extensions/TeX/mediawiki-texvc.js +++ b/unpacked/extensions/TeX/mediawiki-texvc.js @@ -1,106 +1,129 @@ +/************************************************************* + * + * MathJax/extensions/TeX/mediawiki-texvc.js + * + * Implements macros used by mediawiki with their texvc preprocessor. + * + * --------------------------------------------------------------------- + * + * Copyright (c) 2015-2016 The MathJax Consortium + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + MathJax.Extension["TeX/mediawiki-texvc"] = { - version: "2.6.0-beta.2" + version: "2.6.1" }; MathJax.Hub.Register.StartupHook("TeX Jax Ready", function () { - MathJax.InputJax.TeX.Definitions.Add({ - macros: { - AA: ["Macro", "\u00c5"], - alef: ["Macro", "\\aleph"], - alefsym: ["Macro", "\\aleph"], - Alpha: ["Macro", "\\mathrm{A}"], - and: ["Macro", "\\land"], - ang: ["Macro", "\\angle"], - Bbb: ["Macro", "\\mathbb"], - Beta: ["Macro", "\\mathrm{B}"], - bold: ["Macro", "\\mathbf"], - bull: ["Macro", "\\bullet"], - C: ["Macro", "\\mathbb{C}"], - Chi: ["Macro", "\\mathrm{X}"], - clubs: ["Macro", "\\clubsuit"], - cnums: ["Macro", "\\mathbb{C}"], - Complex: ["Macro", "\\mathbb{C}"], - coppa: ["Macro", "\u03D9"], - Coppa: ["Macro", "\u03D8"], - Dagger: ["Macro", "\\ddagger"], - Digamma: ["Macro", "\u03DC"], - darr: ["Macro", "\\downarrow"], - dArr: ["Macro", "\\Downarrow"], - Darr: ["Macro", "\\Downarrow"], - diamonds: ["Macro", "\\diamondsuit"], - empty: ["Macro", "\\emptyset"], - Epsilon: ["Macro", "\\mathrm{E}"], - Eta: ["Macro", "\\mathrm{H}"], - euro: ["Macro", "\u20AC"], - exist: ["Macro", "\\exists"], - geneuro: ["Macro", "\u20AC"], - geneuronarrow: ["Macro", "\u20AC"], - geneurowide: ["Macro", "\u20AC"], - H: ["Macro", "\\mathbb{H}"], - hAar: ["Macro", "\\Leftrightarrow"], - harr: ["Macro", "\\leftrightarrow"], - Harr: ["Macro", "\\Leftrightarrow"], - hearts: ["Macro", "\\heartsuit"], - image: ["Macro", "\\Im"], - infin: ["Macro", "\\infty"], - Iota: ["Macro", "\\mathrm{I}"], - isin: ["Macro", "\\in"], - Kappa: ["Macro", "\\mathrm{K}"], - koppa: ["Macro", "\u03DF"], - Koppa: ["Macro", "\u03DE"], - lang: ["Macro", "\\langle"], - larr: ["Macro", "\\leftarrow"], - Larr: ["Macro", "\\Leftarrow"], - lArr: ["Macro", "\\Leftarrow"], - lrarr: ["Macro", "\\leftrightarrow"], - Lrarr: ["Macro", "\\Leftrightarrow"], - lrArr: ["Macro", "\\Leftrightarrow"], - Mu: ["Macro", "\\mathrm{M}"], - N: ["Macro", "\\mathbb{N}"], - natnums: ["Macro", "\\mathbb{N}"], - Nu: ["Macro", "\\mathrm{N}"], - O: ["Macro", "\\emptyset"], - officialeuro: ["Macro", "\u20AC"], - Omicron: ["Macro", "\\mathrm{O}"], - or: ["Macro", "\\lor"], - P: ["Macro", "\u00B6"], - pagecolor: ['Macro','',1], // ignore \pagecolor{} - part: ["Macro", "\\partial"], - plusmn: ["Macro", "\\pm"], - Q: ["Macro", "\\mathbb{Q}"], - R: ["Macro", "\\mathbb{R}"], - rang: ["Macro", "\\rangle"], - rarr: ["Macro", "\\rightarrow"], - Rarr: ["Macro", "\\Rightarrow"], - rArr: ["Macro", "\\Rightarrow"], - real: ["Macro", "\\Re"], - reals: ["Macro", "\\mathbb{R}"], - Reals: ["Macro", "\\mathbb{R}"], - Rho: ["Macro", "\\mathrm{P}"], - sdot: ["Macro", "\\cdot"], - sampi: ["Macro", "\u03E1"], - Sampi: ["Macro", "\u03E0"], - sect: ["Macro", "\\S"], - spades: ["Macro", "\\spadesuit"], - stigma: ["Macro", "\u03DB"], - Stigma: ["Macro", "\u03DA"], - sub: ["Macro", "\\subset"], - sube: ["Macro", "\\subseteq"], - supe: ["Macro", "\\supseteq"], - Tau: ["Macro", "\\mathrm{T}"], - textvisiblespace: ["Macro", "\u2423"], - thetasym: ["Macro", "\\vartheta"], - uarr: ["Macro", "\\uparrow"], - uArr: ["Macro", "\\Uparrow"], - Uarr: ["Macro", "\\Uparrow"], - varcoppa: ["Macro", "\u03D9"], - varstigma: ["Macro", "\u03DB"], - vline: ['Macro','\\smash{\\large\\lvert}',0], - weierp: ["Macro", "\\wp"], - Z: ["Macro", "\\mathbb{Z}"], - Zeta: ["Macro", "\\mathrm{Z}"] - } - }); + MathJax.InputJax.TeX.Definitions.Add({ + macros: { + AA: ["Macro", "\u00c5"], + alef: ["Macro", "\\aleph"], + alefsym: ["Macro", "\\aleph"], + Alpha: ["Macro", "\\mathrm{A}"], + and: ["Macro", "\\land"], + ang: ["Macro", "\\angle"], + Bbb: ["Macro", "\\mathbb"], + Beta: ["Macro", "\\mathrm{B}"], + bold: ["Macro", "\\mathbf"], + bull: ["Macro", "\\bullet"], + C: ["Macro", "\\mathbb{C}"], + Chi: ["Macro", "\\mathrm{X}"], + clubs: ["Macro", "\\clubsuit"], + cnums: ["Macro", "\\mathbb{C}"], + Complex: ["Macro", "\\mathbb{C}"], + coppa: ["Macro", "\u03D9"], + Coppa: ["Macro", "\u03D8"], + Dagger: ["Macro", "\\ddagger"], + Digamma: ["Macro", "\u03DC"], + darr: ["Macro", "\\downarrow"], + dArr: ["Macro", "\\Downarrow"], + Darr: ["Macro", "\\Downarrow"], + diamonds: ["Macro", "\\diamondsuit"], + empty: ["Macro", "\\emptyset"], + Epsilon: ["Macro", "\\mathrm{E}"], + Eta: ["Macro", "\\mathrm{H}"], + euro: ["Macro", "\u20AC"], + exist: ["Macro", "\\exists"], + geneuro: ["Macro", "\u20AC"], + geneuronarrow: ["Macro", "\u20AC"], + geneurowide: ["Macro", "\u20AC"], + H: ["Macro", "\\mathbb{H}"], + hAar: ["Macro", "\\Leftrightarrow"], + harr: ["Macro", "\\leftrightarrow"], + Harr: ["Macro", "\\Leftrightarrow"], + hearts: ["Macro", "\\heartsuit"], + image: ["Macro", "\\Im"], + infin: ["Macro", "\\infty"], + Iota: ["Macro", "\\mathrm{I}"], + isin: ["Macro", "\\in"], + Kappa: ["Macro", "\\mathrm{K}"], + koppa: ["Macro", "\u03DF"], + Koppa: ["Macro", "\u03DE"], + lang: ["Macro", "\\langle"], + larr: ["Macro", "\\leftarrow"], + Larr: ["Macro", "\\Leftarrow"], + lArr: ["Macro", "\\Leftarrow"], + lrarr: ["Macro", "\\leftrightarrow"], + Lrarr: ["Macro", "\\Leftrightarrow"], + lrArr: ["Macro", "\\Leftrightarrow"], + Mu: ["Macro", "\\mathrm{M}"], + N: ["Macro", "\\mathbb{N}"], + natnums: ["Macro", "\\mathbb{N}"], + Nu: ["Macro", "\\mathrm{N}"], + O: ["Macro", "\\emptyset"], + officialeuro: ["Macro", "\u20AC"], + Omicron: ["Macro", "\\mathrm{O}"], + or: ["Macro", "\\lor"], + P: ["Macro", "\u00B6"], + pagecolor: ['Macro','',1], // ignore \pagecolor{} + part: ["Macro", "\\partial"], + plusmn: ["Macro", "\\pm"], + Q: ["Macro", "\\mathbb{Q}"], + R: ["Macro", "\\mathbb{R}"], + rang: ["Macro", "\\rangle"], + rarr: ["Macro", "\\rightarrow"], + Rarr: ["Macro", "\\Rightarrow"], + rArr: ["Macro", "\\Rightarrow"], + real: ["Macro", "\\Re"], + reals: ["Macro", "\\mathbb{R}"], + Reals: ["Macro", "\\mathbb{R}"], + Rho: ["Macro", "\\mathrm{P}"], + sdot: ["Macro", "\\cdot"], + sampi: ["Macro", "\u03E1"], + Sampi: ["Macro", "\u03E0"], + sect: ["Macro", "\\S"], + spades: ["Macro", "\\spadesuit"], + stigma: ["Macro", "\u03DB"], + Stigma: ["Macro", "\u03DA"], + sub: ["Macro", "\\subset"], + sube: ["Macro", "\\subseteq"], + supe: ["Macro", "\\supseteq"], + Tau: ["Macro", "\\mathrm{T}"], + textvisiblespace: ["Macro", "\u2423"], + thetasym: ["Macro", "\\vartheta"], + uarr: ["Macro", "\\uparrow"], + uArr: ["Macro", "\\Uparrow"], + Uarr: ["Macro", "\\Uparrow"], + varcoppa: ["Macro", "\u03D9"], + varstigma: ["Macro", "\u03DB"], + vline: ['Macro','\\smash{\\large\\lvert}',0], + weierp: ["Macro", "\\wp"], + Z: ["Macro", "\\mathbb{Z}"], + Zeta: ["Macro", "\\mathrm{Z}"] + } + }); }); MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/mediawiki-texvc.js"); diff --git a/unpacked/extensions/asciimath2jax.js b/unpacked/extensions/asciimath2jax.js index f6fae5206..2ca0ffbcc 100644 --- a/unpacked/extensions/asciimath2jax.js +++ b/unpacked/extensions/asciimath2jax.js @@ -207,11 +207,13 @@ MathJax.Extension.asciimath2jax = { }, createPreview: function (mode,asciimath) { + var previewClass = MathJax.Hub.config.preRemoveClass; var preview = this.config.preview; if (preview === "none") return; + if ((this.search.close.previousSibling||{}).className === previewClass) return; if (preview === "AsciiMath") {preview = [this.filterPreview(asciimath)]} if (preview) { - preview = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass},preview); + preview = MathJax.HTML.Element("span",{className:previewClass},preview); this.insertNode(preview); } }, diff --git a/unpacked/extensions/jsMath2jax.js b/unpacked/extensions/jsMath2jax.js index 03b8ff3ee..188119711 100644 --- a/unpacked/extensions/jsMath2jax.js +++ b/unpacked/extensions/jsMath2jax.js @@ -73,10 +73,13 @@ MathJax.Extension.jsMath2jax = { }, createPreview: function (node) { + var previewClass = MathJax.Hub.config.preRemoveClass; var preview = this.config.preview; + if (preview === "none") return; + if ((node.previousSibling||{}).className === previewClass) return; if (preview === "TeX") {preview = [this.filterPreview(node.innerHTML)]} if (preview) { - preview = MathJax.HTML.Element("span",{className: MathJax.Hub.config.preRemoveClass},preview); + preview = MathJax.HTML.Element("span",{className:previewClass},preview); node.parentNode.insertBefore(preview,node); } }, diff --git a/unpacked/extensions/mml2jax.js b/unpacked/extensions/mml2jax.js index 6b3ce1531..995ba94c1 100644 --- a/unpacked/extensions/mml2jax.js +++ b/unpacked/extensions/mml2jax.js @@ -203,6 +203,8 @@ MathJax.Extension.mml2jax = { var preview = this.config.preview; if (preview === "none") return; var isNodePreview = false; + var previewClass = MathJax.Hub.config.preRemoveClass; + if ((script.previousSibling||{}).className === previewClass) return; if (preview === "mathml") { isNodePreview = true; // mathml preview does not work with IE < 9, so fallback to alttext. @@ -225,10 +227,10 @@ MathJax.Extension.mml2jax = { if (preview) { var span; if (isNodePreview) { - span = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass}); + span = MathJax.HTML.Element("span",{className:previewClass}); span.appendChild(preview); } else { - span = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass},preview); + span = MathJax.HTML.Element("span",{className:previewClass},preview); } script.parentNode.insertBefore(span,script); } diff --git a/unpacked/extensions/tex2jax.js b/unpacked/extensions/tex2jax.js index 26238818b..393dd96ca 100644 --- a/unpacked/extensions/tex2jax.js +++ b/unpacked/extensions/tex2jax.js @@ -277,11 +277,13 @@ MathJax.Extension.tex2jax = { }, createPreview: function (mode,tex) { + var previewClass = MathJax.Hub.config.preRemoveClass; var preview = this.config.preview; if (preview === "none") return; + if ((this.search.close.previousSibling||{}).className === previewClass) return; if (preview === "TeX") {preview = [this.filterPreview(tex)]} if (preview) { - preview = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass},preview); + preview = MathJax.HTML.Element("span",{className:previewClass},preview); this.insertNode(preview); } }, diff --git a/unpacked/jax/input/MathML/jax.js b/unpacked/jax/input/MathML/jax.js index 58772053b..89f6c071b 100644 --- a/unpacked/jax/input/MathML/jax.js +++ b/unpacked/jax/input/MathML/jax.js @@ -142,8 +142,14 @@ value = this.filterAttribute(name,value); var defaults = (mml.type === "mstyle" ? MML.math.prototype.defaults : mml.defaults); if (value != null) { - if (value.toLowerCase() === "true") {value = true} - else if (value.toLowerCase() === "false") {value = false} + var val = value.toLowerCase(); + if (val === "true" || val === "false") { + if (typeof (defaults[name]) === "boolean" || defaults[name] === MML.INHERIT || + (defaults[name] === MML.AUTO && + (mml.defaultDef == null || typeof(mml.defaultDef[name]) === "boolean"))) { + value = (val === "true"); + } + } if (defaults[name] != null || MML.copyAttributes[name]) {mml[name] = value} else {mml.attr[name] = value} mml.attrNames.push(name); diff --git a/unpacked/jax/input/TeX/jax.js b/unpacked/jax/input/TeX/jax.js index 26c46275e..76f210a34 100644 --- a/unpacked/jax/input/TeX/jax.js +++ b/unpacked/jax/input/TeX/jax.js @@ -53,8 +53,10 @@ else if (top) { this.data.push(item); if (item.env) { - for (var id in this.env) - {if (this.env.hasOwnProperty(id)) {item.env[id] = this.env[id]}} + if (item.copyEnv !== false) { + for (var id in this.env) + {if (this.env.hasOwnProperty(id)) {item.env[id] = this.env[id]}} + } this.env = item.env; } else {item.env = this.env} } @@ -256,9 +258,9 @@ }); STACKITEM.array = STACKITEM.Subclass({ - type: "array", isOpen: true, arraydef: {}, + type: "array", isOpen: true, copyEnv: false, arraydef: {}, Init: function () { - this.table = []; this.row = []; this.env = {}; this.frame = []; this.hfill = []; + this.table = []; this.row = []; this.frame = []; this.hfill = []; this.SUPER(arguments).Init.apply(this,arguments); }, checkItem: function (item) { @@ -1335,9 +1337,11 @@ Middle: function (name) { var delim = this.GetDelimiter(name); + this.Push(MML.TeXAtom().With({texClass:MML.TEXCLASS.CLOSE})); if (this.stack.Top().type !== "left") {TEX.Error(["MisplacedMiddle","%1 must be within \\left and \\right",name])} this.Push(MML.mo(delim).With({stretchy:true})); + this.Push(MML.TeXAtom().With({texClass:MML.TEXCLASS.OPEN})); }, NamedFn: function (name,id) { @@ -1433,6 +1437,8 @@ var def = {accent: true}; if (this.stack.env.font) {def.mathvariant = this.stack.env.font} var mml = this.mmlToken(MML.mo(MML.entity("#x"+accent)).With(def)); mml.stretchy = (stretchy ? true : false); + var mo = (c.isEmbellished() ? c.CoreMO() : c); + if (mo.isa(MML.mo)) mo.movablelimits = false; this.Push(MML.TeXAtom(MML.munderover(c,null,mml).With({accent: true}))); }, @@ -2211,9 +2217,9 @@ fenced: function (open,mml,close) { var mrow = MML.mrow().With({open:open, close:close, texClass:MML.TEXCLASS.INNER}); mrow.Append( - MML.mo(open).With({fence:true, stretchy:true, texClass:MML.TEXCLASS.OPEN}), + MML.mo(open).With({fence:true, stretchy:true, symmetric:true, texClass:MML.TEXCLASS.OPEN}), mml, - MML.mo(close).With({fence:true, stretchy:true, texClass:MML.TEXCLASS.CLOSE}) + MML.mo(close).With({fence:true, stretchy:true, symmetric:true, texClass:MML.TEXCLASS.CLOSE}) ); return mrow; }, diff --git a/unpacked/jax/output/CommonHTML/autoload/mglyph.js b/unpacked/jax/output/CommonHTML/autoload/mglyph.js index 538616b30..f273ccb59 100644 --- a/unpacked/jax/output/CommonHTML/autoload/mglyph.js +++ b/unpacked/jax/output/CommonHTML/autoload/mglyph.js @@ -60,15 +60,15 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () { var img = CHTML.addElement(node,"img",{ isMathJax:true, src:values.src, alt:values.alt, title:values.alt }); - var w = bbox.img.img.width/CHTML.em, h = bbox.img.img.height/CHTML.em; - if (values.width !== "") img.style.width = CHTML.Em(this.CHTMLlength2em(values.width,w)); - if (values.height !== "") img.style.height = CHTML.Em(this.CHTMLlength2em(values.height,h)); - // - // Warning: causes page reflows - // - bbox.w = bbox.r = img.offsetWidth/CHTML.em; bbox.h = bbox.t = img.offsetHeight/CHTML.em; + var w = values.width, h = values.height; + var W = bbox.img.img.width/CHTML.em, H = bbox.img.img.height/CHTML.em; + var WW = W, HH = H; + if (w !== "") {W = this.CHTMLlength2em(w,WW); H = (WW ? W/WW * HH : 0)} + if (h !== "") {H = this.CHTMLlength2em(h,HH); if (w === "") W = (HH ? H/HH * WW : 0)} + img.style.width = CHTML.Em(W); bbox.w = bbox.r = W; + img.style.height = CHTML.Em(H); bbox.h = bbox.t = H; if (values.valign) { - bbox.d = bbox.b = -this.CHTMLlength2em(values.valign,h); + bbox.d = bbox.b = -this.CHTMLlength2em(values.valign,HH); img.style.verticalAlign = CHTML.Em(-bbox.d); bbox.h -= bbox.d; bbox.t = bbox.h; } diff --git a/unpacked/jax/output/CommonHTML/autoload/mmultiscripts.js b/unpacked/jax/output/CommonHTML/autoload/mmultiscripts.js index 0a6f57f55..32f7d1cc9 100644 --- a/unpacked/jax/output/CommonHTML/autoload/mmultiscripts.js +++ b/unpacked/jax/output/CommonHTML/autoload/mmultiscripts.js @@ -154,8 +154,8 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () { state.i++; state.w = 0; sub = "presub"; sup = "presup"; } else { - var sbox = this.CHTMLaddScript(sub,state); - var Sbox = this.CHTMLaddScript(sup,state); + var sbox = this.CHTMLaddScript(sub,state,node); + var Sbox = this.CHTMLaddScript(sup,state,node); var w = Math.max((sbox ? sbox.rscale*sbox.w : 0),(Sbox ? Sbox.rscale*Sbox.w : 0)); this.CHTMLpadScript(sub,w,sbox,state); this.CHTMLpadScript(sup,w,Sbox,state); @@ -172,12 +172,17 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () { // and padding the box to account for any elements. // Return the bounding box for the script for later use. // - CHTMLaddScript: function (type,state) { + CHTMLaddScript: function (type,state,node) { var BOX, BBOX, data = this.data[state.i]; if (data && data.type !== "none" && data.type !== "mprescripts") { BOX = state.BOX[type]; if (!BOX) { - BOX = state.BOX[type] = CHTML.Element("mjx-"+type); + // + // Add the box to the node temporarily so that it is in the DOM + // (so that CHTMLnodeElement() can be used in the toCommonHTML() below). + // See issue #1480. + // + BOX = state.BOX[type] = CHTML.addElement(node,"mjx-"+type); BBOX = state.BBOX[type] = CHTML.BBOX.empty(); if (state.w) { BOX.style.paddingLeft = CHTML.Em(state.w); diff --git a/unpacked/jax/output/CommonHTML/autoload/mtable.js b/unpacked/jax/output/CommonHTML/autoload/mtable.js index c49e67cea..0012b2788 100644 --- a/unpacked/jax/output/CommonHTML/autoload/mtable.js +++ b/unpacked/jax/output/CommonHTML/autoload/mtable.js @@ -187,8 +187,6 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () { CALIGN = state.CALIGN, RALIGN = state.RALIGN, RCALIGN = state.RCALIGN; CSPACE[state.J] *= 2; RSPACE[ROWS.length-1] *= 2; // since halved below - var LH = CHTML.FONTDATA.lineH * values.useHeight, - LD = CHTML.FONTDATA.lineD * values.useHeight; var T = "0", B, R, L, border, cbox, align; if (values.fspace) T = CHTML.Em(state.FSPACE[1]); for (var i = 0, m = ROWS.length; i < m; i++) { @@ -197,7 +195,7 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () { // Space and borders between rows // B = RSPACE[i]/2; border = null; L = "0"; - if (RLINES[i] !== MML.LINES.NONE) { + if (RLINES[i] !== MML.LINES.NONE && RLINES[i] !== "") { border = state.t+" "+RLINES[i]; B -= 1/CHTML.em/2; } @@ -245,11 +243,12 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () { ); } // - // Pad cells that are too short + // Adjust height and depth of cells // cell = row[j].firstChild.style; - if (cbox.h < LH) cell.marginTop = CHTML.Em(LH-cbox.h); - if (cbox.d < LD) cell.marginBottom = CHTML.Em(LD-cbox.d); + var H = Math.max(1,cbox.h); + if (H !== state.H[i]) cell.marginTop = CHTML.Em(state.H[i]-H); + if (cbox.d < state.D[i]) cell.marginBottom = CHTML.Em(state.D[i]-cbox.d); } T = B; } @@ -494,7 +493,7 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () { if (LABELS[i] && this.data[i].data[0]) { labels.appendChild(LABELS[i]); var lbox = this.data[i].data[0].CHTML; - T += h - lbox.h; + T += h - Math.max(1,lbox.h); if (T) LABELS[i].style.marginTop = CHTML.Em(T); T = d - lbox.d; } else { @@ -563,6 +562,7 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () { MML.mtd.Augment({ toCommonHTML: function (node,options) { node = this.CHTMLdefaultNode(node,options); + CHTML.addElement(node.firstChild,"mjx-strut"); // forces height to 1em (we adjust later) // // Determine if this is stretchy or not // diff --git a/unpacked/jax/output/CommonHTML/jax.js b/unpacked/jax/output/CommonHTML/jax.js index beb7380a8..c8cedc0f7 100644 --- a/unpacked/jax/output/CommonHTML/jax.js +++ b/unpacked/jax/output/CommonHTML/jax.js @@ -71,13 +71,23 @@ ".mjx-chtml[tabindex]:focus, body :focus .mjx-chtml[tabindex]": { display: "inline-table" // see issues #1282 and #1338 }, + ".mjx-full-width": { + display: "table-cell", + width: "10000em" + }, ".mjx-math": { "display": "inline-block", "border-collapse": "separate", "border-spacing": 0, }, - ".mjx-math *": {display:"inline-block", "text-align":"left"}, + ".mjx-math *": { + display:"inline-block", + "-webkit-box-sizing": "content-box!important", + "-moz-box-sizing": "content-box!important", + "box-sizing": "content-box!important", // override bootstrap settings + "text-align":"left" + }, ".mjx-numerator": {display:"block", "text-align":"center"}, ".mjx-denominator": {display:"block", "text-align":"center"}, @@ -170,6 +180,12 @@ position: "absolute", width:"1px", height:"60ex" }, + ".mjx-line-box-test": { + display: "table-cell!important", + width: "10000em!important", + "min-width":0, "max-width":"none", + padding:0, border:0, margin:0 + }, "#MathJax_CHTML_Tooltip": { "background-color": "InfoBackground", color: "InfoText", @@ -232,6 +248,11 @@ // this.TestSpan = CHTML.Element("mjx-test",{style:{left:"1em"}},[["mjx-ex-box-test"]]); + // + // Used in preTranslate to get linebreak width + // + this.linebreakSpan = HTML.Element("span",{className:"mjx-line-box-test"}); + // // Set up styles and preload web fonts // @@ -260,9 +281,11 @@ // Get the default sizes (need styles in place to do this) // document.body.appendChild(this.TestSpan); + document.body.appendChild(this.linebreakSpan); this.defaultEm = this.getFontSize(this.TestSpan); this.defaultEx = this.TestSpan.firstChild.offsetHeight/60; - this.defaultWidth = this.TestSpan.offsetWidth; + this.defaultWidth = this.linebreakSpan.offsetWidth; + document.body.removeChild(this.linebreakSpan); document.body.removeChild(this.TestSpan); }, getFontSize: (window.getComputedStyle ? @@ -336,34 +359,29 @@ ucMatch: HTML.ucMatch, setScript: HTML.setScript, - getNodesByClass: (document.getElementsByClassName ? - function (node,type) {return node.getElementsByClassName(type)} : - function (node,type) { - var NODES = []; - 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)) NODES.push = nodes[i]; - } - return NODES; - } - ), + // + // Look through the direct children of a node for one with the given + // type (but if the node has intervening containers for its children, + // step into them; note that elements corresponding to MathML nodes + // will have id's so we don't step into them). + // + // This is used by munderover and msubsup to locate their child elements + // when they are part of an embellished operator that is being stretched. + // We don't use querySelector because we want to find only the direct child + // nodes, not nodes that might be nested deeper in the tree (see issue #1447). + // getNode: function (node,type) { - var nodes = this.getNodesByClass(node,type); - if (nodes.length === 1) return nodes[0]; - var closest = nodes[0], N = this.getNodeDepth(node,closest); - for (var i = 1, m = nodes.length; i < m; i++) { - var n = this.getNodeDepth(node,nodes[i]); - if (n < N) {closest = nodes[i]; N = n} + while (node && node.childNodes.length === 1 && node.firstChild.id == null) + node = node.firstChild; + if (node) { + var name = RegExp("\\b"+type+"\\b"); + for (var i = 0, m = node.childNodes.length; i < m; i++) { + var child = node.childNodes[i]; + if (name.test(child.className)) return child; + } } - return closest; + return null; }, - getNodeDepth: function (parent,node) { - var n = 0; - while (node && node !== parent) {node = node.parentNode; n++} - return n; - }, - /********************************************/ @@ -422,6 +440,7 @@ // // Add test nodes for determineing scales and linebreak widths // + script.parentNode.insertBefore(this.linebreakSpan.cloneNode(true),script); script.parentNode.insertBefore(this.TestSpan.cloneNode(true),script); } // @@ -434,12 +453,10 @@ jax = script.MathJax.elementJax; if (!jax) continue; em = CHTML.getFontSize(test); ex = test.firstChild.offsetHeight/60; - if (ex === 0 || ex === "NaN") ex = this.defaultEx - node = test; - while (node) { - cwidth = node.offsetWidth; if (cwidth) break; - cwidth = CHTML.getMaxWidth(node); if (cwidth) break; - node = node.parentNode; + cwidth = Math.max(0,test.previousSibling.offsetWidth-2); + if (ex === 0 || ex === "NaN") { + ex = this.defaultEx; + cwidth = this.defaultWidth; } if (relwidth) maxwidth = cwidth; scale = (this.config.matchFontHeight ? ex/this.TEX.x_height/em : 1); @@ -455,7 +472,9 @@ for (i = 0; i < m; i++) { script = scripts[i]; if (!script.parentNode) continue; test = scripts[i].previousSibling; + span = test.previousSibling; jax = scripts[i].MathJax.elementJax; if (!jax) continue; + span.parentNode.removeChild(span); test.parentNode.removeChild(test); } state.CHTMLeqn = state.CHTMLlast = 0; state.CHTMLi = -1; @@ -1307,6 +1326,7 @@ updateFrom: function (cbox) { this.h = cbox.h; this.d = cbox.d; this.w = cbox.w; this.r = cbox.r; this.l = cbox.l; this.t = cbox.t; this.b = cbox.b; + if (cbox.pwidth) this.pwidth = cbox.pwidth; if (cbox.D) this.D = cbox.D; else delete this.D; }, adjust: function (m,x,X,M) { @@ -1324,7 +1344,8 @@ empty: function (bbox) { if (!bbox) bbox = CHTML.BBOX.zero(); bbox.h = bbox.d = bbox.r = bbox.t = bbox.b = -BIGDIMEN; - bbox.w = 0; bbox.l = BIGDIMEN; + bbox.w = 0; bbox.l = BIGDIMEN; + delete bbox.pwidth; return bbox; }, // @@ -1723,8 +1744,8 @@ var alttext = this.Get("alttext"); if (alttext && !node.getAttribute("aria-label")) node.setAttribute("aria-label",alttext); if (this.CHTML.pwidth) { - node.parentNode.style.width = this.CHTML.pwidth; node.parentNode.style.minWidth = this.CHTML.mwidth||CHTML.Em(this.CHTML.w); + node.parentNode.className += " mjx-full-width"; } else if (!this.isMultiline && this.Get("display") === "block") { var values = this.getValues("indentalignfirst","indentshiftfirst","indentalign","indentshift"); if (values.indentalignfirst !== MML.INDENTALIGN.INDENTALIGN) values.indentalign = values.indentalignfirst; @@ -2659,6 +2680,7 @@ if (this.data[0]) { this.data[0].toCommonHTML(node); this.CHTML.updateFrom(this.data[0].CHTML); + this.CHTMLhandleBBox(node); } return node; } diff --git a/unpacked/jax/output/HTML-CSS/autoload/mtable.js b/unpacked/jax/output/HTML-CSS/autoload/mtable.js index eccc7063b..81cb05212 100644 --- a/unpacked/jax/output/HTML-CSS/autoload/mtable.js +++ b/unpacked/jax/output/HTML-CSS/autoload/mtable.js @@ -401,11 +401,11 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () { y = Y; for (i = 0, m = A.length-1; i < m; i++) { dy = Math.max(0,D[i]+H[i+1]+RSPACE[i]); - if (RLINES[i] !== "none") { + if (RLINES[i] !== MML.LINES.NONE && RLINES[i] !== "") { line = HTMLCSS.createRule(stack,1.25/HTMLCSS.em,0,fW); HTMLCSS.addBox(stack,line); line.bbox = {h:1.25/HTMLCSS.em, d:0, w:fW, rw:fW, lw:0}; HTMLCSS.placeBox(line,0,y - D[i] - (dy-D[i]-H[i+1])/2,true); - if (RLINES[i] === "dashed") line.style.borderTopStyle = "dashed"; + if (RLINES[i] === MML.LINES.DASHED) line.style.borderTopStyle = "dashed"; if (hasRelativeWidth) line.style.width = "100%" } y -= dy; diff --git a/unpacked/jax/output/HTML-CSS/fonts/STIX-Web/fontdata.js b/unpacked/jax/output/HTML-CSS/fonts/STIX-Web/fontdata.js index 6514528be..461cd2f44 100644 --- a/unpacked/jax/output/HTML-CSS/fonts/STIX-Web/fontdata.js +++ b/unpacked/jax/output/HTML-CSS/fonts/STIX-Web/fontdata.js @@ -246,6 +246,7 @@ REMAPACCENT: { "\u007E": "\u0303", "\u2192": "\u20D7", + "\u2190": "\u20D6", "\u0060": "\u0300", "\u005E": "\u0302", "\u00B4": "\u0301", diff --git a/unpacked/jax/output/HTML-CSS/fonts/STIX/fontdata.js b/unpacked/jax/output/HTML-CSS/fonts/STIX/fontdata.js index 42c76c757..920de949a 100644 --- a/unpacked/jax/output/HTML-CSS/fonts/STIX/fontdata.js +++ b/unpacked/jax/output/HTML-CSS/fonts/STIX/fontdata.js @@ -140,6 +140,7 @@ REMAPACCENT: { "\u007E": "\u0303", "\u2192": "\u20D7", + "\u2190": "\u20D6", "\u0060": "\u0300", "\u005E": "\u0302", "\u00B4": "\u0301", diff --git a/unpacked/jax/output/HTML-CSS/jax.js b/unpacked/jax/output/HTML-CSS/jax.js index 0407b35ab..8dad7d6aa 100644 --- a/unpacked/jax/output/HTML-CSS/jax.js +++ b/unpacked/jax/output/HTML-CSS/jax.js @@ -241,6 +241,8 @@ var EVENT, TOUCH, HOVER; // filled in later + var oldIE = MathJax.Hub.Browser.isMSIE && (document.documentMode||0) < 8; + HTMLCSS.Augment({ config: { styles: { @@ -278,6 +280,11 @@ "min-width": 0, "min-height": 0, width: "100%" }, + + ".MathJax.MathJax_FullWidth": { + display: (oldIE ? "block" : "table-cell") + "!important", + width: (oldIE ? "100%" : "10000em") + "!important" + }, ".MathJax img, .MathJax nobr, .MathJax a": { border: 0, padding: 0, margin: 0, @@ -331,6 +338,12 @@ width:"1px", height:"60em", "min-height": 0, "max-height":"none" }, + ".MathJax_LineBox": { + display: (oldIE ? "block" : "table-cell") + "!important", + width: (oldIE ? "100%" : "10000em") + "!important", + "min-width":0, "max-width":"none", + padding:0, border:0, margin:0 + }, ".MathJax .MathJax_HitBox": { cursor: "text", @@ -340,7 +353,7 @@ ".MathJax .MathJax_HitBox *": { filter: "none", opacity:1, background:"transparent" // for IE }, - + "#MathJax_Tooltip": { position: "absolute", left: 0, top: 0, width: "auto", height: "auto", @@ -482,8 +495,7 @@ ); // Used in preTranslate to get linebreak width - this.linebreakSpan = this.Element("span",null, - [["hr",{style: {width:"100%", size:1, padding:0, border:0, margin:0}}]]); + this.linebreakSpan = MathJax.HTML.Element("span",{className:"MathJax_LineBox"}); // Set up styles and preload web fonts return AJAX.Styles(this.config.styles,["InitializeHTML",this]); @@ -539,7 +551,7 @@ document.body.appendChild(this.linebreakSpan); this.defaultEx = this.EmExSpan.firstChild.offsetHeight/60; this.defaultEm = this.EmExSpan.lastChild.firstChild.offsetHeight/60; - this.defaultWidth = this.linebreakSpan.firstChild.offsetWidth; + this.defaultWidth = this.linebreakSpan.offsetWidth; document.body.removeChild(this.linebreakSpan); document.body.removeChild(this.EmExSpan); }, @@ -609,7 +621,7 @@ jax = script.MathJax.elementJax; if (!jax) continue; ex = test.firstChild.offsetHeight/60; em = test.lastChild.firstChild.offsetHeight/60; - cwidth = div.previousSibling.firstChild.offsetWidth; + cwidth = Math.max(0,div.previousSibling.offsetWidth - 2); if (relwidth) {maxwidth = cwidth} if (ex === 0 || ex === "NaN") { // can't read width, so move to hidden div for processing @@ -2951,7 +2963,8 @@ if (math && math.bbox.width != null) { span.style.minWidth = (math.bbox.minWidth || span.style.width); span.style.width = math.bbox.width; - box.style.width = stack.style.width = SPAN.style.width = "100%"; + box.style.width = stack.style.width = "100%"; + SPAN.className += " MathJax_FullWidth"; } // // Add color (if any) diff --git a/unpacked/jax/output/SVG/autoload/mglyph.js b/unpacked/jax/output/SVG/autoload/mglyph.js index 0c332ca65..ab3a3bba8 100644 --- a/unpacked/jax/output/SVG/autoload/mglyph.js +++ b/unpacked/jax/output/SVG/autoload/mglyph.js @@ -82,7 +82,7 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () { } else { var mu = this.SVGgetMu(svg); svg.Add(BBOX.MGLYPH(this.img.img,values.width,values.height,values.valign,mu, - {src:values.src, alt:values.alt, title:values.alt})); + {alt:values.alt, title:values.alt})); } } svg.Clean(); diff --git a/unpacked/jax/output/SVG/autoload/mtable.js b/unpacked/jax/output/SVG/autoload/mtable.js index ee3a18159..669f10792 100644 --- a/unpacked/jax/output/SVG/autoload/mtable.js +++ b/unpacked/jax/output/SVG/autoload/mtable.js @@ -308,7 +308,7 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () { y = Y - lw/2; for (i = 0, m = A.length-1; i < m; i++) { dy = Math.max(0,D[i]+H[i+1]+RSPACE[i]); - if (RLINES[i] !== "none") + if (RLINES[i] !== MML.LINES.NONE && RLINES[i] !== "") {svg.Add(BBOX.HLINE(fW,lw,RLINES[i]),0,y-D[i]-(dy-D[i]-H[i+1])/2)} y -= dy; } diff --git a/unpacked/jax/output/SVG/fonts/STIX-Web/fontdata.js b/unpacked/jax/output/SVG/fonts/STIX-Web/fontdata.js index f45dfaee6..a2a26eb45 100644 --- a/unpacked/jax/output/SVG/fonts/STIX-Web/fontdata.js +++ b/unpacked/jax/output/SVG/fonts/STIX-Web/fontdata.js @@ -243,6 +243,7 @@ REMAPACCENT: { "\u007E": "\u0303", "\u2192": "\u20D7", + "\u2190": "\u20D6", "\u0060": "\u0300", "\u005E": "\u0302", "\u00B4": "\u0301", diff --git a/unpacked/jax/output/SVG/jax.js b/unpacked/jax/output/SVG/jax.js index db854e125..d6b7f4274 100644 --- a/unpacked/jax/output/SVG/jax.js +++ b/unpacked/jax/output/SVG/jax.js @@ -100,6 +100,12 @@ "min-height": 0, "max-height":"none", padding:0, border: 0, margin: 0 }, + ".MathJax_SVG_LineBox": { + display: "table-cell!important", + width: "10000em!important", + "min-width":0, "max-width":"none", + padding:0, border:0, margin:0 + }, "#MathJax_SVG_Tooltip": { position: "absolute", left: 0, top: 0, @@ -173,8 +179,7 @@ ); // Used in preTranslate to get linebreak width - this.linebreakSpan = HTML.Element("span",null, - [["hr",{style: {width:"auto", size:1, padding:0, border:0, margin:0}}]]); + this.linebreakSpan = HTML.Element("span",{className:"MathJax_SVG_LineBox"}); // Set up styles return AJAX.Styles(this.config.styles,["InitializeSVG",this]); @@ -190,7 +195,7 @@ document.body.appendChild(this.ExSpan); document.body.appendChild(this.linebreakSpan); this.defaultEx = this.ExSpan.firstChild.offsetHeight/60; - this.defaultWidth = this.linebreakSpan.firstChild.offsetWidth; + this.defaultWidth = this.linebreakSpan.offsetWidth; document.body.removeChild(this.linebreakSpan); document.body.removeChild(this.ExSpan); }, @@ -256,16 +261,15 @@ test = script.previousSibling; div = test.previousSibling; jax = script.MathJax.elementJax; if (!jax) continue; ex = test.firstChild.offsetHeight/60; - cwidth = div.previousSibling.firstChild.offsetWidth / this.config.scale * 100; - if (relwidth) {maxwidth = cwidth} + cwidth = Math.max(0,(div.previousSibling.offsetWidth-2) / this.config.scale * 100); if (ex === 0 || ex === "NaN") { // can't read width, so move to hidden div for processing // (this will cause a reflow for each math element that is hidden) this.hiddenDiv.appendChild(div); jax.SVG.isHidden = true; ex = this.defaultEx; cwidth = this.defaultWidth; - if (relwidth) {maxwidth = cwidth} } + if (relwidth) {maxwidth = cwidth} jax.SVG.ex = ex; jax.SVG.em = em = ex / SVG.TeX.x_height * 1000; // scale ex to x_height jax.SVG.cwidth = cwidth/em * 1000; @@ -2089,13 +2093,14 @@ var style = svg.element.style, px = SVG.TeX.x_height/SVG.ex; var H = (Math.ceil(svg.H/px)+1)*px+SVG.HFUZZ, // round to pixels and add padding D = (Math.ceil(svg.D/px)+1)*px+SVG.DFUZZ; - svg.element.setAttribute("width",SVG.Ex(l+svg.w+r)); + var w = l + svg.w + r; + svg.element.setAttribute("width",SVG.Ex(w)); svg.element.setAttribute("height",SVG.Ex(H+D)); style.verticalAlign = SVG.Ex(-D); if (l) style.marginLeft = SVG.Ex(-l); if (r) style.marginRight = SVG.Ex(-r); svg.element.setAttribute("viewBox",SVG.Fixed(-l,1)+" "+SVG.Fixed(-H,1)+" "+ - SVG.Fixed(l+svg.w+r,1)+" "+SVG.Fixed(H+D,1)); + SVG.Fixed(w,1)+" "+SVG.Fixed(H+D,1)); // // If there is extra height or depth, hide that // @@ -2105,6 +2110,12 @@ style.verticalAlign = SVG.Ex(-svg.d); } // + // The approximate ex can cause full-width equations to be too wide, + // so if they are close to full width, make sure they aren't too big. + // + if (Math.abs(w-SVG.cwidth) < 10) + style.maxWidth = SVG.Fixed(SVG.cwidth*SVG.em/1000); + // // Add it to the MathJax span // var alttext = this.Get("alttext"); @@ -2131,7 +2142,7 @@ if (shift) { HUB.Insert(style,({ left: {marginLeft: SVG.Ex(shift)}, - right: {marginRight: SVG.Ex(-shift), marginLeft: SVG.Ex(Math.max(0,shift-(l+svg.w+r)))}, + right: {marginRight: SVG.Ex(-shift), marginLeft: SVG.Ex(Math.max(0,shift-w))}, center: {marginLeft: SVG.Ex(shift), marginRight: SVG.Ex(-shift)} })[values.indentalign]); }