diff --git a/unpacked/MathJax.js b/unpacked/MathJax.js index 75273002e..4480b59e7 100644 --- a/unpacked/MathJax.js +++ b/unpacked/MathJax.js @@ -1725,7 +1725,13 @@ MathJax.Hub = { } }} return dst; - } + }, + + // Old browsers (e.g. Internet Explorer <= 8) do not support trim(). + SplitList: ("trim" in String.prototype ? + function (list) {return list.trim().split(/\s+/)} : + function (list) {return list.replace(/^\s+/,''). + replace(/\s+$/,'').split(/\s+/)}) }; MathJax.Hub.Insert(MathJax.Hub.config.styles,MathJax.Message.styles); MathJax.Hub.Insert(MathJax.Hub.config.styles,{".MathJax_Error":MathJax.Hub.config.errorSettings.style}); diff --git a/unpacked/extensions/TeX/AMSmath.js b/unpacked/extensions/TeX/AMSmath.js index 4615be6de..407b01ab5 100644 --- a/unpacked/extensions/TeX/AMSmath.js +++ b/unpacked/extensions/TeX/AMSmath.js @@ -1,5 +1,6 @@ /* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */ /* vim: set ts=2 et sw=2 tw=80: */ + /************************************************************* * * MathJax/extensions/TeX/AMSmath.js @@ -24,7 +25,7 @@ */ MathJax.Extension["TeX/AMSmath"] = { - version: "2.1", + version: "2.1.1", number: 0, // current equation number startNumber: 0, // current starting equation number (for when equation is restarted) @@ -254,18 +255,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () { var den = this.ParseArg(name); var frac = MML.mfrac(num,den); if (thick !== "") {frac.linethickness = thick} - if (left || right) { - var mrow = MML.mrow(); - mrow.open = left; mrow.close = right; - if (left) { - mrow.Append(MML.mo(left).With({fence: "true"})); - } - mrow.Append(frac); - if (right) { - mrow.Append(MML.mo(right).With({fence: "true"})); - } - frac = mrow; - } + if (left || right) {frac = TEX.mfenced(left,frac,right)} if (style !== "") { var STYLE = (["D","T","S","SS"])[style]; if (STYLE == null) {TEX.Error("Bad math style for "+name)} diff --git a/unpacked/jax/input/MathML/config.js b/unpacked/jax/input/MathML/config.js index 77d7e0217..508cfdfb9 100644 --- a/unpacked/jax/input/MathML/config.js +++ b/unpacked/jax/input/MathML/config.js @@ -24,7 +24,7 @@ MathJax.InputJax.MathML = MathJax.InputJax({ id: "MathML", - version: "2.1", + version: "2.1.1", directory: MathJax.InputJax.directory + "/MathML", extensionDir: MathJax.InputJax.extensionDir + "/MathML", entityDir: MathJax.InputJax.directory + "/MathML/entities", diff --git a/unpacked/jax/input/MathML/jax.js b/unpacked/jax/input/MathML/jax.js index 144b17bab..07e60d015 100644 --- a/unpacked/jax/input/MathML/jax.js +++ b/unpacked/jax/input/MathML/jax.js @@ -1,5 +1,6 @@ /* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */ /* vim: set ts=2 et sw=2 tw=80: */ + /************************************************************* * * MathJax/jax/input/MathML/jax.js @@ -162,10 +163,10 @@ } if (mml.type === "mrow" && mml.data.length >= 2) { var first = mml.data[0], last = mml.data[mml.data.length-1]; - if (first.type === "mo" && first.fence && - last.type === "mo" && last.fence) { - if (first.data[0]) {mml.open = first.data[0].data[0]} - if (last.data[0]) {mml.close = last.data[0].data[0]} + if (first.type === "mo" && first.Get("fence") && + last.type === "mo" && last.Get("fence")) { + if (first.data[0]) {mml.open = first.data.join("")} + if (last.data[0]) {mml.close = last.data.join("")} } } }, diff --git a/unpacked/jax/input/TeX/config.js b/unpacked/jax/input/TeX/config.js index 4850a6a53..774511b8e 100644 --- a/unpacked/jax/input/TeX/config.js +++ b/unpacked/jax/input/TeX/config.js @@ -24,7 +24,7 @@ MathJax.InputJax.TeX = MathJax.InputJax({ id: "TeX", - version: "2.1", + version: "2.1.1", directory: MathJax.InputJax.directory + "/TeX", extensionDir: MathJax.InputJax.extensionDir + "/TeX", diff --git a/unpacked/jax/input/TeX/jax.js b/unpacked/jax/input/TeX/jax.js index b6cd72018..68b057b8a 100644 --- a/unpacked/jax/input/TeX/jax.js +++ b/unpacked/jax/input/TeX/jax.js @@ -1,5 +1,6 @@ /* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */ /* vim: set ts=2 et sw=2 tw=80: */ + /************************************************************* * * MathJax/jax/input/TeX/jax.js @@ -177,16 +178,7 @@ if (this.open || this.close) { mml.texClass = MML.TEXCLASS.INNER; mml.texWithDelims = true; - var mrow = MML.mrow(); - mrow.open = this.open; mrow.close = this.close; - if (this.open) { - mrow.Append(MML.mo(this.open).With({fence: "true"})); - } - mrow.Append(mml); - if (this.close) { - mrow.Append(MML.mo(this.close).With({fence: "true"})); - } - mml = mrow; + mml = TEX.mfenced(this.open,mml,this.close); } return [STACKITEM.mml(mml), item]; } @@ -199,20 +191,8 @@ type: "left", isOpen: true, delim: '(', stopError: "Extra \\left or missing \\right", checkItem: function (item) { - if (item.type === "right") { - var mml = MML.mrow(); - mml.open = this.delim; mml.close = item.delim; - if (this.delim) { - mml.Append(MML.mo(this.delim).With({fence: "true"})); - } - for (var i in this.data) { - mml.Append(this.data[i]); - } - if (item.delim) { - mml.Append(MML.mo(item.delim).With({fence: "true"})); - } - return STACKITEM.mml(mml); - } + if (item.type === "right") + {return STACKITEM.mml(TEX.mfenced(this.delim,this.mmlData(),item.delim))} return this.SUPER(arguments).checkItem.call(this,item); } }); @@ -287,18 +267,7 @@ if ((this.arraydef.columnlines||"none") != "none" || (this.arraydef.rowlines||"none") != "none") {mml.padding = 0} // HTML-CSS jax implements this } - if (this.open || this.close) { - var mrow = MML.mrow(); - mrow.open = this.open; mrow.close = this.close; - if (this.open) { - mrow.Append(MML.mo(this.open).With({fence: "true"})) - } - mrow.Append(mml); - if (this.close) { - mrow.Append(MML.mo(this.close).With({fence: "true"})) - } - mml = mrow; - } + if (this.open || this.close) {mml = TEX.mfenced(this.open,mml,this.close)} mml = STACKITEM.mml(mml); if (this.requireClose) { if (item.type === 'close') {return mml} @@ -1081,7 +1050,7 @@ return this.stack.Top().data[0]; }, mmlToken: function (token) {return token}, // used by boldsymbol extension - + /************************************************************************/ /* * Handle various token classes @@ -2081,6 +2050,18 @@ TEXDEF.macros[name].isUser = true; }, + /* + * Create an mrow that represents the equivalent of an mfenced + */ + mfenced: function (open,mml,close) { + var mrow = MML.mrow(); + mrow.open = open; mrow.close = close; + if (open) {mrow.Append(MML.mo(open).With({fence:true, texClass:MML.TEXCLASS.OPEN}))} + if (mml.type === "mrow") {mrow.Append.apply(mrow,mml.data)} else {mrow.Append(mml)} + if (close) {mrow.Append(MML.mo(close).With({fence:true, texClass:MML.TEXCLASS.CLOSE}))} + return mrow; + }, + // // Combine adjacent elements that are relations // (since MathML treats the spacing very differently) diff --git a/unpacked/jax/output/NativeMML/config.js b/unpacked/jax/output/NativeMML/config.js index fd7af3031..a7837badc 100644 --- a/unpacked/jax/output/NativeMML/config.js +++ b/unpacked/jax/output/NativeMML/config.js @@ -24,7 +24,7 @@ MathJax.OutputJax.NativeMML = MathJax.OutputJax({ id: "NativeMML", - version: "2.1.1", + version: "2.1.2", directory: MathJax.OutputJax.directory + "/NativeMML", extensionDir: MathJax.OutputJax.extensionDir + "/NativeMML", diff --git a/unpacked/jax/output/NativeMML/jax.js b/unpacked/jax/output/NativeMML/jax.js index 7ab203d65..0f4ec7a4f 100644 --- a/unpacked/jax/output/NativeMML/jax.js +++ b/unpacked/jax/output/NativeMML/jax.js @@ -1,5 +1,6 @@ /* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */ /* vim: set ts=2 et sw=2 tw=80: */ + /************************************************************* * * MathJax/jax/output/NativeMML/jax.js @@ -42,6 +43,7 @@ }; var CELLSPACING = function (obj,rowSpacing,columnSpacing) { + // // Webkit default padding on mtd cells is simply // // mtd {padding: 0.5ex;} @@ -63,15 +65,16 @@ // Here, we will set the left/top padding of each cell to // rowSpacing/columnSpacing (or 0px for the leftmost/topmost cells) and // reset the right/bottom padding to zero. + // if (obj) { var span = HTML.Element("span"); span.style.cssText = (obj.getAttribute("style")||""); if (span.style.padding === "") { var padding = { paddingLeft: columnSpacing, paddingTop: rowSpacing, paddingRight: "0px", paddingBottom: "0px" }; - for (var side in padding) { + for (var side in padding) {if (padding.hasOwnProperty(side)) { if ((span.style[side]||"") === "") {span.style[side] = padding[side];} - } + }} } obj.setAttribute("style",span.style.cssText); } @@ -317,8 +320,10 @@ postTranslate: function (state) { if (this.forceReflow) { + // // Firefox messes up some mtable's when they are dynamically created // but gets them right on a reflow, so force reflow by toggling a stylesheet + // var sheet = (document.styleSheets||[])[0]||{}; sheet.disabled = true; sheet.disabled = false; } @@ -375,8 +380,10 @@ if (nMML[type] && nMML[type](event,this) === false) {return false} if (ZOOM && ZOOM.HandleEvent(event,type,this) === false) {return false} if (event.srcElement.className === "MathJax_MathPlayer_Overlay" && this.msieMath.fireEvent) { - // for now, ignore all other events. This will disable MathPlayer's zoom - // feature, but also its support. + // + // For now, ignore all other events. This will disable MathPlayer's zoom + // feature, but also its support. + // if (type === "ContextMenu" || type === "Mouseover" || type === "Mouseout") {this.msieMath.fireEvent("on"+event.type,event)} } @@ -516,9 +523,11 @@ else {parent.appendChild(this.NativeMMLelement("mrow"))} } } else if (nMML.stretchyMoBug && (this.open || this.close)) { + // // This element contains opening and/or closing fences. Opera is not // able to stretch operators, so let's use an element // instead. + // var mfenced = this.NativeMMLelement("mfenced"); this.NativeMMLattributes(mfenced); var i = 0, m = this.data.length; @@ -526,7 +535,9 @@ if (this.close) { mfenced.setAttribute("close", this.close); m--; } var tag = mfenced; if (m - i + 1 > 1) { + // // If there are several children, put them in an + // tag = this.NativeMMLelement("mrow"); parent.appendChild(mfenced); parent = mfenced; @@ -579,40 +590,42 @@ }); if (!isMSIE) { + var SPLIT = MathJax.Hub.SplitList; MML.mtable.Augment({ toNativeMML: function (parent) { + var i, m; if (nMML.tableSpacingBug) { + // // Parse the rowspacing/columnspacing. For convenience, we convert // them to a left/top padding value that will be applied to each // cell. The leftmost/topmost cells will use "0px". + // var values = this.getValues("rowspacing", "columnspacing"); - this.nMMLtopPadding = ("0px " + values.rowspacing); - this.nMMLtopPadding = this.nMMLtopPadding.trim().split(/\s+/); - this.nMMLleftPadding = ("0px " + values.columnspacing); - this.nMMLleftPadding = this.nMMLleftPadding.trim().split(/\s+/); - // transmit the top padding to each row. + this.nMMLtopPadding = SPLIT("0px "+values.rowspacing); + this.nMMLleftPadding = SPLIT("0px "+values.columnspacing); + // + // Transmit the top padding to each row. // If this.parent.nMML.topPadding does not contain enough value, // repeat the last one. - for (var i = 0, m = this.data.length, tp = this.nMMLtopPadding; - i < m; i++) { - if (this.data[i]) { - this.data[i].nMMLtopPadding = - tp[i < tp.length ? i : tp.length-1]; - } + // + var tp = this.nMMLtopPadding, M = tp.length; + for (i = 0, m = this.data.length; i < m; i++) { + if (this.data[i]) + {this.data[i].nMMLtopPadding = tp[i < M ? i : M-1]} } } if (nMML.tableLabelBug) { // // Look for labeled rows so we know how to handle them // - for (var i = 0, m = this.data.length; i < m; i++) { + for (i = 0, m = this.data.length; i < m; i++) { if (this.data[i] && this.data[i].isa(MML.mlabeledtr)) { var align = HUB.config.displayAlign.charAt(0), - side = this.Get("side").charAt(0); + side = this.Get("side").charAt(0); this.nMMLhasLabels = true; this.nMMLlaMatch = (align === side); - this.nMMLforceWidth = (align === "c" || !!(this.width||""). - match("%")); + this.nMMLforceWidth = + (align === "c" || !!((this.width||"").match("%"))); break; } } @@ -636,7 +649,8 @@ if (this.nMMLforceWidth || side !== "r") { var n = (align !== "l" ? 1 : 0) + (side === "l" ? 1 : 0); if (n) { - var attr = {columnalign:"left", columnwidth:"auto", columnspacing:"0px", columnlines:"none"}; + var attr = {columnalign:"left", columnwidth:"auto", + columnspacing:"0px", columnlines:"none"}; for (var id in attr) {if (attr.hasOwnProperty(id) && this[id]) { var cols = [attr[id],attr[id]].slice(2-n).join(" ")+" "; mtable.setAttribute(id,cols+mtable.getAttribute(id)); @@ -646,7 +660,8 @@ // // Force the table width to 100% when needed // - if (this.nMMLforceWidth || !this.nMMLlaMatch) {mtable.setAttribute("width","100%")} + if (this.nMMLforceWidth || !this.nMMLlaMatch) + {mtable.setAttribute("width","100%")} } } }); @@ -655,21 +670,20 @@ this.SUPER(arguments).toNativeMML.call(this,parent); var mtr = parent.lastChild; if (nMML.tableSpacingBug) { - // set the row/column spacing. If this.parent.nMMLleftPadding does + // + // Set the row/column spacing. If this.parent.nMMLleftPadding does // not contain enough value, repeat the last one. - for (var mtd = mtr.firstElementChild, i = 0, - lp = this.parent.nMMLleftPadding; mtd; - mtd = mtd.nextElementSibling, i++) { - CELLSPACING(mtd, - this.nMMLtopPadding, - lp[i < lp.length ? i : lp.length-1]); + // + var lp = this.parent.nMMLleftPadding, M = lp.length; + for (var mtd = mtr.firstChild, i = 0; mtd; mtd = mtd.nextSibling, i++) { + CELLSPACING(mtd,this.nMMLtopPadding,lp[i < M ? i : M-1]); } } if (nMML.tableLabelBug) { var forceWidth = this.parent.nMMLforceWidth, - side = this.parent.Get("side").charAt(0), - align = HUB.config.displayAlign.charAt(0); + side = this.parent.Get("side").charAt(0), + align = HUB.config.displayAlign.charAt(0); if (this.parent.nMMLhasLabels && mtr.firstChild) { // @@ -681,11 +695,11 @@ NOPADDING("Left",mtr.firstChild); if (align !== "l") { mtr.insertBefore(this.NativeMMLelement("mtd"),mtr.firstChild) - .setAttribute("style","padding:0"); + .setAttribute("style","padding:0"); } if (side === "l") { mtr.insertBefore(this.NativeMMLelement("mtd"),mtr.firstChild) - .setAttribute("style","padding:0"); + .setAttribute("style","padding:0"); } } // @@ -710,21 +724,20 @@ } if (nMML.tableSpacingBug) { - // set the row/column spacing. If this.parent.nMMLleftPadding does + // + // Set the row/column spacing. If this.parent.nMMLleftPadding does // not contain enough value, repeat the last one. - for (var mtd = mtr.firstElementChild, i = 0, - lp = this.parent.nMMLleftPadding; mtd; - mtd = mtd.nextElementSibling, i++) { - CELLSPACING(mtd, - this.nMMLtopPadding, - lp[i < lp.length ? i : lp.length-1]); + // + var lp = this.parent.nMMLleftPadding, M = lp.length; + for (var mtd = mtr.firstChild, i = 0; mtd; mtd = mtd.nextSibling, i++) { + CELLSPACING(mtd,this.nMMLtopPadding,lp[i < M ? i : M-1]); } } if (nMML.tableLabelBug) { var side = this.parent.Get("side").charAt(0), - align = HUB.config.displayAlign.charAt(0), - indent = HUB.config.displayIndent; + align = HUB.config.displayAlign.charAt(0), + indent = HUB.config.displayIndent; // // Create label and either set the column width (if label is on the // same side as the alignment), or use mpadded to hide the label @@ -759,7 +772,7 @@ if (align !== "l") { if (align === "c") {w /= 2}; width -= w; mtr.insertBefore(this.NativeMMLelement("mtd"),mtr.firstChild) - .setAttribute("style","padding:0;width:"+w+"%"); + .setAttribute("style","padding:0;width:"+w+"%"); } if (side === "l") {mtr.insertBefore(label,mtr.firstChild)} } @@ -770,7 +783,7 @@ NOPADDING("Right",mtr.lastChild); if (align !== "r") { mtr.appendChild(this.NativeMMLelement("mtd")) - .setAttribute("style","padding:0;width:"+width+"%"); + .setAttribute("style","padding:0;width:"+width+"%"); } if (side === "r") { if (side !== align) {pad.setAttribute("lspace","-1width")} @@ -923,6 +936,7 @@ return; } + // // Some browsers do not handle very well. The MathML spec // suggests this equivalent construction instead, so let's use it: // open, child1, sep1, child2, ... sep(N-1), childN, close @@ -933,27 +947,36 @@ // // child1, sep1, child2, sep2, ..., sep(N-1), childN // + // var isOpera = HUB.Browser.isOpera; + var i, m, operator; + // // parse the open, close and separators attributes. + // var values = this.getValues("open","close","separators"); - values.open = values.open.trim(); - values.close = values.close.trim(); + values.open = values.open.replace(/^\s+/,"").replace(/\s+$/,""); + values.close = values.close.replace(/^\s+/,"").replace(/\s+$/,""); values.separators = values.separators.replace(/\s+/g,"").split(""); if (values.separators.length == 0) { + // // No separators specified, do not use separators at all. + // values.separators = null; } else if (values.separators.length < this.data.length-1) { + // // There are not enough separators, repeat the last one. - for (var s = values.separators[values.separators.length-1], - i = this.data.length-1-values.separators.length; i > 0; i--) { - values.separators.push(s) - } + // + var s = values.separators[values.separators.length-1]; + for (i = this.data.length-1-values.separators.length; i > 0; i--) + {values.separators.push(s)} } - // create an container and attach the attributes of the + // + // Create an container and attach the attributes of the // element to it. Note: removeAttribute does not raise any // exception when the attributes is absent. + // var tag = this.NativeMMLelement(isOpera ? this.type : "mrow"); this.NativeMMLattributes(tag); tag.removeAttribute("separators"); @@ -961,8 +984,7 @@ tag.setAttribute("open", values.open); tag.setAttribute("close", values.close); if (this.data.length > 1) { - parent.appendChild(tag); - parent = tag; + parent.appendChild(tag); parent = tag; tag = this.NativeMMLelement("mrow"); } } else { @@ -971,30 +993,34 @@ } if (!isOpera) { - // append the opening fence - var operator = this.NativeMMLelement("mo"); + // + // Append the opening fence + // + operator = this.NativeMMLelement("mo"); operator.setAttribute("fence", "true"); operator.textContent = values.open; tag.appendChild(operator); } - // append the content of the - for (var i = 0, m = this.data.length; i < m; i++) { + // + // Append the content of the + // + for (i = 0, m = this.data.length; i < m; i++) { if (values.separators && i > 0) { - var operator = this.NativeMMLelement("mo"); + operator = this.NativeMMLelement("mo"); operator.setAttribute("separator", "true"); operator.textContent = values.separators[i-1]; tag.appendChild(operator); } - if (this.data[i]) { - this.data[i].toNativeMML(tag); - } - else {tag.appendChild(this.NativeMMLelement("mrow"))} + if (this.data[i]) {this.data[i].toNativeMML(tag)} + else {tag.appendChild(this.NativeMMLelement("mrow"))} } if (!isOpera) { - // append the closing fence - var operator = this.NativeMMLelement("mo"); + // + // Append the closing fence + // + operator = this.NativeMMLelement("mo"); operator.setAttribute("fence", "true"); operator.textContent = values.close; tag.appendChild(operator);