diff --git a/unpacked/jax/element/mml/jax.js b/unpacked/jax/element/mml/jax.js index 2081f3df4..c2a2efbe6 100644 --- a/unpacked/jax/element/mml/jax.js +++ b/unpacked/jax/element/mml/jax.js @@ -920,49 +920,58 @@ MathJax.ElementJax.mml.Augment({ close: ')', separators: ',' }, - texClass: MML.TEXCLASS.OPEN, - setTeXclass: function (prev) { - this.getPrevClass(prev); + addFakeNodes: function () { var values = this.getValues("open","close","separators"); values.open = values.open.replace(/[ \t\n\r]/g,""); values.close = values.close.replace(/[ \t\n\r]/g,""); values.separators = values.separators.replace(/[ \t\n\r]/g,""); - // create a fake node for the open item + // + // Create a fake node for the open item + // if (values.open !== "") { this.SetData("open",MML.mo(values.open).With({ fence:true, form:MML.FORM.PREFIX, texClass:MML.TEXCLASS.OPEN })); + // // Clear flag for using MML spacing even though form is specified + // this.data.open.useMMLspacing &= ~this.data.open.SPACE_ATTR.form; - prev = this.data.open.setTeXclass(prev); } - // get the separators + // + // Create fake nodes for the separators + // if (values.separators !== "") { while (values.separators.length < this.data.length) {values.separators += values.separators.charAt(values.separators.length-1)} - } - // handle the first item, if any - if (this.data[0]) {prev = this.data[0].setTeXclass(prev)} - // add fake nodes for separators and handle the following item - for (var i = 1, m = this.data.length; i < m; i++) { - if (this.data[i]) { - if (values.separators !== "") { - this.SetData("sep"+i,MML.mo(values.separators.charAt(i-1)).With({separator:true})); - prev = this.data["sep"+i].setTeXclass(prev); - } - prev = this.data[i].setTeXclass(prev); + for (var i = 1, m = this.data.length; i < m; i++) { + if (this.data[i]) + {this.SetData("sep"+i,MML.mo(values.separators.charAt(i-1)).With({separator:true}))} } } - // create fake node for the close item + // + // Create fake node for the close item + // if (values.close !== "") { this.SetData("close",MML.mo(values.close).With({ fence:true, form:MML.FORM.POSTFIX, texClass:MML.TEXCLASS.CLOSE })); + // // Clear flag for using MML spacing even though form is specified + // this.data.close.useMMLspacing &= ~this.data.close.SPACE_ATTR.form; - prev = this.data.close.setTeXclass(prev); } - // get the data from the open item + }, + texClass: MML.TEXCLASS.OPEN, + setTeXclass: function (prev) { + this.addFakeNodes(); + this.getPrevClass(prev); + if (this.data.open) {prev = this.data.open.setTeXclass(prev)} + if (this.data[0]) {prev = this.data[0].setTeXclass(prev)} + for (var i = 1, m = this.data.length; i < m; i++) { + if (this.data["sep"+i]) {prev = this.data["sep"+i].setTeXclass(prev)} + if (this.data[i]) {prev = this.data[i].setTeXclass(prev)} + } + if (this.data.close) {prev = this.data.close.setTeXclass(prev)} this.updateTeXclass(this.data.open); this.texClass = MML.TEXCLASS.INNER; return prev; diff --git a/unpacked/jax/output/CommonHTML/jax.js b/unpacked/jax/output/CommonHTML/jax.js index 9b3e35c6c..b76d29589 100644 --- a/unpacked/jax/output/CommonHTML/jax.js +++ b/unpacked/jax/output/CommonHTML/jax.js @@ -27,7 +27,7 @@ */ -(function (HUB,AJAX,HTML,CHTML) { +(function (AJAX,HUB,HTML,CHTML) { var MML; /* @@ -152,7 +152,9 @@ }, Startup: function () { + // // Set up event handling + // EVENT = MathJax.Extension.MathEvents.Event; TOUCH = MathJax.Extension.MathEvents.Touch; HOVER = MathJax.Extension.MathEvents.Hover; @@ -162,14 +164,18 @@ this.Mouseout = HOVER.Mouseout; this.Mousemove = HOVER.Mousemove; - // Determine pixels per inch + // + // Determine pixels per inch + // var div = HTML.addElement(document.body,"div",{style:{width:"5in"}}); this.pxPerInch = div.offsetWidth/5; div.parentNode.removeChild(div); - // Set up styles and preload web fonts - return AJAX.Styles(this.config.styles,["InitializeHTML",this]); + // + // Set up styles and preload web fonts + // + return AJAX.Styles(this.config.styles,["InitializeCHTML",this]); }, - InitializeHTML: function () { + InitializeCHTML: function () { }, preTranslate: function (state) { @@ -515,23 +521,34 @@ this.CHTMLhandleStyle(span); this.CHTMLhandleColor(span); if (this.isToken) this.CHTMLhandleToken(span); - for (var i = 0, m = this.data.length, SPAN = span; i < m; i++) { - var child = this.data[i]; - if (child) { - if (options.childSpans) - SPAN = HTML.addElement(span,"span",{className:options.className}); - child.toCommonHTML(SPAN); - if (!options.noBBox) { - this.CHTML.w += child.CHTML.w + child.CHTML.l + child.CHTML.r; - if (child.CHTML.h > this.CHTML.h) this.CHTML.h = child.CHTML.h; - if (child.CHTML.d > this.CHTML.d) this.CHTML.d = child.CHTML.d; - if (child.CHTML.t > this.CHTML.t) this.CHTML.t = child.CHTML.t; - if (child.CHTML.b > this.CHTML.b) this.CHTML.b = child.CHTML.b; - } - } else if (options.forceChild) {HTML.addElement(span,"span")} - } + for (var i = 0, m = this.data.length; i < m; i++) this.CHTMLaddChild(span,i,options); return span; }, + CHTMLaddChild: function (span,i,options) { + var child = this.data[i]; + if (child) { + if (options.childSpans) + span = HTML.addElement(span,"span",{className:options.className}); + child.toCommonHTML(span); + if (!options.noBBox) { + this.CHTML.w += child.CHTML.w + child.CHTML.l + child.CHTML.r; + if (child.CHTML.h > this.CHTML.h) this.CHTML.h = child.CHTML.h; + if (child.CHTML.d > this.CHTML.d) this.CHTML.d = child.CHTML.d; + if (child.CHTML.t > this.CHTML.t) this.CHTML.t = child.CHTML.t; + if (child.CHTML.b > this.CHTML.b) this.CHTML.b = child.CHTML.b; + } + } else if (options.forceChild) {HTML.addElement(span,"span")} + }, + CHTMLstretchChild: function (i,H,D) { + var data = this.data[i]; + if (data && data.CHTMLcanStretch("Vertical",H,D)) { + var bbox = this.CHTML, dbox = data.CHTML, w = dbox.w; + data.CHTMLstretchV(H,D); + bbox.w += dbox.w - w; + if (dbox.h > bbox.h) bbox.h = dbox.h; + if (dbox.d > bbox.d) bbox.d = dbox.d; + } + }, CHTMLcreateSpan: function (span) { if (!this.CHTML) this.CHTML = {}; @@ -569,7 +586,7 @@ CHTMLhandleScriptlevel: function (span) { // ### FIXME: Need to prevent getting too small - // ### and should keep track of scaling so it can be comensated for + // ### and should keep track of scaling so it can be compensated for var level = this.Get("scriptlevel"); if (level) span.className += " MJXc-script"; }, @@ -888,7 +905,7 @@ var values = this.getValues("linethickness","displaystyle"); if (!values.displaystyle) { if (this.data[0]) this.data[0].CHTMLhandleScriptlevel(span.firstChild); - if (this.data[1]) this.data[0].CHTMLhandleScriptlevel(span.lastChild); + if (this.data[1]) this.data[1].CHTMLhandleScriptlevel(span.lastChild); } var denom = HTML.Element("span",{className:"MJXc-box",style:{"margin-top":"-.8em"}},[ ["span",{className:"MJXc-denom"},[ // inline-table @@ -971,22 +988,41 @@ }, CHTMLlayoutRoot: MML.msqrt.prototype.CHTMLlayoutRoot }); + + MML.mfenced.Augment({ + toCommonHTML: function (span) { + span = this.CHTMLcreateSpan(span); + this.CHTMLhandleStyle(span); + this.CHTMLhandleColor(span); + // + // Make row of open, data, sep, ... data, close + // + this.addFakeNodes(); + this.CHTMLaddChild(span,"open",{}); + for (var i = 0, m = this.data.length; i < m; i++) { + this.CHTMLaddChild(span,"sep"+i,{}); + this.CHTMLaddChild(span,i,{}); + } + this.CHTMLaddChild(span,"close",{}); + // + // Check for streching the elements + // + var H = this.CHTML.h, D = this.CHTML.d; + this.CHTMLstretchChild("open",H,D); + for (var i = 0, m = this.data.length; i < m; i++) { + this.CHTMLstretchChild("sep"+i,H,D); + this.CHTMLstretchChild(i,H,D); + } + this.CHTMLstretchChild("close",H,D); + return span; + } + }); MML.mrow.Augment({ toCommonHTML: function (span) { span = this.CHTMLdefaultSpan(span); - var bbox = this.CHTML; - var H = bbox.h, D = bbox.d; - for (var i = 0, m = this.data.length; i < m; i++) { - var data = this.data[i]; - if (data && data.CHTMLcanStretch("Vertical",H,D)) { - var dbox = data.CHTML; var w = dbox.w; - data.CHTMLstretchV(H,D); - bbox.w += dbox.w - w; - if (dbox.h > bbox.h) bbox.h = dbox.h; - if (dbox.d > bbox.d) bbox.d = dbox.d; - } - } + var H = this.CHTML.h, D = this.CHTML.d; + for (var i = 0, m = this.data.length; i < m; i++) this.CHTMLstretchChild(i,H,D); return span; } }); @@ -1090,4 +1126,4 @@ {AJAX.Require("[MathJax]/extensions/MathZoom.js")} }); -})(MathJax.Hub,MathJax.Ajax,MathJax.HTML,MathJax.OutputJax.CommonHTML); +})(MathJax.Ajax,MathJax.Hub,MathJax.HTML,MathJax.OutputJax.CommonHTML);