From 7116cde3282d8b17aea56fd787f1c0d6be7e9b43 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Fri, 29 Apr 2016 19:02:15 -0400 Subject: [PATCH 01/29] Improve getNode() so that it doesn't find elements inside nodes that come from other MathML nodes (those with IDs). Resolves issue #1447. --- unpacked/jax/output/CommonHTML/jax.js | 36 ++++++++------------------- 1 file changed, 11 insertions(+), 25 deletions(-) diff --git a/unpacked/jax/output/CommonHTML/jax.js b/unpacked/jax/output/CommonHTML/jax.js index bed4fe2bb..483e44005 100644 --- a/unpacked/jax/output/CommonHTML/jax.js +++ b/unpacked/jax/output/CommonHTML/jax.js @@ -336,34 +336,20 @@ 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 children of a node for one with the given type + // but don't step into child nodes that are from MathML elements + // themselves (they will have IDs). + // 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} + 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; + if (child.id == null) return this.getNode(child,type); } - return closest; }, - getNodeDepth: function (parent,node) { - var n = 0; - while (node && node !== parent) {node = node.parentNode; n++} - return n; - }, - + /********************************************/ From e1d430d1b3798a8be25089c836001c507d89dd73 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 17 May 2016 12:31:47 -0400 Subject: [PATCH 02/29] Make getNode() non-recursive and add comments for what it does. Issue #1447. --- unpacked/jax/output/CommonHTML/jax.js | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/unpacked/jax/output/CommonHTML/jax.js b/unpacked/jax/output/CommonHTML/jax.js index 483e44005..91c507bfe 100644 --- a/unpacked/jax/output/CommonHTML/jax.js +++ b/unpacked/jax/output/CommonHTML/jax.js @@ -337,20 +337,29 @@ setScript: HTML.setScript, // - // Look through the children of a node for one with the given type - // but don't step into child nodes that are from MathML elements - // themselves (they will have IDs). + // 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 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; - if (child.id == null) return this.getNode(child,type); + 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 null; }, - /********************************************/ preTranslate: function (state) { From 67bca32380e0ae64e953317eb35c4b00ad50004a Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 17 May 2016 15:52:50 -0400 Subject: [PATCH 03/29] Properly determine container width for shrink-wrapped elements, and try to handle the problem with full-width equations being too wide when the ex-size isn't measured accurately enough. Issue #1478. --- unpacked/jax/output/SVG/jax.js | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/unpacked/jax/output/SVG/jax.js b/unpacked/jax/output/SVG/jax.js index d8edf98c4..9aac0baed 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]); } From 22c1cf4cb9d799da56a830c0f91a6076e049bdcf Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 17 May 2016 15:54:33 -0400 Subject: [PATCH 04/29] Properly determine container width for shrink-wrapped elements in HTML-CSS, and add the CSS from handle-floats into the standard HTML-CSS. Remove the content of the handle-floats extension. Issue #1478. --- unpacked/extensions/HTML-CSS/handle-floats.js | 39 ++----------------- unpacked/jax/output/HTML-CSS/jax.js | 25 +++++++++--- 2 files changed, 22 insertions(+), 42 deletions(-) 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/jax/output/HTML-CSS/jax.js b/unpacked/jax/output/HTML-CSS/jax.js index ec9ac237f..0e8692c7a 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: "table-cell!important", + width: "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 ? "inline-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) From 97ab12ea52403990ba9dbb105fa7f43b84f67d7c Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 17 May 2016 15:55:07 -0400 Subject: [PATCH 05/29] Properly determine container width for shrink-wrapped elements in CommonHTML. Issue #1478. --- unpacked/jax/output/CommonHTML/jax.js | 34 ++++++++++++++++++++------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/unpacked/jax/output/CommonHTML/jax.js b/unpacked/jax/output/CommonHTML/jax.js index beb7380a8..b0fd4eacd 100644 --- a/unpacked/jax/output/CommonHTML/jax.js +++ b/unpacked/jax/output/CommonHTML/jax.js @@ -71,6 +71,10 @@ ".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", @@ -170,6 +174,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 +242,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 +275,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 ? @@ -422,6 +439,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 +452,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 +471,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; @@ -1723,8 +1741,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; From 422065a0c1b7001a4d9249de2a4e12daac6ca247 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 17 May 2016 16:56:56 -0400 Subject: [PATCH 06/29] Fix CSS for IE < 8. --- unpacked/jax/output/HTML-CSS/jax.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/unpacked/jax/output/HTML-CSS/jax.js b/unpacked/jax/output/HTML-CSS/jax.js index 0e8692c7a..366d75bdb 100644 --- a/unpacked/jax/output/HTML-CSS/jax.js +++ b/unpacked/jax/output/HTML-CSS/jax.js @@ -282,8 +282,8 @@ }, ".MathJax.MathJax_FullWidth": { - display: "table-cell!important", - width: "10000em!important" + display: (oldIE ? "block" : "table-cell") + "!important", + width: (oldIE ? "100%" : "10000em") + "!important" }, ".MathJax img, .MathJax nobr, .MathJax a": { @@ -339,7 +339,7 @@ "min-height": 0, "max-height":"none" }, ".MathJax_LineBox": { - display: (oldIE ? "inline-block" : "table-cell") + "!important", + display: (oldIE ? "block" : "table-cell") + "!important", width: (oldIE ? "100%" : "10000em") + "!important", "min-width":0, "max-width":"none", padding:0, border:0, margin:0 From ab7d436bb158b586bb32be9d0b47501df5a2f676 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 17 May 2016 19:07:17 -0400 Subject: [PATCH 07/29] Mark accented operators as not having movable limits. Resolves issue #1469. --- unpacked/jax/input/TeX/jax.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/unpacked/jax/input/TeX/jax.js b/unpacked/jax/input/TeX/jax.js index 8463c8be3..bfc69cd6f 100644 --- a/unpacked/jax/input/TeX/jax.js +++ b/unpacked/jax/input/TeX/jax.js @@ -1433,6 +1433,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}))); }, From 2f37edaadf7e47814ef68e3bcb5446fb8e903200 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Wed, 18 May 2016 12:30:53 -0400 Subject: [PATCH 08/29] Construct the script boxes in the DOM so that stretchy characters can use CHTMLnodeElement() to locate their associated DOM nodes properly. The boxes are moved into the correct places later. REsolves issue #1480. --- .../jax/output/CommonHTML/autoload/mmultiscripts.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/unpacked/jax/output/CommonHTML/autoload/mmultiscripts.js b/unpacked/jax/output/CommonHTML/autoload/mmultiscripts.js index 0a6f57f55..e60755e00 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 + // (to 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); From c9fc3ae66b1d38ee19e121d6b751b782bc5fac9b Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Wed, 18 May 2016 12:37:23 -0400 Subject: [PATCH 09/29] Fix up comment. --- unpacked/jax/output/CommonHTML/autoload/mmultiscripts.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unpacked/jax/output/CommonHTML/autoload/mmultiscripts.js b/unpacked/jax/output/CommonHTML/autoload/mmultiscripts.js index e60755e00..32f7d1cc9 100644 --- a/unpacked/jax/output/CommonHTML/autoload/mmultiscripts.js +++ b/unpacked/jax/output/CommonHTML/autoload/mmultiscripts.js @@ -179,8 +179,8 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () { if (!BOX) { // // Add the box to the node temporarily so that it is in the DOM - // (to CHTMLnodeElement() can be used in the toCommonHTML() below) - // See issue #1480 + // (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(); From a118ca9e82b6ee5a98f99ec606f507edac1cd2d5 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Thu, 2 Jun 2016 16:33:15 -0400 Subject: [PATCH 10/29] Allow percentage width to bubble up un bbox.updateFrom(cbox). Resolves issue #1499. --- unpacked/jax/output/CommonHTML/jax.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/unpacked/jax/output/CommonHTML/jax.js b/unpacked/jax/output/CommonHTML/jax.js index beb7380a8..66f2775ec 100644 --- a/unpacked/jax/output/CommonHTML/jax.js +++ b/unpacked/jax/output/CommonHTML/jax.js @@ -1307,6 +1307,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 +1325,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; }, // @@ -2659,6 +2661,7 @@ if (this.data[0]) { this.data[0].toCommonHTML(node); this.CHTML.updateFrom(this.data[0].CHTML); + this.CHTMLhandleBBox(node); } return node; } From fef425431bf777670e25198a98018df6e195f702 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Mon, 6 Jun 2016 07:15:04 -0400 Subject: [PATCH 11/29] Handle adjusting cell heights properly. Add a 1em strut to work around issues with cells containing no text and cells that are shorter than the midpoint of the font. Resolves issue #1500. --- unpacked/jax/output/CommonHTML/autoload/mtable.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/unpacked/jax/output/CommonHTML/autoload/mtable.js b/unpacked/jax/output/CommonHTML/autoload/mtable.js index c49e67cea..e4569f1bb 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++) { @@ -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 // From acbb4441410dc6df6aaf8b61ec612f290854cec5 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 7 Jun 2016 06:46:13 -0400 Subject: [PATCH 12/29] Make rowlines='' and rowlines=' ' be rowlines='none'. Resolives issue #1004. --- unpacked/jax/output/CommonHTML/autoload/mtable.js | 2 +- unpacked/jax/output/HTML-CSS/autoload/mtable.js | 4 ++-- unpacked/jax/output/SVG/autoload/mtable.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/unpacked/jax/output/CommonHTML/autoload/mtable.js b/unpacked/jax/output/CommonHTML/autoload/mtable.js index c49e67cea..2e2b5bb36 100644 --- a/unpacked/jax/output/CommonHTML/autoload/mtable.js +++ b/unpacked/jax/output/CommonHTML/autoload/mtable.js @@ -197,7 +197,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; } 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/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; } From 02cfa458d8891dc88246b14ea5e01742bf4b41aa Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 7 Jun 2016 10:06:18 -0400 Subject: [PATCH 13/29] Don't add a 'src' attribute ( uses href, not src) --- unpacked/jax/output/SVG/autoload/mglyph.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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(); From 00864b06356044980a4e77831cb290aa3cd51146 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 7 Jun 2016 10:14:51 -0400 Subject: [PATCH 14/29] surround \middle with OPEN and CLOSE TeXAtoms, so that the spacing will be consistent with TeX's version (e.g., \mathrel{}\middle|\mathrel{} will produce the right spacing). As a side effect, this resolves the problem with the quotes, sot this resolves issue #1023. --- unpacked/jax/input/TeX/jax.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/unpacked/jax/input/TeX/jax.js b/unpacked/jax/input/TeX/jax.js index 8463c8be3..4b36326af 100644 --- a/unpacked/jax/input/TeX/jax.js +++ b/unpacked/jax/input/TeX/jax.js @@ -1335,9 +1335,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) { From cfeaa8668f06d243795c2a2de99da99ecf38ec84 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 7 Jun 2016 10:23:01 -0400 Subject: [PATCH 15/29] Mark delimters are symmetric when used with \left and \right. Resolves issue #1084. --- unpacked/jax/input/TeX/jax.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unpacked/jax/input/TeX/jax.js b/unpacked/jax/input/TeX/jax.js index 8463c8be3..90bcec558 100644 --- a/unpacked/jax/input/TeX/jax.js +++ b/unpacked/jax/input/TeX/jax.js @@ -2210,9 +2210,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})); + mrow.Append(MML.mo(open).With({fence:true, stretchy:true, symmetric:true, texClass:MML.TEXCLASS.OPEN})); if (mml.type === "mrow") {mrow.Append.apply(mrow,mml.data)} else {mrow.Append(mml)} - mrow.Append(MML.mo(close).With({fence:true, stretchy:true, texClass:MML.TEXCLASS.CLOSE})); + mrow.Append(MML.mo(close).With({fence:true, stretchy:true, symmetric:true, texClass:MML.TEXCLASS.CLOSE})); return mrow; }, /* From 5b6aa4f82add3313248d80710a7405d085489196 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 7 Jun 2016 10:45:59 -0400 Subject: [PATCH 16/29] Prevent CSS bleedthrough for box-sizing (set by Bootstrap CSS). Resolves issue #1393. --- unpacked/jax/output/CommonHTML/jax.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/unpacked/jax/output/CommonHTML/jax.js b/unpacked/jax/output/CommonHTML/jax.js index beb7380a8..4fead6f15 100644 --- a/unpacked/jax/output/CommonHTML/jax.js +++ b/unpacked/jax/output/CommonHTML/jax.js @@ -77,7 +77,13 @@ "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"}, From a6b7700c18ab064297c0c52f5d0eab03c4be4a9a Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 7 Jun 2016 11:25:26 -0400 Subject: [PATCH 17/29] Don't convert attribute to boolean unless the default is a boolean. Resolves issue #1356. --- unpacked/jax/input/MathML/jax.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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); From ae4f60f2dff606611ca6a2491cd4ceead043139a Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 7 Jun 2016 12:43:09 -0400 Subject: [PATCH 18/29] Make CHTML mglyph scale image size by hand rather than using offsetWidth and offsetHeight, since those cause reflow. This also makes it work in mathjax-node. Resolves mathjax/Mathjax-node#241. --- .../jax/output/CommonHTML/autoload/mglyph.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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; } From 11f617c51677136089727d266b3d2480f12eadbc Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 7 Jun 2016 15:50:49 -0400 Subject: [PATCH 19/29] Don't do assistive MathML when the output renderer is PlainSource. Resolves issue #1497. --- unpacked/extensions/AssistiveMML.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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) { From d4df0a8c9207bbf5079940f2756b8a86a6463bc0 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 7 Jun 2016 16:11:44 -0400 Subject: [PATCH 20/29] Add copyright notice. Re-indent. Update version number. Resolves issue #1391 --- unpacked/extensions/TeX/mediawiki-texvc.js | 221 ++++++++++++--------- 1 file changed, 122 insertions(+), 99 deletions(-) diff --git a/unpacked/extensions/TeX/mediawiki-texvc.js b/unpacked/extensions/TeX/mediawiki-texvc.js index e43351f2a..e9174c49f 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 Wikimedia 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"); From d11ef35af089a6f234275755fb218bdc1811be3b Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 7 Jun 2016 16:13:23 -0400 Subject: [PATCH 21/29] Fix mediawiki name in comment. #1391. --- unpacked/extensions/TeX/mediawiki-texvc.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unpacked/extensions/TeX/mediawiki-texvc.js b/unpacked/extensions/TeX/mediawiki-texvc.js index e9174c49f..e31fdec21 100644 --- a/unpacked/extensions/TeX/mediawiki-texvc.js +++ b/unpacked/extensions/TeX/mediawiki-texvc.js @@ -2,7 +2,7 @@ * * MathJax/extensions/TeX/mediawiki-texvc.js * - * Implements macros used by Wikimedia with their texvc preprocessor. + * Implements macros used by mediawiki with their texvc preprocessor. * * --------------------------------------------------------------------- * From 559102f017b3ef710ab2a5053a3ce66539032415 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Wed, 8 Jun 2016 06:40:20 -0400 Subject: [PATCH 22/29] Remove unneeded parentheses. #1478 --- unpacked/jax/output/SVG/jax.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unpacked/jax/output/SVG/jax.js b/unpacked/jax/output/SVG/jax.js index 9aac0baed..ef7a4732f 100644 --- a/unpacked/jax/output/SVG/jax.js +++ b/unpacked/jax/output/SVG/jax.js @@ -2142,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-(w)))}, + right: {marginRight: SVG.Ex(-shift), marginLeft: SVG.Ex(Math.max(0,shift-w))}, center: {marginLeft: SVG.Ex(shift), marginRight: SVG.Ex(-shift)} })[values.indentalign]); } From a1c40e7a02848a83b27b8d834c0ffa1a63a08ac2 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 14 Jun 2016 13:41:32 -0400 Subject: [PATCH 23/29] Make left arrow use combining left arrow for accents (consistent with right arrow). --- unpacked/jax/output/HTML-CSS/fonts/STIX-Web/fontdata.js | 1 + unpacked/jax/output/HTML-CSS/fonts/STIX/fontdata.js | 1 + 2 files changed, 2 insertions(+) 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", From 947d1556ea1280f0b11fbf1572ac6eb37440cae2 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 14 Jun 2016 13:50:38 -0400 Subject: [PATCH 24/29] Make left arrow use combining left arrow for accents (consistent with right arrow). --- unpacked/jax/output/SVG/fonts/STIX-Web/fontdata.js | 1 + 1 file changed, 1 insertion(+) 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", From 1b32cd95d9c3ec7c300267e27e3d45aa1e63ea51 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 14 Jun 2016 13:58:34 -0400 Subject: [PATCH 25/29] Add Contrib to the Ajax paths. Resolves issue #1519. --- unpacked/MathJax.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/unpacked/MathJax.js b/unpacked/MathJax.js index c5f456373..331f0900b 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.protocal).match(/^https?:/) ? "" : "http:") + + "//cdn.mathjax.org/mathjax/contrib"; // the third-party extensions BASE.Ajax = { loaded: {}, // files already loaded From fcda005c56e966c94fbc415c29bada05419103b3 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 14 Jun 2016 14:22:51 -0400 Subject: [PATCH 26/29] Don't copy environment into array environments. Resolves issue #1468. --- unpacked/jax/input/TeX/jax.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/unpacked/jax/input/TeX/jax.js b/unpacked/jax/input/TeX/jax.js index eeec47541..b16dafc8e 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} } @@ -258,7 +260,8 @@ STACKITEM.array = STACKITEM.Subclass({ type: "array", isOpen: true, arraydef: {}, Init: function () { - this.table = []; this.row = []; this.env = {}; this.frame = []; this.hfill = []; + this.table = []; this.row = []; this.frame = []; this.hfill = []; + this.copyEnv = false; this.SUPER(arguments).Init.apply(this,arguments); }, checkItem: function (item) { From dbc70acd58761ca1dc32944135789fc9199b17db Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 14 Jun 2016 14:59:49 -0400 Subject: [PATCH 27/29] Make copyEnv a shared constant. --- unpacked/jax/input/TeX/jax.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/unpacked/jax/input/TeX/jax.js b/unpacked/jax/input/TeX/jax.js index b16dafc8e..36e53592c 100644 --- a/unpacked/jax/input/TeX/jax.js +++ b/unpacked/jax/input/TeX/jax.js @@ -258,10 +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.frame = []; this.hfill = []; - this.copyEnv = false; this.SUPER(arguments).Init.apply(this,arguments); }, checkItem: function (item) { From 1e999e389ed3c5e61ad404c8379ac87b56b5ae30 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Tue, 14 Jun 2016 15:32:53 -0400 Subject: [PATCH 28/29] Don't have preprocessors make a preview if there already is one. Resolves issue #1445. --- unpacked/extensions/asciimath2jax.js | 4 +++- unpacked/extensions/jsMath2jax.js | 5 ++++- unpacked/extensions/mml2jax.js | 6 ++++-- unpacked/extensions/tex2jax.js | 4 +++- 4 files changed, 14 insertions(+), 5 deletions(-) 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); } }, From 30990c4ab81044a0deb43e9839cafce70f46f7c9 Mon Sep 17 00:00:00 2001 From: "Davide P. Cervone" Date: Wed, 15 Jun 2016 15:45:01 -0400 Subject: [PATCH 29/29] Fix spelling of 'protocol'. Issue #1519. --- unpacked/MathJax.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unpacked/MathJax.js b/unpacked/MathJax.js index 331f0900b..84a1a9fe4 100644 --- a/unpacked/MathJax.js +++ b/unpacked/MathJax.js @@ -659,7 +659,7 @@ MathJax.cdnFileVersions = {}; // can be used to specify revisions for individua var PATH = {}; PATH[BASENAME] = ""; // empty path gets the root URL - PATH.Contrib = (String(location.protocal).match(/^https?:/) ? "" : "http:") + + PATH.Contrib = (String(location.protocol).match(/^https?:/) ? "" : "http:") + "//cdn.mathjax.org/mathjax/contrib"; // the third-party extensions BASE.Ajax = {