aboutsummaryrefslogtreecommitdiff
path: root/js/mathjax/jax/output/CommonHTML/autoload
diff options
context:
space:
mode:
Diffstat (limited to 'js/mathjax/jax/output/CommonHTML/autoload')
-rw-r--r--js/mathjax/jax/output/CommonHTML/autoload/annotation-xml.js62
-rw-r--r--js/mathjax/jax/output/CommonHTML/autoload/maction.js180
-rw-r--r--js/mathjax/jax/output/CommonHTML/autoload/menclose.js332
-rw-r--r--js/mathjax/jax/output/CommonHTML/autoload/mglyph.js96
-rw-r--r--js/mathjax/jax/output/CommonHTML/autoload/mmultiscripts.js298
-rw-r--r--js/mathjax/jax/output/CommonHTML/autoload/ms.js75
-rw-r--r--js/mathjax/jax/output/CommonHTML/autoload/mtable.js604
-rw-r--r--js/mathjax/jax/output/CommonHTML/autoload/multiline.js799
8 files changed, 2446 insertions, 0 deletions
diff --git a/js/mathjax/jax/output/CommonHTML/autoload/annotation-xml.js b/js/mathjax/jax/output/CommonHTML/autoload/annotation-xml.js
new file mode 100644
index 0000000..39acf24
--- /dev/null
+++ b/js/mathjax/jax/output/CommonHTML/autoload/annotation-xml.js
@@ -0,0 +1,62 @@
+// @license magnet:?xt=urn:btih:8e4f440f4c65981c5bf93c76d35135ba5064d8b7dn=apache-2.0.txt Apache-2.0
+/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+
+/*************************************************************
+ *
+ * MathJax/jax/output/CommonHTML/autoload/annotation-xm;l.js
+ *
+ * Implements the CommonHTML output for <annotation-xml> elements.
+ *
+ * ---------------------------------------------------------------------
+ *
+ * Copyright (c) 2015-2020 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.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
+ var VERSION = "2.7.9";
+ var MML = MathJax.ElementJax.mml,
+ CHTML = MathJax.OutputJax.CommonHTML;
+
+ MML["annotation-xml"].Augment({
+ toCommonHTML: function (node) {
+ var encoding = this.Get("encoding");
+ node = this.CHTMLdefaultNode(node,{childOptions:{encoding:encoding}});
+ if (this.CHTML.rscale !== 1) this.CHTML.rescale(1/this.CHTML.rscale);
+ return node;
+ }
+ });
+
+ MML.xml.Augment({
+ toCommonHTML: function (node,options) {
+ var bbox = this.CHTML = CHTML.BBOX.zero();
+ for (var i = 0, m = this.data.length; i < m; i++)
+ {node.appendChild(this.data[i].cloneNode(true))}
+ //
+ // Warning: causes reflow
+ //
+ var w = node.offsetWidth, h = node.offsetHeight;
+ var strut = CHTML.addElement(node,"mjx-hd-test",{style:{height:h+"px"}});
+ bbox.d = bbox.b = (node.offsetHeight - h)/CHTML.em;
+ bbox.w = bbox.r = w/CHTML.em; bbox.h = bbox.t = h/CHTML.em - bbox.d;
+ node.removeChild(strut);
+ }
+ });
+
+ MathJax.Hub.Startup.signal.Post("CommonHTML annotation-xml Ready");
+ MathJax.Ajax.loadComplete(CHTML.autoloadDir+"/annotation-xml.js");
+});
+
+// @license-end
diff --git a/js/mathjax/jax/output/CommonHTML/autoload/maction.js b/js/mathjax/jax/output/CommonHTML/autoload/maction.js
new file mode 100644
index 0000000..3fdb393
--- /dev/null
+++ b/js/mathjax/jax/output/CommonHTML/autoload/maction.js
@@ -0,0 +1,180 @@
+// @license magnet:?xt=urn:btih:8e4f440f4c65981c5bf93c76d35135ba5064d8b7dn=apache-2.0.txt Apache-2.0
+/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+
+/*************************************************************
+ *
+ * MathJax/jax/output/CommonHTML/autoload/maction.js
+ *
+ * Implements the CommonHTML output for <maction> elements.
+ *
+ * ---------------------------------------------------------------------
+ *
+ * Copyright (c) 2015-2020 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.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
+ var VERSION = "2.7.9";
+ var MML = MathJax.ElementJax.mml,
+ CHTML = MathJax.OutputJax.CommonHTML;
+
+ var currentTip, hover, clear;
+
+ //
+ // Add configuration for tooltips
+ //
+ var CONFIG = CHTML.config.tooltip = MathJax.Hub.Insert({
+ delayPost: 600, delayClear: 600,
+ offsetX: 10, offsetY: 5
+ },CHTML.config.tooltip||{});
+
+
+ MML.maction.Augment({
+ CHTMLtooltip: CHTML.addElement(document.body,"div",{id:"MathJax_CHTML_Tooltip"}),
+
+ toCommonHTML: function (node) {
+ var selected = this.Get("selection");
+ node = this.CHTMLcreateNode(node);
+ this.CHTML = CHTML.BBOX.empty();
+ this.CHTMLhandleStyle(node);
+ this.CHTMLhandleScale(node);
+ this.CHTMLaddChild(node,selected-1,{});
+ this.CHTML.clean();
+ this.CHTMLhandleSpace(node);
+ this.CHTMLhandleBBox(node);
+ this.CHTMLhandleColor(node);
+
+ var type = this.Get("actiontype");
+ if (this.CHTMLaction[type] && this.CHTMLaction.hasOwnProperty(type))
+ this.CHTMLaction[type].call(this,node,selected);
+
+ return node;
+ },
+ CHTMLcoreNode: function (node) {return this.CHTMLchildNode(node,0)},
+
+ //
+ // Implementations for the various actions
+ //
+ CHTMLaction: {
+ toggle: function (node,selection) {
+ this.selection = selection;
+ node.onclick = MathJax.Callback(["CHTMLclick",this,CHTML.jax]);
+ node.style.cursor = "pointer";
+ },
+
+ statusline: function (node,selection) {
+ node.onmouseover = MathJax.Callback(["CHTMLsetStatus",this]);
+ node.onmouseout = MathJax.Callback(["CHTMLclearStatus",this]);
+ node.onmouseover.autoReset = node.onmouseout.autoReset = true;
+ },
+
+ tooltip: function(node,selection) {
+ if (this.data[1] && this.data[1].isToken) {
+ node.title = node.alt = this.data[1].data.join("");
+ } else {
+ node.onmouseover = MathJax.Callback(["CHTMLtooltipOver",this,CHTML.jax]);
+ node.onmouseout = MathJax.Callback(["CHTMLtooltipOut",this,CHTML.jax]);
+ node.onmouseover.autoReset = node.onmouseout.autoReset = true;
+ }
+ }
+ },
+
+ //
+ // Handle a click on the maction element
+ // (remove the original rendering and rerender)
+ //
+ CHTMLclick: function (jax,event) {
+ this.selection++;
+ if (this.selection > this.data.length) this.selection = 1;
+ var hover = !!jax.hover;
+ jax.Update();
+ if (hover) {
+ var span = document.getElementById(jax.inputID+"-Span");
+ MathJax.Extension.MathEvents.Hover.Hover(jax,span);
+ }
+ return MathJax.Extension.MathEvents.Event.False(event);
+ },
+
+ //
+ // Set/Clear the window status message
+ //
+ CHTMLsetStatus: function (event) {
+ // FIXME: Do something better with non-token elements
+ this.messageID = MathJax.Message.Set
+ ((this.data[1] && this.data[1].isToken) ?
+ this.data[1].data.join("") : this.data[1].toString());
+ },
+ CHTMLclearStatus: function (event) {
+ if (this.messageID) MathJax.Message.Clear(this.messageID,0);
+ delete this.messageID;
+ },
+
+ //
+ // Handle tooltips
+ //
+ CHTMLtooltipOver: function (jax,event) {
+ if (!event) event = window.event;
+ if (clear) {clearTimeout(clear); clear = null}
+ if (hover) clearTimeout(hover);
+ var x = event.pageX; var y = event.pageY;
+ if (x == null) {
+ x = event.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
+ y = event.clientY + document.body.scrollTop + document.documentElement.scrollTop;
+ }
+ var callback = MathJax.Callback(["CHTMLtooltipPost",this,jax,x+CONFIG.offsetX,y+CONFIG.offsetY])
+ hover = setTimeout(callback,CONFIG.delayPost);
+ },
+ CHTMLtooltipOut: function (jax,event) {
+ if (hover) {clearTimeout(hover); hover = null}
+ if (clear) clearTimeout(clear);
+ var callback = MathJax.Callback(["CHTMLtooltipClear",this,80]);
+ clear = setTimeout(callback,CONFIG.delayClear);
+ },
+ CHTMLtooltipPost: function (jax,x,y) {
+ hover = null; if (clear) {clearTimeout(clear); clear = null}
+ var tip = this.CHTMLtooltip;
+ tip.style.display = "block"; tip.style.opacity = "";
+// tip.style.filter = CHTML.config.styles["#MathJax_CHTML_Tooltip"].filter;
+ if (this === currentTip) return;
+ tip.style.left = x+"px"; tip.style.top = y+"px";
+ tip.innerHTML = '<span class="mjx-chtml"><span class="mjx-math"></span></span>';
+ CHTML.getMetrics(jax);
+ try {this.data[1].toCommonHTML(tip.firstChild.firstChild)} catch(err) {
+ if (!err.restart) throw err;
+ tip.style.display = "none";
+ MathJax.Callback.After(["CHTMLtooltipPost",this,jax,x,y],err.restart);
+ return;
+ }
+ currentTip = this;
+ },
+ CHTMLtooltipClear: function (n) {
+ var tip = this.CHTMLtooltip;
+ if (n <= 0) {
+ tip.style.display = "none";
+ tip.style.opacity = tip.style.filter = "";
+ clear = null;
+ } else {
+ tip.style.opacity = n/100;
+ tip.style.filter = "alpha(opacity="+n+")";
+ clear = setTimeout(MathJax.Callback(["CHTMLtooltipClear",this,n-20]),50);
+ }
+ }
+ });
+
+ MathJax.Hub.Startup.signal.Post("CommonHTML maction Ready");
+ MathJax.Ajax.loadComplete(CHTML.autoloadDir+"/maction.js");
+});
+
+// @license-end
diff --git a/js/mathjax/jax/output/CommonHTML/autoload/menclose.js b/js/mathjax/jax/output/CommonHTML/autoload/menclose.js
new file mode 100644
index 0000000..5ba5b02
--- /dev/null
+++ b/js/mathjax/jax/output/CommonHTML/autoload/menclose.js
@@ -0,0 +1,332 @@
+// @license magnet:?xt=urn:btih:8e4f440f4c65981c5bf93c76d35135ba5064d8b7dn=apache-2.0.txt Apache-2.0
+/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+
+/*************************************************************
+ *
+ * MathJax/jax/output/CommonHTML/autoload/menclose.js
+ *
+ * Implements the CommonHTML output for <menclose> elements.
+ *
+ * ---------------------------------------------------------------------
+ *
+ * Copyright (c) 2015-2020 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.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
+ var VERSION = "2.7.9";
+ var MML = MathJax.ElementJax.mml,
+ CHTML = MathJax.OutputJax.CommonHTML;
+
+ var SVGNS = "http://www.w3.org/2000/svg";
+ var ARROWX = 4, ARROWDX = 1, ARROWY = 2;
+
+ MML.menclose.Augment({
+ toCommonHTML: function (node) {
+ var values = this.getValues("notation","thickness","padding");
+ if (values.thickness == null) values.thickness = ".075em";
+ if (values.padding == null) values.padding = ".2em";
+ //
+ // Get DOM nodes
+ //
+ node = this.CHTMLdefaultNode(node,{childNodes:"mjx-box", forceChild:true});
+ var child = node.firstChild, cbox = this.CHTMLbboxFor(0);
+ //
+ // Get the padding and rule thickness
+ //
+ var p = this.CHTMLlength2em(values.padding,1/CHTML.em); // padding for enclosure
+ var t = this.CHTMLlength2em(values.thickness,1/CHTML.em); // thickness of lines
+ t = Math.max(1,Math.round(t*CHTML.em))/CHTML.em;
+ var SOLID = CHTML.Px(t)+" solid";
+ var bb = {L:p, R:p, T:p, B:p, H:cbox.h+p, D:cbox.d+p, W:cbox.w+2*p};
+ child.style.padding = CHTML.Em(p);
+ //
+ // Eliminate duplicate notations.
+ //
+ var notations = MathJax.Hub.SplitList(values.notation), notation = {};
+ for (var i = 0, m = notations.length; i < m; i++) notation[notations[i]] = true;
+ if (notation[MML.NOTATION.UPDIAGONALARROW]) delete notation[MML.NOTATION.UPDIAGONALSTRIKE];
+ //
+ // Add the needed notations
+ //
+ for (var n in notation) {
+ if (notation.hasOwnProperty(n)) {
+ if (this.CHTMLnotation[n] && this.CHTMLnotation.hasOwnProperty(n))
+ this.CHTMLnotation[n].call(this,child,cbox,bb,p,t,SOLID);
+ }
+ }
+ //
+ // Adjust the bounding box
+ //
+ var BBOX = this.CHTML;
+ BBOX.w += bb.L + bb.R; BBOX.r += BBOX.L; if (BBOX.w > BBOX.r) BBOX.r = BBOX.w;
+ BBOX.h += bb.T; if (BBOX.h > BBOX.t) BBOX.t = BBOX.h;
+ BBOX.d += bb.B; if (BBOX.d > BBOX.b) BBOX.b = BBOX.d;
+
+ return node;
+ },
+ //
+ // The various notations and their implementations
+ //
+ CHTMLnotation: {
+
+ /********************************************************/
+
+ box: function (child,cbox,bb,p,t,SOLID) {
+ p -= t;
+ child.style.padding = CHTML.Em(p);
+ child.style.border = SOLID;
+ },
+
+ /********************************************************/
+
+ roundedbox: function (child,cbox,bb,p,t,SOLID) {
+ var r = Math.min(cbox.w,cbox.h+cbox.d+2*p)/4;
+ CHTML.addElement(child.parentNode,"mjx-box",{
+ style: {
+ padding:CHTML.Em(p-t), border:SOLID, "border-radius":CHTML.Em(r),
+ height:CHTML.Em(cbox.h+cbox.d), "vertical-align":CHTML.Em(-bb.D),
+ width:CHTML.Em(cbox.w), "margin-left":CHTML.Em(-bb.W)
+ }
+ });
+ },
+
+ /********************************************************/
+
+ circle: function (child,cbox,bb,p,t,SOLID) {
+ var H = bb.H, D = bb.D, W = bb.W;
+ var svg = this.CHTMLsvg(child,bb,t);
+ this.CHTMLsvgElement(svg.firstChild,"ellipse",{
+ rx:CHTML.Px(W/2-t/2), ry:CHTML.Px((H+D)/2-t/2),
+ cx:CHTML.Px(W/2), cy:CHTML.Px((H+D)/2)
+ });
+ this.CHTMLsvgViewBox(svg);
+ },
+
+ /********************************************************/
+
+ left: function (child,cbox,bb,p,t,SOLID) {
+ child.style.borderLeft = SOLID;
+ child.style.paddingLeft = CHTML.Em(p-t);
+ },
+
+ /********************************************************/
+
+ right: function (child,cbox,bb,p,t,SOLID) {
+ child.style.borderRight = SOLID;
+ child.style.paddingRight = CHTML.Em(p-t);
+ },
+
+ /********************************************************/
+
+ top: function (child,cbox,bb,p,t,SOLID) {
+ child.style.borderTop = SOLID;
+ child.style.paddingTop = CHTML.Em(p-t);
+ },
+
+ /********************************************************/
+
+ bottom: function (child,cbox,bb,p,t,SOLID) {
+ child.style.borderBottom = SOLID;
+ child.style.paddingBottom = CHTML.Em(p-t);
+ },
+
+ /********************************************************/
+
+ actuarial: function (child,cbox,bb,p,t,SOLID) {
+ child.style.borderTop = child.style.borderRight = SOLID;
+ child.style.paddingTop = child.style.paddingRight = CHTML.Em(p-t);
+ },
+
+ /********************************************************/
+
+ madruwb: function (child,cbox,bb,p,t,SOLID) {
+ child.style.borderBottom = child.style.borderRight = SOLID;
+ child.style.paddingBottom = child.style.paddingRight = CHTML.Em(p-t);
+ },
+
+ /********************************************************/
+
+ verticalstrike: function (child,cbox,bb,p,t,SOLID) {
+ CHTML.addElement(child.parentNode,"mjx-box",{
+ style: {
+ "border-left":SOLID,
+ height:CHTML.Em(bb.H+bb.D), "vertical-align":CHTML.Em(-bb.D),
+ width:CHTML.Em(cbox.w/2+p-t/2), "margin-left":CHTML.Em(-cbox.w/2-p-t/2)
+ }
+ });
+ },
+
+ /********************************************************/
+
+ horizontalstrike: function (child,cbox,bb,p,t,SOLID) {
+ CHTML.addElement(child.parentNode,"mjx-box",{
+ style: {
+ "border-top":SOLID,
+ height:CHTML.Em((bb.H+bb.D)/2-t/2), "vertical-align":CHTML.Em(-bb.D),
+ width:CHTML.Em(bb.W), "margin-left":CHTML.Em(-bb.W)
+ }
+ });
+ },
+
+ /********************************************************/
+
+ updiagonalstrike: function (child,cbox,bb,p,t,SOLID) {
+ var H = bb.H, D = bb.D, W = bb.W;
+ var svg = this.CHTMLsvg(child,bb,t);
+ this.CHTMLsvgElement(svg.firstChild,"line",{
+ x1:CHTML.Px(t/2), y1:CHTML.Px(H+D-t), x2:CHTML.Px(W-t), y2:CHTML.Px(t/2)
+ });
+ this.CHTMLsvgViewBox(svg);
+ },
+
+ /********************************************************/
+
+ downdiagonalstrike: function (child,cbox,bb,p,t,SOLID) {
+ var H = bb.H, D = bb.D, W = bb.W;
+ var svg = this.CHTMLsvg(child,bb,t);
+ this.CHTMLsvgElement(svg.firstChild,"line",{
+ x1:CHTML.Px(t/2), y1:CHTML.Px(t/2), x2:CHTML.Px(W-t), y2:CHTML.Px(H+D-t)
+ });
+ this.CHTMLsvgViewBox(svg);
+ },
+
+ /********************************************************/
+
+ updiagonalarrow: function (child,cbox,bb,p,t,SOLID) {
+ var H = bb.H + bb.D - t, W = bb.W - t/2;
+ var a = Math.atan2(H,W)*(-180/Math.PI).toFixed(3);
+ var R = Math.sqrt(H*H + W*W);
+ var svg = this.CHTMLsvg(child,bb,t);
+ var g = this.CHTMLsvgElement(svg.firstChild,"g",{
+ fill:"currentColor",
+ transform:"translate("+this.CHTMLpx(t/2)+" "+this.CHTMLpx(H+t/2)+") rotate("+a+")"
+ });
+ var x = t * ARROWX, dx = t * ARROWDX, y = t * ARROWY;
+ this.CHTMLsvgElement(g,"line",{
+ x1:CHTML.Px(t/2), y1:0, x2:CHTML.Px(R-x), y2:0
+ });
+ this.CHTMLsvgElement(g,"path",{
+ d: "M "+this.CHTMLpx(R-x)+",0 " +
+ "L "+this.CHTMLpx(R-x-dx)+","+this.CHTMLpx(y) +
+ "L "+this.CHTMLpx(R)+",0 " +
+ "L "+this.CHTMLpx(R-x-dx)+","+this.CHTMLpx(-y),
+ stroke:"none"
+ });
+ this.CHTMLsvgViewBox(svg);
+ },
+
+ /********************************************************/
+
+ phasorangle: function (child,cbox,bb,p,t,SOLID) {
+ var P = p, H = bb.H, D = bb.D;
+ p = (H+D)/2;
+ var W = bb.W + p - P; bb.W = W; bb.L = p;
+ child.style.margin = "0 0 0 "+CHTML.Em(p-P);
+ var svg = this.CHTMLsvg(child,bb,t);
+ this.CHTMLsvgElement(svg.firstChild,"path",{
+ d: "M "+this.CHTMLpx(p)+",1 " +
+ "L 1,"+this.CHTMLpx(H+D-t)+" L "+this.CHTMLpx(W)+","+this.CHTMLpx(H+D-t)
+ });
+ this.CHTMLsvgViewBox(svg);
+ },
+
+ /********************************************************/
+
+ longdiv: function (child,cbox,bb,p,t,SOLID) {
+ bb.W += 1.5*p; bb.L += 1.5*p;
+ var H = bb.H, D = bb.D, W = bb.W;
+ child.style.margin = "0 0 0 "+CHTML.Em(1.5*p);
+ var svg = this.CHTMLsvg(child,bb,t);
+ this.CHTMLsvgElement(svg.firstChild,"path",{
+ d: "M "+this.CHTMLpx(W)+",1 L 1,1 "+
+ "a"+this.CHTMLpx(p)+","+this.CHTMLpx((H+D)/2-t/2)+" 0 0,1 1,"+this.CHTMLpx(H+D-1.5*t)
+ });
+ this.CHTMLsvgViewBox(svg);
+ },
+
+ /********************************************************/
+
+ radical: function (child,cbox,bb,p,t,SOLID) {
+ bb.W += 1.5*p; bb.L += 1.5*p;
+ var H = bb.H, D = bb.D, W = bb.W;
+ child.style.margin = "0 0 0 "+CHTML.Em(1.5*p);
+ var svg = this.CHTMLsvg(child,bb,t);
+ this.CHTMLsvgElement(svg.firstChild,"path",{
+ d: "M 1,"+this.CHTMLpx(.6*(H+D)) +
+ " L "+this.CHTMLpx(p)+","+this.CHTMLpx(H+D) +
+ " L "+this.CHTMLpx(2*p)+",1 L "+this.CHTMLpx(W)+",1"
+ });
+ this.CHTMLsvgViewBox(svg);
+ }
+
+ /********************************************************/
+
+ },
+
+ //
+ // Pixels with no "px"
+ //
+ CHTMLpx: function (m) {
+ m *= CHTML.em;
+ if (Math.abs(m) < .1) return "0";
+ return m.toFixed(1).replace(/\.0$/,"");
+ },
+
+ //
+ // Create the SVG element and position it over the
+ // contents
+ //
+ CHTMLsvg: function (node,bbox,t) {
+ var svg = document.createElementNS(SVGNS,"svg");
+ if (svg.style) {
+ svg.style.width = CHTML.Em(bbox.W);
+ svg.style.height = CHTML.Em(bbox.H+bbox.D);
+ svg.style.verticalAlign = CHTML.Em(-bbox.D);
+ svg.style.marginLeft = CHTML.Em(-bbox.W);
+ }
+ var g = this.CHTMLsvgElement(svg,"g",{"stroke-width":CHTML.Px(t)});
+ if (this.CHTML.scale !== 1) {
+ g.setAttribute('transform', 'scale('+this.CHTML.scale+')');
+ }
+ node.parentNode.appendChild(svg);
+ return svg;
+ },
+ //
+ CHTMLsvgViewBox: function (svg) {
+ var bbox = svg.getBBox();
+ svg.setAttribute('viewBox', [bbox.x, bbox.y, bbox.width, bbox.height].join(' '));
+ },
+ //
+ // Add an SVG element to the given svg node
+ //
+ CHTMLsvgElement: function (svg,type,def) {
+ var obj = document.createElementNS(SVGNS,type); obj.isMathJax = true;
+ if (def) {for (var id in def) {if (def.hasOwnProperty(id)) {obj.setAttributeNS(null,id,def[id].toString())}}}
+ svg.appendChild(obj);
+ return obj;
+ }
+ });
+
+ //
+ // Just use default toCommonHTML for EI8
+ //
+ if (!document.createElementNS) delete MML.menclose.prototype.toCommonHTML;
+
+ MathJax.Hub.Startup.signal.Post("CommonHTML menclose Ready");
+ MathJax.Ajax.loadComplete(CHTML.autoloadDir+"/menclose.js");
+});
+
+// @license-end
diff --git a/js/mathjax/jax/output/CommonHTML/autoload/mglyph.js b/js/mathjax/jax/output/CommonHTML/autoload/mglyph.js
new file mode 100644
index 0000000..3f1f269
--- /dev/null
+++ b/js/mathjax/jax/output/CommonHTML/autoload/mglyph.js
@@ -0,0 +1,96 @@
+// @license magnet:?xt=urn:btih:8e4f440f4c65981c5bf93c76d35135ba5064d8b7dn=apache-2.0.txt Apache-2.0
+/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+
+/*************************************************************
+ *
+ * MathJax/jax/output/CommonHTML/autoload/mglyph.js
+ *
+ * Implements the CommonHTML output for <mglyph> elements.
+ *
+ * ---------------------------------------------------------------------
+ *
+ * Copyright (c) 2015-2020 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.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
+ var VERSION = "2.7.9";
+ var MML = MathJax.ElementJax.mml,
+ CHTML = MathJax.OutputJax.CommonHTML,
+ LOCALE = MathJax.Localization;
+
+ MML.mglyph.Augment({
+ toCommonHTML: function (node,options) {
+ var values = this.getValues("src","width","height","valign","alt");
+ node = this.CHTMLcreateNode(node);
+ this.CHTMLhandleStyle(node);
+ this.CHTMLhandleScale(node);
+ if (values.src === "") {
+ var index = this.Get("index");
+ this.CHTMLgetVariant();
+ if (index && this.CHTMLvariant.style)
+ this.CHTMLhandleText(node,String.fromCharCode(index),this.CHTMLvariant);
+ } else {
+ var bbox = this.CHTML;
+ if (!bbox.img) bbox.img = MML.mglyph.GLYPH[values.src];
+ if (!bbox.img) {
+ bbox.img = MML.mglyph.GLYPH[values.src] = {img: new Image(), status: "pending"};
+ bbox.img.img.onload = MathJax.Callback(["CHTMLimgLoaded",this]);
+ bbox.img.img.onerror = MathJax.Callback(["CHTMLimgError",this]);
+ bbox.img.img.src = values.src;
+ MathJax.Hub.RestartAfter(bbox.img.img.onload);
+ }
+ if (bbox.img.status !== "OK") {
+ var err = MML.Error(LOCALE._(["MathML","BadMglyph"],"Bad mglyph: %1",values.src));
+ err.data[0].data[0].mathsize = "75%";
+ this.Append(err); err.toCommonHTML(node); this.data.pop();
+ bbox.combine(err.CHTML,0,0,1);
+ } else {
+ var img = CHTML.addElement(node,"img",{
+ isMathJax:true, src:values.src, alt:values.alt, title:values.alt
+ });
+ 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,HH);
+ img.style.verticalAlign = CHTML.Em(-bbox.d);
+ bbox.h -= bbox.d; bbox.t = bbox.h;
+ }
+ }
+ }
+ this.CHTMLhandleSpace(node);
+ this.CHTMLhandleBBox(node);
+ this.CHTMLhandleColor(node);
+ return node;
+ },
+ CHTMLimgLoaded: function (event,status) {
+ if (typeof(event) === "string") status = event;
+ this.CHTML.img.status = (status || "OK");
+ },
+ CHTMLimgError: function () {this.CHTML.img.img.onload("error")}
+ },{
+ GLYPH: {} // global list of all loaded glyphs
+ });
+
+ MathJax.Hub.Startup.signal.Post("CommonHTML mglyph Ready");
+ MathJax.Ajax.loadComplete(CHTML.autoloadDir+"/mglyph.js");
+});
+
+// @license-end
diff --git a/js/mathjax/jax/output/CommonHTML/autoload/mmultiscripts.js b/js/mathjax/jax/output/CommonHTML/autoload/mmultiscripts.js
new file mode 100644
index 0000000..e9cce12
--- /dev/null
+++ b/js/mathjax/jax/output/CommonHTML/autoload/mmultiscripts.js
@@ -0,0 +1,298 @@
+// @license magnet:?xt=urn:btih:8e4f440f4c65981c5bf93c76d35135ba5064d8b7dn=apache-2.0.txt Apache-2.0
+/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+
+/*************************************************************
+ *
+ * MathJax/jax/output/CommonHTML/autoload/mmultiscripts.js
+ *
+ * Implements the CommonHTML output for <mmultiscripts> elements.
+ *
+ * ---------------------------------------------------------------------
+ *
+ * Copyright (c) 2015-2020 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.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
+ var VERSION = "2.7.9";
+ var MML = MathJax.ElementJax.mml,
+ CHTML = MathJax.OutputJax.CommonHTML;
+
+ MML.mmultiscripts.Augment({
+ toCommonHTML: function (node,options) {
+ var stretch = (options||{}).stretch;
+ if (!stretch) {
+ node = this.CHTMLcreateNode(node);
+ this.CHTMLhandleStyle(node);
+ this.CHTMLgetVariant();
+ this.CHTMLhandleScale(node);
+ }
+ CHTML.BBOX.empty(this.CHTML);
+
+ //
+ // Get base node
+ //
+ var base, bbox;
+ if (stretch) {
+ base = CHTML.getNode(node,"mjx-base");
+ } else {
+ this.CHTMLaddChild(node,0,{type:"mjx-base", noBBox:true, forceChild:true});
+ base = node.firstChild;
+ }
+ bbox = this.CHTMLbboxFor(0);
+ if (bbox.ic) {
+ bbox.R -= bbox.ic; // remove IC (added by mo and mi)
+ if (!stretch) base.style.marginRight = CHTML.Em(-bbox.ic);
+ delta = 1.3*bbox.ic + .05; // make faked IC be closer to expeted results
+ }
+
+ //
+ // Collect scripts into horizontal boxes and add them into the node
+ //
+ var BOX = {}, BBOX = {};
+ this.CHTMLgetScripts(BOX,BBOX,stretch,node);
+ var sub = BOX.sub, sup = BOX.sup, presub = BOX.presub, presup = BOX.presup;
+ var sbox = BBOX.sub, Sbox = BBOX.sup, pbox = BBOX.presub, Pbox = BBOX.presup;
+ if (!stretch) this.CHTMLaddBoxes(node,base,BOX);
+
+ //
+ // Get the initial values for the variables
+ //
+ var values = this.getValues("scriptlevel","scriptsizemultiplier");
+ var sscale = (this.Get("scriptlevel") < 3 ? values.scriptsizemultiplier : 1);
+ var ex = CHTML.TEX.x_height, s = CHTML.TEX.scriptspace;
+ var q = CHTML.TEX.sup_drop * sscale, r = CHTML.TEX.sub_drop * sscale;
+ var u = bbox.h - q, v = bbox.d + r, delta = 0, p;
+ var bmml = this.data[this.base];
+ if (bmml && (bmml.type === "mi" || bmml.type === "mo")) {
+ if (CHTML.isChar(bmml.data.join("")) && bbox.rscale === 1 && !bbox.sH &&
+ !bmml.Get("largeop")) {u = v = 0}
+ }
+ values = this.getValues("displaystyle","subscriptshift","superscriptshift","texprimestyle");
+ values.subscriptshift = (values.subscriptshift === "" ? 0 : this.CHTMLlength2em(values.subscriptshift));
+ values.superscriptshift = (values.superscriptshift === "" ? 0 : this.CHTMLlength2em(values.superscriptshift));
+
+ var dx = (presub ? s+pbox.w : presup ? s+Pbox.w-delta : 0);
+ this.CHTML.combine(bbox,dx,0); var x = this.CHTML.w;
+
+ //
+ // Place the scripts as needed
+ //
+ if (!sup && !presup) {
+ v = Math.max(v,CHTML.TEX.sub1,values.subscriptshift);
+ if (sub) v = Math.max(v,sbox.h-(4/5)*ex);
+ if (presub) v = Math.max(v,pbox.h-(4/5)*ex);
+ if (sub) this.CHTMLplaceSubOnly(sub,sbox,x,v,s);
+ if (presub) this.CHTMLplacePresubOnly(presub,pbox,v,s);
+ } else {
+ if (!sub && !presub) {
+ p = CHTML.TEX[(values.displaystyle ? "sup1" : (values.texprimestyle ? "sup3" : "sup2"))];
+ u = Math.max(u,p,values.superscriptshift);
+ if (sup) u = Math.max(u,Sbox.d+(1/4)*ex);
+ if (presup) u = Math.max(u,Pbox.d+(1/4)*ex);
+ if (sup) this.CHTMLplaceSupOnly(sup,Sbox,x,delta,u,s);
+ if (presup) this.CHTMLplacePresupOnly(presup,Pbox,delta,u,s);
+ } else {
+ v = Math.max(v,CHTML.TEX.sub2);
+ var t = CHTML.TEX.rule_thickness;
+ var h = (sbox||pbox).h, d = (Sbox||Pbox).d;
+ if (presub) h = Math.max(h,pbox.h);
+ if (presup) d = Math.max(d,Pbox.d);
+ if ((u - d) - (h - v) < 3*t) {
+ v = 3*t - u + d + h; q = (4/5)*ex - (u - d);
+ if (q > 0) {u += q; v -= q}
+ }
+ u = Math.max(u,values.superscriptshift);
+ v = Math.max(v,values.subscriptshift);
+ if (sup) {
+ if (sub) {this.CHTMLplaceSubSup(sub,sbox,sup,Sbox,x,delta,u,v,s)}
+ else {this.CHTMLplaceSupOnly(sup,Sbox,x,delta,u,s)}
+ } else if (sub) {this.CHTMLplaceSubOnly(sub,sbox,x,v,s)}
+ if (presup) {
+ if (presub) {this.CHTMLplacePresubPresup(presub,pbox,presup,Pbox,delta,u,v,s)}
+ else {this.CHTMLplacePresupOnly(presup,Pbox,delta,u,s)}
+ } else if (presub) {this.CHTMLplacePresubOnly(presub,pbox,v,s)}
+ }
+ }
+ this.CHTML.clean();
+ this.CHTMLhandleSpace(node);
+ this.CHTMLhandleBBox(node);
+ this.CHTMLhandleColor(node);
+ return node;
+ },
+ //
+ // Get the subscript, superscript, presubscript, and presuperscript
+ // boxes, with proper spacing, and computer their bounding boxes.
+ //
+ CHTMLgetScripts: function (BOX,BBOX,stretch,node) {
+ if (stretch) {
+ BOX.sub = CHTML.getNode(node,"mjx-sub");
+ BOX.sup = CHTML.getNode(node,"mjx-sup");
+ BOX.presub = CHTML.getNode(node,"mjx-presub");
+ BOX.presup = CHTML.getNode(node,"mjx-presup");
+ BBOX.sub = this.CHTMLbbox.sub;
+ BBOX.sup = this.CHTMLbbox.sup;
+ BBOX.presub = this.CHTMLbbox.presub;
+ BBOX.presup = this.CHTMLbbox.presup;
+ return;
+ }
+ this.CHTMLbbox = BBOX; // save for when stretched
+ var state = {i:1, w:0, BOX:BOX, BBOX:BBOX}, m = this.data.length;
+ var sub = "sub", sup = "sup";
+ while (state.i < m) {
+ if ((this.data[state.i]||{}).type === "mprescripts") {
+ state.i++; state.w = 0;
+ sub = "presub"; sup = "presup";
+ } else {
+ 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);
+ state.w += w;
+ }
+ }
+ if (BBOX.sub) BBOX.sub.clean();
+ if (BBOX.sup) BBOX.sup.clean();
+ if (BBOX.presub) BBOX.presub.clean();
+ if (BBOX.presup) BBOX.presup.clean();
+ },
+ //
+ // Add a script to the proper box, creating the box if needed,
+ // and padding the box to account for any <none/> elements.
+ // Return the bounding box for the script for later use.
+ //
+ 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) {
+ //
+ // 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);
+ BBOX.w = BBOX.r = state.w; BBOX.x = state.w;
+ }
+ }
+ data.toCommonHTML(BOX);
+ BBOX = data.CHTML;
+ }
+ if (data && data.type !== "mprescripts") state.i++;
+ return BBOX;
+ },
+ //
+ // Add padding to the script box to make match the width of the
+ // super- or subscript that is above or below it, and adjust the
+ // bounding box for the script row. If these are pre-scripts,
+ // right-justify the scripts, otherwise, left-justify them.
+ //
+ CHTMLpadScript: function (type,w,bbox,state) {
+ if (!bbox) bbox = {w:0, fake:1, rscale:1};
+ var BBOX = state.BBOX[type], dx = 0, dw = 0;
+ if (BBOX) {
+ if (bbox.rscale*bbox.w < w) {
+ var BOX = state.BOX[type]; dw = w-bbox.rscale*bbox.w;
+ var space = CHTML.Element("mjx-spacer",{style:{width:CHTML.Em(dw)}});
+ if (type.substr(0,3) === "pre" && !bbox.fake) {
+ BOX.insertBefore(space,BOX.lastChild);
+ dx = dw; dw = 0;
+ } else {
+ BOX.appendChild(space);
+ }
+ }
+ if (bbox.fake) {BBOX.w += dx} else {BBOX.combine(bbox,BBOX.w+dx,0)}
+ BBOX.w += dw;
+ }
+ },
+ //
+ // Add the boxes into the main node, creating stacks when needed
+ //
+ CHTMLaddBoxes: function (node,base,BOX) {
+ var sub = BOX.sub, sup = BOX.sup, presub = BOX.presub, presup = BOX.presup;
+ if (presub && presup) {
+ var prestack = CHTML.Element("mjx-prestack"); node.insertBefore(prestack,base);
+ prestack.appendChild(presup); prestack.appendChild(presub);
+ } else {
+ if (presub) node.insertBefore(presub,base);
+ if (presup) node.insertBefore(presup,base);
+ }
+ if (sub && sup) {
+ var stack = CHTML.addElement(node,"mjx-stack");
+ stack.appendChild(sup); stack.appendChild(sub);
+ } else {
+ if (sub) node.appendChild(sub);
+ if (sup) node.appendChild(sup);
+ }
+ },
+ //
+ // Handle positioning the various scripts
+ //
+ CHTMLplaceSubOnly: function (sub,sbox,x,v,s) {
+ sub.style.verticalAlign = CHTML.Em(-v);
+ sub.style.marginRight = CHTML.Em(s); sbox.w += s;
+ this.CHTML.combine(sbox,x,-v);
+ },
+ CHTMLplaceSupOnly: function (sup,Sbox,x,delta,u,s) {
+ sup.style.verticalAlign = CHTML.Em(u);
+ sup.style.paddingLeft = CHTML.Em(delta);
+ sup.style.paddingRight = CHTML.Em(s); Sbox.w += s;
+ this.CHTML.combine(Sbox,x+delta,u);
+ },
+ CHTMLplaceSubSup: function (sub,sbox,sup,Sbox,x,delta,u,v,s) {
+ sub.style.paddingRight = CHTML.Em(s); sbox.w += s;
+ sup.style.paddingBottom = CHTML.Em(u+v-Sbox.d-sbox.h);
+ sup.style.paddingLeft = CHTML.Em(delta+(Sbox.x||0));
+ sup.style.paddingRight = CHTML.Em(s); Sbox.w += s;
+ sup.parentNode.style.verticalAlign = CHTML.Em(-v);
+ this.CHTML.combine(sbox,x,-v);
+ this.CHTML.combine(Sbox,x+delta,u);
+ },
+ CHTMLplacePresubOnly: function (presub,pbox,v,s) {
+ presub.style.verticalAlign = CHTML.Em(-v);
+ presub.style.marginLeft = CHTML.Em(s);
+ this.CHTML.combine(pbox,s,-v);
+ },
+ CHTMLplacePresupOnly: function (presup,Pbox,delta,u,s) {
+ presup.style.verticalAlign = CHTML.Em(u);
+ presup.style.paddingLeft = CHTML.Em(s);
+ presup.style.paddingRight = CHTML.Em(-delta);
+ this.CHTML.combine(Pbox,s,u);
+ },
+ CHTMLplacePresubPresup: function (presub,pbox,presup,Pbox,delta,u,v,s) {
+ presub.style.paddingLeft = CHTML.Em(s);
+ presup.style.paddingBottom = CHTML.Em(u+v-Pbox.d-pbox.h);
+ presup.style.paddingLeft = CHTML.Em(delta+s+(Pbox.x||0));
+ presup.style.paddingRight = CHTML.Em(-delta);
+ presup.parentNode.style.verticalAlign = CHTML.Em(-v);
+ this.CHTML.combine(pbox,s,-v);
+ this.CHTML.combine(Pbox,s+delta,u);
+ },
+ //
+ // Handle stretchy bases
+ //
+ CHTMLstretchH: MML.mbase.CHTMLstretchH,
+ CHTMLstretchV: MML.mbase.CHTMLstretchV
+ });
+
+ MathJax.Hub.Startup.signal.Post("CommonHTML mmultiscripts Ready");
+ MathJax.Ajax.loadComplete(CHTML.autoloadDir+"/mmultiscripts.js");
+});
+
+// @license-end
diff --git a/js/mathjax/jax/output/CommonHTML/autoload/ms.js b/js/mathjax/jax/output/CommonHTML/autoload/ms.js
new file mode 100644
index 0000000..ded30fc
--- /dev/null
+++ b/js/mathjax/jax/output/CommonHTML/autoload/ms.js
@@ -0,0 +1,75 @@
+// @license magnet:?xt=urn:btih:8e4f440f4c65981c5bf93c76d35135ba5064d8b7dn=apache-2.0.txt Apache-2.0
+/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+
+/*************************************************************
+ *
+ * MathJax/jax/output/CommonHTML/autoload/ms.js
+ *
+ * Implements the CommonHTML output for <ms> elements.
+ *
+ * ---------------------------------------------------------------------
+ *
+ * Copyright (c) 2015-2020 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.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
+ var VERSION = "2.7.9";
+ var MML = MathJax.ElementJax.mml,
+ CHTML = MathJax.OutputJax.CommonHTML;
+
+ MML.ms.Augment({
+ toCommonHTML: function (node) {
+ //
+ // Create the node and handle its styles and scaling
+ // Get the variant and an empty bounding box
+ //
+ node = this.CHTMLcreateNode(node);
+ this.CHTMLhandleStyle(node);
+ this.CHTMLgetVariant();
+ this.CHTMLhandleScale(node);
+ CHTML.BBOX.empty(this.CHTML);
+ //
+ // Get the quotes to use
+ //
+ var values = this.getValues("lquote","rquote","mathvariant");
+ if (!this.hasValue("lquote") || values.lquote === '"') values.lquote = "\u201C";
+ if (!this.hasValue("rquote") || values.rquote === '"') values.rquote = "\u201D";
+ if (values.lquote === "\u201C" && values.mathvariant === "monospace") values.lquote = '"';
+ if (values.rquote === "\u201D" && values.mathvariant === "monospace") values.rquote = '"';
+ //
+ // Add the left quote, the child nodes, and the right quote
+ //
+ var text = values.lquote+this.data.join("")+values.rquote; // FIXME: handle mglyph?
+ this.CHTMLhandleText(node,text,this.CHTMLvariant);
+ //
+ // Finish the bbox, add any needed space and color
+ //
+ this.CHTML.clean();
+ this.CHTMLhandleSpace(node);
+ this.CHTMLhandleBBox(node);
+ this.CHTMLhandleColor(node);
+ //
+ // Return the completed node
+ //
+ return node;
+ }
+ });
+
+ MathJax.Hub.Startup.signal.Post("CommonHTML ms Ready");
+ MathJax.Ajax.loadComplete(CHTML.autoloadDir+"/ms.js");
+});
+
+// @license-end
diff --git a/js/mathjax/jax/output/CommonHTML/autoload/mtable.js b/js/mathjax/jax/output/CommonHTML/autoload/mtable.js
new file mode 100644
index 0000000..2e8b397
--- /dev/null
+++ b/js/mathjax/jax/output/CommonHTML/autoload/mtable.js
@@ -0,0 +1,604 @@
+// @license magnet:?xt=urn:btih:8e4f440f4c65981c5bf93c76d35135ba5064d8b7dn=apache-2.0.txt Apache-2.0
+/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+
+/*************************************************************
+ *
+ * MathJax/jax/output/CommonHTML/autoload/mtable.js
+ *
+ * Implements the CommonHTML output for <mtable> elements.
+ *
+ * ---------------------------------------------------------------------
+ *
+ * Copyright (c) 2015-2020 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.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
+ var VERSION = "2.7.9";
+ var MML = MathJax.ElementJax.mml,
+ CONFIG = MathJax.Hub.config,
+ CHTML = MathJax.OutputJax.CommonHTML,
+ SPLIT = MathJax.Hub.SplitList;
+
+ var LABEL = -1,
+ BIGDIMEN = 1000000;
+
+ MML.mtable.Augment({
+ toCommonHTML: function (node) {
+ //
+ // Create the table nodes and put them in a table
+ // (so that its bottom is on the baseline, rather than aligned on the top row)
+ //
+ var state = {rows:[], labels:[], labeled: false};
+ node = this.CHTMLdefaultNode(node,{noBBox:true, childOptions:state});
+ var table = CHTML.Element("mjx-table");
+ while (node.firstChild) table.appendChild(node.firstChild);
+ node.appendChild(table);
+ //
+ // Get the table attributes
+ //
+ var values = this.getValues("columnalign","rowalign","columnspacing","rowspacing",
+ "columnwidth","equalcolumns","equalrows",
+ "columnlines","rowlines","frame","framespacing",
+ "align","width","side","minlabelspacing","useHeight");
+ var t = CHTML.TEX.min_rule_thickness/CHTML.em;
+ state.t = CHTML.Px(t*this.CHTML.scale,1);
+ //
+ // Create the table
+ //
+ this.CHTMLgetBoxSizes(values,state);
+ this.CHTMLgetAttributes(values,state);
+ this.CHTMLadjustCells(values,state);
+ if (values.frame) table.style.border = state.t+" "+values.frame;
+ this.CHTMLalignV(values,state,node);
+ this.CHTMLcolumnWidths(values,state,node);
+ this.CHTMLstretchCells(values,state);
+ if (state.labeled) this.CHTMLaddLabels(values,state,node,table);
+ //
+ // Set the bounding box (ignores overlapping outside of the table)
+ //
+ var BBOX = this.CHTML;
+ BBOX.w = BBOX.r = state.R;
+ BBOX.h = BBOX.t = state.T-state.B;
+ BBOX.d = BBOX.b = state.B;
+ if (!values.frame && !BBOX.pwidth) {
+ node.style.padding = "0 "+CHTML.Em(1/6);
+ BBOX.L = BBOX.R = 1/6;
+ }
+ //
+ // Add any needed space and color
+ //
+ this.CHTMLhandleSpace(node);
+ this.CHTMLhandleBBox(node);
+ this.CHTMLhandleColor(node);
+ //
+ // Return the completed node
+ //
+ return node;
+ },
+ //
+ // Get the natural height, depth, and widths of the rows and columns
+ //
+ CHTMLgetBoxSizes: function (values,state) {
+ var LH = CHTML.FONTDATA.lineH * values.useHeight,
+ LD = CHTML.FONTDATA.lineD * values.useHeight;
+ var H = [], D = [], W = [], J = -1, i, m;
+ for (i = 0, m = this.data.length; i < m; i++) {
+ var row = this.data[i], s = (row.type === "mtr" ? 0 : LABEL);
+ H[i] = LH; D[i] = LD;
+ for (var j = s, M = row.data.length + s; j < M; j++) {
+ if (W[j] == null) {W[j] = -BIGDIMEN; if (j > J) J = j}
+ var cbox = row.data[j-s].CHTML;
+ if (cbox.h > H[i]) H[i] = cbox.h;
+ if (cbox.d > D[i]) D[i] = cbox.d;
+ if (cbox.w > W[j]) W[j] = cbox.w;
+ }
+ }
+ if (values.equalrows) {
+ state.HD = true;
+ var HH = Math.max.apply(Math,H);
+ var DD = Math.max.apply(Math,D);
+ for (i = 0, m = H.length; i < m; i++) {H[i] = HH; D[i] = DD}
+ }
+ state.H = H; state.D = D; state.W = W, state.J = J;
+ },
+ //
+ // Pad the spacing and alignment attributes to match the size of the table
+ //
+ CHTMLgetAttributes: function (values,state) {
+ var CSPACE = SPLIT(values.columnspacing),
+ RSPACE = SPLIT(values.rowspacing),
+ CALIGN = SPLIT(values.columnalign),
+ RALIGN = SPLIT(values.rowalign),
+ CLINES = SPLIT(values.columnlines),
+ RLINES = SPLIT(values.rowlines),
+ CWIDTH = SPLIT(values.columnwidth),
+ RCALIGN = [], i, m, J = state.J, M = state.rows.length-1;
+ for (i = 0, m = CSPACE.length; i < m; i++) CSPACE[i] = this.CHTMLlength2em(CSPACE[i]);
+ for (i = 0, m = RSPACE.length; i < m; i++) RSPACE[i] = this.CHTMLlength2em(RSPACE[i]);
+ while (CSPACE.length < J) CSPACE.push(CSPACE[CSPACE.length-1]);
+ while (CALIGN.length <= J) CALIGN.push(CALIGN[CALIGN.length-1]);
+ while (CLINES.length < J) CLINES.push(CLINES[CLINES.length-1]);
+ while (CWIDTH.length <= J) CWIDTH.push(CWIDTH[CWIDTH.length-1]);
+ while (RSPACE.length < M) RSPACE.push(RSPACE[RSPACE.length-1]);
+ while (RALIGN.length <= M) RALIGN.push(RALIGN[RALIGN.length-1]);
+ while (RLINES.length < M) RLINES.push(RLINES[RLINES.length-1]);
+ CALIGN[LABEL] = (values.side.substr(0,1) === "l" ? "left" : "right");
+ //
+ // Override aligment data based on row-specific attributes
+ //
+ for (i = 0; i <= M; i++) {
+ var row = this.data[i]; RCALIGN[i] = [];
+ if (row.rowalign) RALIGN[i] = row.rowalign;
+ if (row.columnalign) {
+ RCALIGN[i] = SPLIT(row.columnalign);
+ while (RCALIGN[i].length <= J) RCALIGN[i].push(RCALIGN[i][RCALIGN[i].length-1]);
+ }
+ }
+ //
+ // Handle framespacing
+ //
+ var FSPACE = SPLIT(values.framespacing);
+ if (FSPACE.length != 2) FSPACE = SPLIT(this.defaults.framespacing);
+ FSPACE[0] = Math.max(0,this.CHTMLlength2em(FSPACE[0]));
+ FSPACE[1] = Math.max(0,this.CHTMLlength2em(FSPACE[1]));
+ if (values.columnlines.replace(/none/g,"").replace(/ /g,"") !== "" ||
+ values.rowlines.replace(/none/g,"").replace(/ /g,"") !== "") values.fspace = true;
+ //
+ // Pad arrays so that final column can be treated as all the others
+ //
+ if (values.frame === MML.LINES.NONE) delete values.frame; else values.fspace = true;
+ if (values.frame) {
+ FSPACE[0] = Math.max(0,FSPACE[0]);
+ FSPACE[1] = Math.max(0,FSPACE[1]);
+ }
+ if (values.fspace) {
+ CSPACE[J] = FSPACE[0]; RSPACE[M] = FSPACE[1];
+ } else {
+ CSPACE[J] = RSPACE[M] = 0;
+ }
+ CLINES[J] = RLINES[M] = MML.LINES.NONE;
+ //
+ // Save everything in the state
+ //
+ state.CSPACE = CSPACE; state.RSPACE = RSPACE;
+ state.CALIGN = CALIGN; state.RALIGN = RALIGN;
+ state.CLINES = CLINES; state.RLINES = RLINES;
+ state.CWIDTH = CWIDTH; state.RCALIGN = RCALIGN;
+ state.FSPACE = FSPACE;
+ },
+ //
+ // Add styles to cells to handle borders, spacing, alignment, etc.
+ //
+ CHTMLadjustCells: function(values,state) {
+ var ROWS = state.rows,
+ CSPACE = state.CSPACE, CLINES = state.CLINES,
+ RSPACE = state.RSPACE, RLINES = state.RLINES,
+ CALIGN = state.CALIGN, RALIGN = state.RALIGN,
+ RCALIGN = state.RCALIGN;
+ CSPACE[state.J] *= 2; RSPACE[ROWS.length-1] *= 2; // since halved below
+ var T = "0", B, R, L, border, cbox, align, lastB = 0;
+ if (values.fspace) {
+ lastB = state.FSPACE[1];
+ T = CHTML.Em(state.FSPACE[1]);
+ }
+ state.RHD = []; state.RH = [];
+ for (var i = 0, m = ROWS.length; i < m; i++) {
+ var row = ROWS[i], rdata = this.data[i];
+ //
+ // Space and borders between rows
+ //
+ B = RSPACE[i]/2; border = null; L = "0";
+ if (RLINES[i] !== MML.LINES.NONE && RLINES[i] !== "") border = state.t+" "+RLINES[i];
+ if (border || (CLINES[j] !== MML.LINES.NONE && CLINES[j] !== "")) {
+ while (row.length <= state.J) {
+ row.push(CHTML.addElement(row.node,"mjx-mtd",null,[['span']]));
+ }
+ }
+ state.RH[i] = lastB + state.H[i]; // distance to baseline in row
+ lastB = Math.max(0,B);
+ state.RHD[i] = state.RH[i] + lastB + state.D[i]; // total height of row
+ B = CHTML.Em(lastB);
+ //
+ // Frame space for initial cell
+ //
+ if (values.fspace) L = CHTML.Em(state.FSPACE[0]);
+ //
+ // The cells in the row
+ //
+ for (var j = 0, M = row.length; j < M; j++) {
+ var s = (rdata.type === "mtr" ? 0 : LABEL);
+ var mtd = rdata.data[j-s] || {CHTML: CHTML.BBOX.zero()};
+ var cell = row[j].style; cbox = mtd.CHTML;
+ //
+ // Space and borders between columns
+ //
+ R = CSPACE[j]/2;
+ if (CLINES[j] !== MML.LINES.NONE) {
+ cell.borderRight = state.t+" "+CLINES[j];
+ R -= 1/CHTML.em/2;
+ }
+ R = CHTML.Em(Math.max(0,R));
+ cell.padding = T+" "+R+" 0px "+L;
+ if (border) cell.borderBottom = border;
+ L = R;
+ //
+ // Handle vertical alignment
+ //
+ align = (mtd.rowalign||(this.data[i]||{}).rowalign||RALIGN[i]);
+ var H = Math.max(1,cbox.h), D = Math.max(.2,cbox.d),
+ HD = (state.H[i]+state.D[i]) - (H+D),
+ child = row[j].firstChild.style;
+ if (align === MML.ALIGN.TOP) {
+ if (HD) child.marginBottom = CHTML.Em(HD);
+ cell.verticalAlign = "top";
+ } else if (align === MML.ALIGN.BOTTOM) {
+ cell.verticalAlign = "bottom";
+ if (HD) child.marginTop = CHTML.Em(HD);
+ } else if (align === MML.ALIGN.CENTER) {
+ if (HD) child.marginTop = child.marginBottom = CHTML.Em(HD/2);
+ cell.verticalAlign = "middle";
+ } else {
+ if (H !== state.H[i]) child.marginTop = CHTML.Em(state.H[i]-H);
+ }
+ //
+ // Handle horizontal alignment
+ //
+ align = (mtd.columnalign||RCALIGN[i][j]||CALIGN[j]);
+ if (align !== MML.ALIGN.CENTER) cell.textAlign = align;
+ }
+ row.node.style.height = CHTML.Em(state.RHD[i]);
+ T = B;
+ }
+ CSPACE[state.J] /= 2; RSPACE[ROWS.length-1] /= 2; // back to normal
+ },
+ //
+ // Align the table vertically according to the align attribute
+ //
+ CHTMLalignV: function (values,state,node) {
+ var n, M = state.rows.length, H = state.H, D = state.D, RSPACE = state.RSPACE;
+ //
+ // Get alignment type and row number
+ //
+ if (typeof(values.align) !== "string") values.align = String(values.align);
+ if (values.align.match(/(top|bottom|center|baseline|axis)( +(-?\d+))?/)) {
+ n = parseInt(RegExp.$3||"0");
+ values.align = RegExp.$1
+ if (n < 0) n += state.rows.length + 1;
+ if (n > M || n <= 0) n = null;
+ } else {
+ values.align = this.defaults.align;
+ }
+ //
+ // Get table height and baseline offset
+ //
+ var T = 0, B = 0, a = CHTML.TEX.axis_height;
+ if (values.fspace) T += state.FSPACE[1];
+ if (values.frame) {T += 2/CHTML.em; B += 1/CHTML.em}
+ for (var i = 0; i < M; i++) {
+ var h = H[i], d = D[i];
+ T += h + d + RSPACE[i];
+ if (n) {
+ if (i === n-1) {
+ B += ({top:h+d, bottom:0, center:(h+d)/2,
+ baseline:d, axis:a+d})[values.align] + RSPACE[i];
+ }
+ if (i >= n) B += h + d + RSPACE[i];
+ }
+ }
+ if (!n) B = ({top:T, bottom:0, center:T/2, baseline:T/2, axis:T/2-a})[values.align];
+ //
+ // Place the node and save the values
+ //
+ if (B) node.style.verticalAlign = CHTML.Em(-B);
+ state.T = T; state.B = B;
+ },
+ //
+ // Determine column widths and set the styles for the columns
+ //
+ CHTMLcolumnWidths: function (values,state,node) {
+ var CWIDTH = state.CWIDTH, CSPACE = state.CSPACE, J = state.J, j;
+ var WW = 0, setWidths = false, relWidth = values.width.match(/%$/);
+ var i, m, w;
+ //
+ // Handle equal columns by adjusting the CWIDTH array
+ //
+ if (values.width !== "auto" && !relWidth) {
+ WW = Math.max(0,this.CHTMLlength2em(values.width,state.R));
+ setWidths = true;
+ }
+ if (values.equalcolumns) {
+ if (relWidth) {
+ //
+ // Use percent of total (not perfect, but best we can do)
+ //
+ var p = CHTML.Percent(1/(J+1));
+ for (j = 0; j <= J; j++) CWIDTH[j] = p;
+ } else {
+ //
+ // For width = auto, make all widths equal the widest,
+ // otherwise, for specific width, remove intercolumn space
+ // and divide by number of columns to get widest space.
+ //
+ w = Math.max.apply(Math,state.W);
+ if (values.width !== "auto") {
+ var S = (values.fspace ? state.FSPACE[0] + (values.frame ? 2/CHTML.em : 0) : 0);
+ for (j = 0; j <= J; j++) S += CSPACE[j];
+ w = Math.max((WW-S)/(J+1),w);
+ }
+ w = CHTML.Em(w);
+ for (j = 0; j <= J; j++) CWIDTH[j] = w;
+ }
+ setWidths = true;
+ }
+ //
+ // Compute natural table width
+ //
+ var TW = 0; if (values.fspace) TW = state.FSPACE[0];
+ var auto = [], fit = [], percent = [], W = [];
+ var row = state.rows[0];
+ for (j = 0; j <= J; j++) {
+ W[j] = state.W[j];
+ if (CWIDTH[j] === "auto") auto.push(j)
+ else if (CWIDTH[j] === "fit") fit.push(j)
+ else if (CWIDTH[j].match(/%$/)) percent.push(j)
+ else W[j] = this.CHTMLlength2em(CWIDTH[j],W[j]);
+ TW += W[j] + CSPACE[j];
+ if (row[j]) row[j].style.width = CHTML.Em(W[j]);
+ }
+ if (values.frame) TW += 2/CHTML.em;
+ var hasFit = (fit.length > 0);
+ //
+ // Adjust widths of columns
+ //
+ if (setWidths || (relWidth && hasFit)) {
+ if (relWidth) {
+ //
+ // Attach appropriate widths to the columns
+ //
+ for (j = 0; j <= J; j++) {
+ cell = row[j].style;
+ if (CWIDTH[j] === "auto" && !hasFit) cell.width = "";
+ else if (CWIDTH[j] === "fit") cell.width = "";
+ else if (CWIDTH[j].match(/%$/)) cell.width = CWIDTH[j];
+ else cell.minWidth = cell.maxWidth = cell.width;
+ }
+ } else {
+ //
+ // Compute percentage widths
+ //
+ if (WW > TW) {
+ var extra = 0;
+ for (i = 0, m = percent.length; i < m; i++) {
+ j = percent[i];
+ w = Math.max(W[j],this.CHTMLlength2em(CWIDTH[j],WW));
+ extra += w-W[j]; W[j] = w;
+ row[j].style.width = CHTML.Em(w);
+ }
+ TW += extra;
+ }
+ //
+ // Compute "fit" widths
+ //
+ if (!hasFit) fit = auto;
+ if (WW > TW && fit.length) {
+ var dw = (WW - TW) / fit.length;
+ for (i = 0, m = fit.length; i < m; i++) {
+ j = fit[i]; W[j] += dw;
+ row[j].style.width = CHTML.Em(W[j]);
+ }
+ TW = WW;
+ }
+ }
+ }
+ W[LABEL] = state.W[LABEL];
+ state.W = W;
+ state.R = TW;
+ //
+ // Set variable width on DOM nodes
+ //
+ if (relWidth) {
+ node.style.width = this.CHTML.pwidth = "100%";
+ this.CHTML.mwidth = CHTML.Em(TW);
+ node.firstChild.style.width = values.width;
+ node.firstChild.style.margin = "auto";
+ }
+ },
+ //
+ // Stretch any cells that can be stretched
+ //
+ CHTMLstretchCells: function (values,state) {
+ var ROWS = state.rows, H = state.H, D = state.D, W = state.W,
+ J = state.J, M = ROWS.length-1;
+ for (var i = 0; i <= M; i++) {
+ var row = ROWS[i], rdata = this.data[i];
+ var h = H[i], d = D[i];
+ for (var j = 0; j <= J; j++) {
+ var cell = row[j], cdata = rdata.data[j];
+ if (!cdata) continue;
+ if (cdata.CHTML.stretch === "V") cdata.CHTMLstretchV(h,d);
+ else if (cdata.CHTML.stretch === "H") cdata.CHTMLstretchH(cell,W[j]);
+ }
+ }
+ },
+ //
+ // Add labels to a table
+ //
+ CHTMLaddLabels: function (values,state,node,table) {
+ //
+ // Get indentation and alignment
+ //
+ var indent = this.getValues("indentalignfirst","indentshiftfirst","indentalign","indentshift");
+ if (indent.indentalignfirst !== MML.INDENTALIGN.INDENTALIGN) indent.indentalign = indent.indentalignfirst;
+ if (indent.indentalign === MML.INDENTALIGN.AUTO) indent.indentalign = CONFIG.displayAlign;
+ if (indent.indentshiftfirst !== MML.INDENTSHIFT.INDENTSHIFT) indent.indentshift = indent.indentshiftfirst;
+ if (indent.indentshift === "auto") indent.indentshift = "0";
+ var shift = this.CHTMLlength2em(indent.indentshift,CHTML.cwidth);
+ var labelspace = this.CHTMLlength2em(values.minlabelspacing,.8);
+ var labelW = labelspace + state.W[LABEL], labelshift = 0, tw = state.R;
+ var dIndent = this.CHTMLlength2em(CONFIG.displayIndent,CHTML.cwidth);
+ var s = (state.CALIGN[LABEL] === MML.INDENTALIGN.RIGHT ? -1 : 1);
+ if (indent.indentalign === MML.INDENTALIGN.CENTER) {
+ tw += 2 * (labelW - s*(shift + dIndent));
+ shift += dIndent;
+ } else if (state.CALIGN[LABEL] === indent.indentalign) {
+ if (dIndent < 0) {labelshift = s*dIndent; dIndent = 0}
+ shift += s*dIndent; if (labelW > s*shift) shift = s*labelW; shift += labelshift;
+ shift *= s; tw += shift;
+ } else {
+ tw += labelW - s*shift + dIndent;
+ shift -= s*dIndent; shift *= -s;
+ }
+ //
+ // Create boxes for table and labels
+ //
+ var box = CHTML.addElement(node,"mjx-box",{
+ style:{width:"100%","text-align":indent.indentalign}
+ }); box.appendChild(table);
+ var labels = CHTML.Element("mjx-itable");
+ table.style.display = "inline-table"; if (!table.style.width) table.style.width = "auto";
+ labels.style.verticalAlign = "top";
+ table.style.verticalAlign = CHTML.Em(state.T-state.B-state.H[0]);
+ node.style.verticalAlign = "";
+ if (shift) {
+ if (indent.indentalign === MML.INDENTALIGN.CENTER) {
+ table.style.marginLeft = CHTML.Em(shift);
+ table.style.marginRight = CHTML.Em(-shift);
+ } else {
+ var margin = "margin" + (indent.indentalign === MML.INDENTALIGN.RIGHT ? "Right" : "Left");
+ table.style[margin] = CHTML.Em(shift);
+ }
+ }
+ //
+ // Add labels on correct side
+ //
+ if (state.CALIGN[LABEL] === "left") {
+ node.insertBefore(labels,box);
+ labels.style.marginRight = CHTML.Em(-state.W[LABEL]-labelshift);
+ if (labelshift) labels.style.marginLeft = CHTML.Em(labelshift);
+ } else {
+ node.appendChild(labels);
+ labels.style.marginLeft = CHTML.Em(-state.W[LABEL]+labelshift);
+ }
+ //
+ // Vertically align the labels with their rows
+ //
+ var LABELS = state.labels, T = 0;
+ if (values.fspace) T = state.FSPACE[0] + (values.frame ? 1/CHTML.em : 0);
+ for (var i = 0, m = LABELS.length; i < m; i++) {
+ if (LABELS[i] && this.data[i].data[0]) {
+ labels.appendChild(LABELS[i]);
+ var lbox = this.data[i].data[0].CHTML;
+ T = state.RH[i] - Math.max(1,lbox.h);
+ if (T) LABELS[i].firstChild.firstChild.style.marginTop = CHTML.Em(T);
+ LABELS[i].style.height = CHTML.Em(state.RHD[i]);
+ } else {
+ CHTML.addElement(labels,"mjx-label",{style:{height:CHTML.Em(state.RHD[i])}});
+ }
+ }
+ //
+ // Propagate full-width equations, and reserve room for equation plus label
+ //
+ node.style.width = this.CHTML.pwidth = "100%";
+ node.style.minWidth = this.CHTML.mwidth = CHTML.Em(Math.max(0,tw));
+ }
+ });
+
+ MML.mtr.Augment({
+ toCommonHTML: function (node,options) {
+ //
+ // Create the row node
+ //
+ node = this.CHTMLcreateNode(node);
+ this.CHTMLhandleStyle(node);
+ this.CHTMLhandleScale(node);
+ //
+ // Add a new row with no label
+ //
+ if (!options) options = {rows:[],labels:[]};
+ var row = []; options.rows.push(row); row.node = node;
+ options.labels.push(null);
+ //
+ // Add the cells to the row
+ //
+ for (var i = 0, m = this.data.length; i < m; i++)
+ row.push(this.CHTMLaddChild(node,i,options));
+ //
+ this.CHTMLhandleColor(node);
+ return node;
+ }
+ });
+ MML.mlabeledtr.Augment({
+ toCommonHTML: function (node,options) {
+ //
+ // Create the row node
+ //
+ node = this.CHTMLcreateNode(node);
+ this.CHTMLhandleStyle(node);
+ this.CHTMLhandleScale(node);
+ //
+ // Add a new row, and get the label
+ //
+ if (!options) options = {rows:[],labels:[]};
+ var row = []; options.rows.push(row); row.node = node;
+ var label = CHTML.Element("mjx-label"); options.labels.push(label);
+ this.CHTMLaddChild(label,0,options);
+ if (this.data[0]) options.labeled = true;
+ //
+ // Add the cells to the row
+ //
+ for (var i = 1, m = this.data.length; i < m; i++)
+ row.push(this.CHTMLaddChild(node,i,options));
+ //
+ this.CHTMLhandleColor(node);
+ return node;
+ }
+ });
+ 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
+ //
+ if (this.isEmbellished()) {
+ var mo = this.CoreMO(), BBOX = this.CHTML;
+ if (mo.CHTMLcanStretch("Vertical")) BBOX.stretch = "V";
+ else if (mo.CHTMLcanStretch("Horizontal")) BBOX.stretch = "H";
+ if (BBOX.stretch) {
+ var min = mo.Get("minsize",true);
+ if (min) {
+ if (BBOX.stretch === "V") {
+ var HD = BBOX.h + BBOX.d;
+ if (HD) {
+ var r = this.CHTMLlength2em(min,HD)/HD;
+ if (r > 1) {BBOX.h *= r; BBOX.d *= r}
+ }
+ } else {
+ BBOX.w = Math.max(BBOX.w,this.CHTMLlength2em(min,BBOX.w));
+ }
+ }
+ }
+ }
+ return node;
+ }
+ });
+
+
+ MathJax.Hub.Startup.signal.Post("CommonHTML mtable Ready");
+ MathJax.Ajax.loadComplete(CHTML.autoloadDir+"/mtable.js");
+});
+
+// @license-end
diff --git a/js/mathjax/jax/output/CommonHTML/autoload/multiline.js b/js/mathjax/jax/output/CommonHTML/autoload/multiline.js
new file mode 100644
index 0000000..9d54b99
--- /dev/null
+++ b/js/mathjax/jax/output/CommonHTML/autoload/multiline.js
@@ -0,0 +1,799 @@
+// @license magnet:?xt=urn:btih:8e4f440f4c65981c5bf93c76d35135ba5064d8b7dn=apache-2.0.txt Apache-2.0
+/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+
+/*************************************************************
+ *
+ * MathJax/jax/output/CommonHTML/autoload/multiline.js
+ *
+ * Implements the CommonHTML output for <mrow>'s that contain line breaks.
+ *
+ * ---------------------------------------------------------------------
+ *
+ * Copyright (c) 2015-2020 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.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
+ var VERSION = "2.7.9";
+ var MML = MathJax.ElementJax.mml,
+ CONFIG = MathJax.Hub.config,
+ CHTML = MathJax.OutputJax.CommonHTML;
+ //
+ // Fake node used for testing end-of-line potential breakpoint
+ //
+ var MO = MML.mo().With({CHTML: CHTML.BBOX.empty()});
+
+ //
+ // Penalties for the various line breaks
+ //
+ var PENALTY = {
+ newline: 0,
+ nobreak: 1000000,
+ goodbreak: [-200],
+ badbreak: [+200],
+ auto: [0],
+
+ maxwidth: 1.33, // stop looking for breaks after this time the line-break width
+ toobig: 800,
+ nestfactor: 400,
+ spacefactor: -100,
+ spaceoffset: 2,
+ spacelimit: 1, // spaces larger than this get a penalty boost
+ fence: 500,
+ close: 500
+ };
+
+ var ENDVALUES = {linebreakstyle: "after"};
+
+
+ /**************************************************************************/
+
+ MML.mbase.Augment({
+ CHTMLlinebreakPenalty: PENALTY,
+
+ /****************************************************************/
+ //
+ // Handle breaking an mrow into separate lines
+ //
+ CHTMLmultiline: function (node) {
+
+ //
+ // Find the parent element and mark it as multiline
+ //
+ var parent = this;
+ while (parent.inferred || (parent.parent && parent.parent.type === "mrow" &&
+ parent.parent.isEmbellished())) {parent = parent.parent}
+ var isTop = ((parent.type === "math" && parent.Get("display") === "block") ||
+ parent.type === "mtd");
+ parent.isMultiline = true;
+
+ //
+ // Default values for the line-breaking parameters
+ //
+ var VALUES = this.getValues(
+ "linebreak","linebreakstyle","lineleading","linebreakmultchar",
+ "indentalign","indentshift",
+ "indentalignfirst","indentshiftfirst",
+ "indentalignlast","indentshiftlast"
+ );
+ if (VALUES.linebreakstyle === MML.LINEBREAKSTYLE.INFIXLINEBREAKSTYLE)
+ VALUES.linebreakstyle = this.Get("infixlinebreakstyle");
+ VALUES.lineleading = this.CHTMLlength2em(VALUES.lineleading,0.5);
+
+ //
+ // Break the math at its best line breaks
+ //
+ CHTML.BBOX.empty(this.CHTML);
+ var stack = CHTML.addElement(node,"mjx-stack");
+ var state = {
+ BBOX: this.CHTML,
+ n: 0, Y: 0,
+ scale: (this.CHTML.scale||1),
+ isTop: isTop,
+ values: {},
+ VALUES: VALUES
+ },
+ align = this.CHTMLgetAlign(state,{}),
+ shift = this.CHTMLgetShift(state,{},align),
+ start = [],
+ end = {
+ index:[], penalty:PENALTY.nobreak,
+ w:0, W:shift, shift:shift, scanW:shift,
+ nest: 0
+ },
+ broken = false;
+
+ while (this.CHTMLbetterBreak(end,state,true) &&
+ (end.scanW >= CHTML.linebreakWidth || end.penalty === PENALTY.newline)) {
+ this.CHTMLaddLine(stack,start,end.index,state,end.values,broken);
+ start = end.index.slice(0); broken = true;
+ align = this.CHTMLgetAlign(state,end.values);
+ shift = this.CHTMLgetShift(state,end.values,align);
+ end.W = end.shift = end.scanW = shift; end.penalty = PENALTY.nobreak;
+ }
+ state.isLast = true;
+ this.CHTMLaddLine(stack,start,[],state,ENDVALUES,broken);
+
+ if (parent.type === "math") {
+ node.style.width = stack.style.width = this.CHTML.pwidth = "100%";
+ }
+ this.CHTML.mwidth = CHTML.Em(this.CHTML.w);
+ this.CHTML.isMultiline = parent.CHTML.isMultiline = true;
+ stack.style.verticalAlign = CHTML.Em(state.d - this.CHTML.d);
+
+ return node;
+ },
+
+ /****************************************************************/
+ //
+ // Locate the next linebreak that is better than the current one
+ //
+ CHTMLbetterBreak: function (info,state,toplevel) {
+ if (this.isToken) return false; // FIXME: handle breaking of token elements
+ if (this.isEmbellished()) {
+ info.embellished = this;
+ return this.CoreMO().CHTMLbetterBreak(info,state);
+ }
+ if (this.linebreakContainer) return false;
+ //
+ // Get the current breakpoint position and other data
+ //
+ var index = info.index.slice(0), i = info.index.shift(),
+ m = this.data.length, W, w, scanW, broken = (info.index.length > 0), better = false;
+ if (i == null) i = -1; if (!broken) {i++; info.W += info.w; info.w = 0}
+ scanW = info.scanW = info.W; info.nest++;
+ //
+ // Look through the line for breakpoints,
+ // (as long as we are not too far past the breaking width)
+ //
+ while (i < m && (info.scanW < PENALTY.maxwidth*CHTML.linebreakWidth || info.w === 0)) {
+ if (this.data[i]) {
+ if (this.data[i].CHTMLbetterBreak(info,state)) {
+ better = true; index = [i].concat(info.index); W = info.W; w = info.w;
+ if (info.penalty === PENALTY.newline) {
+ info.index = index;
+ if (info.nest) {info.nest--}
+ return true;
+ }
+ }
+ scanW = (broken ? info.scanW : this.CHTMLaddWidth(i,info,scanW));
+ }
+ info.index = []; i++; broken = false;
+ }
+ //
+ // Check if end-of-line is a better breakpoint
+ //
+ if (toplevel && better) {
+ MO.parent = this.parent; MO.inherit = this.inherit;
+ if (MO.CHTMLbetterBreak(info,state)) {better = false; index = info.index}
+ }
+ if (info.nest) {info.nest--}
+ info.index = index;
+ if (better) {info.W = W; info.w = w}
+ return better;
+ },
+ CHTMLaddWidth: function (i,info,scanW) {
+ if (this.data[i]) {
+ var bbox = this.data[i].CHTML;
+ scanW += (bbox.w + (bbox.L||0) + (bbox.R||0)) * (bbox.scale || 1);
+ info.W = info.scanW = scanW; info.w = 0;
+ }
+ return scanW;
+ },
+
+ /****************************************************************/
+ //
+ // Create a new line and move the required elements into it
+ // Position it using proper alignment and indenting
+ //
+ CHTMLaddLine: function (stack,start,end,state,values,broken) {
+ //
+ // Create a box for the line, with empty BBox
+ // fill it with the proper elements,
+ // and clean up the bbox
+ //
+ var block = CHTML.addElement(stack,"mjx-block",{},[["mjx-box"]]), line = block.firstChild;
+ var bbox = state.bbox = CHTML.BBOX.empty();
+ state.first = broken; state.last = true;
+ this.CHTMLmoveLine(start,end,line,state,values);
+ bbox.clean();
+ //
+ // Get the alignment and shift values
+ //
+ var align = this.CHTMLgetAlign(state,values),
+ shift = this.CHTMLgetShift(state,values,align,true);
+ //
+ // Set the Y offset based on previous depth, leading, and current height
+ //
+ var dY = 0;
+ if (state.n > 0) {
+ var LHD = CHTML.FONTDATA.baselineskip;
+ var leading = (state.values.lineleading == null ? state.VALUES : state.values).lineleading * state.scale;
+ var Y = state.Y;
+ state.Y -= Math.max(LHD,state.d + bbox.h + leading);
+ dY = Y - state.Y - state.d - bbox.h;
+ }
+ //
+ // Place the new line
+ //
+ if (shift) line.style.margin = "0 "+CHTML.Em(-shift)+" 0 "+CHTML.Em(shift);
+ if (align !== MML.INDENTALIGN.LEFT) block.style.textAlign = align;
+ if (dY) block.style.paddingTop = CHTML.Em(dY);
+ state.BBOX.combine(bbox,shift,state.Y);
+ //
+ // Save the values needed for the future
+ //
+ state.d = state.bbox.d; state.values = values; state.n++;
+ },
+
+ /****************************************************************/
+ //
+ // Get alignment and shift values from the given data
+ //
+ CHTMLgetAlign: function (state,values) {
+ var cur = values, prev = state.values, def = state.VALUES, align;
+ if (state.n === 0) align = cur.indentalignfirst || prev.indentalignfirst || def.indentalignfirst;
+ else if (state.isLast) align = prev.indentalignlast || def.indentalignlast;
+ else align = prev.indentalign || def.indentalign;
+ if (align === MML.INDENTALIGN.INDENTALIGN) align = prev.indentalign || def.indentalign;
+ if (align === MML.INDENTALIGN.AUTO) align = (state.isTop ? CONFIG.displayAlign : MML.INDENTALIGN.LEFT);
+ return align;
+ },
+ CHTMLgetShift: function (state,values,align,noadjust) {
+ var cur = values, prev = state.values, def = state.VALUES, shift;
+ if (state.n === 0) shift = cur.indentshiftfirst || prev.indentshiftfirst || def.indentshiftfirst;
+ else if (state.isLast) shift = prev.indentshiftlast || def.indentshiftlast;
+ else shift = prev.indentshift || def.indentshift;
+ if (shift === MML.INDENTSHIFT.INDENTSHIFT) shift = prev.indentshift || def.indentshift;
+ if (shift === "auto" || shift === "") shift = "0";
+ shift = this.CHTMLlength2em(shift,CHTML.cwidth);
+ if (state.isTop && CONFIG.displayIndent !== "0") {
+ var indent = this.CHTMLlength2em(CONFIG.displayIndent,CHTML.cwidth);
+ shift += (align === MML.INDENTALIGN.RIGHT ? -indent : indent);
+ }
+ return (align === MML.INDENTALIGN.RIGHT && !noadjust ? -shift : shift);
+ },
+
+ /****************************************************************/
+ //
+ // Move the selected elements into the new line's box,
+ // moving whole items when possible, and parts of ones
+ // that are split by a line break.
+ //
+ CHTMLmoveLine: function (start,end,node,state,values) {
+ var i = start[0], j = end[0];
+ if (i == null) i = -1; if (j == null) j = this.data.length-1;
+ if (i === j && start.length > 1) {
+ //
+ // If starting and ending in the same element move the subpiece to the new line
+ //
+ this.data[i].CHTMLmoveSlice(start.slice(1),end.slice(1),node,state,values,"marginLeft");
+ } else {
+ //
+ // Otherwise, move the remainder of the initial item
+ // and any others up to the last one
+ //
+ var last = state.last; state.last = false;
+ while (i < j) {
+ if (this.data[i]) {
+ if (start.length <= 1) this.data[i].CHTMLmoveNode(node,state,values);
+ else this.data[i].CHTMLmoveSlice(start.slice(1),[],node,state,values,"marginLeft");
+ }
+ i++; state.first = false; start = [];
+ }
+ //
+ // If the last item is complete, move it,
+ // otherwise move the first part of it up to the split
+ //
+ state.last = last;
+ if (this.data[i]) {
+ if (end.length <= 1) this.data[i].CHTMLmoveNode(node,state,values);
+ else this.data[i].CHTMLmoveSlice([],end.slice(1),node,state,values,"marginRight");
+ }
+ }
+ },
+
+ /****************************************************************/
+ //
+ // Split an element and copy the selected items into the new part
+ //
+ CHTMLmoveSlice: function (start,end,node,state,values,margin) {
+ //
+ // Create a new box for the slice of the element
+ // Move the selected portion into the slice
+ // If it is the last slice
+ // Remove the original (now empty) node
+ // Rename the Continue-0 node with the original name (for CHTMLnodeElement)
+ //
+ var slice = this.CHTMLcreateSliceNode(node);
+ this.CHTMLmoveLine(start,end,slice,state,values);
+ if (slice.style[margin]) slice.style[margin] = "";
+ if (this.CHTML.L) {
+ if (margin !== "marginLeft") state.bbox.w += this.CHTML.L;
+ else slice.className = slice.className.replace(/ MJXc-space\d/,"");
+ }
+ if (this.CHTML.R && margin !== "marginRight") state.bbox.w += this.CHTML.R;
+ if (end.length === 0) {
+ node = this.CHTMLnodeElement();
+ if (this.href) node = node.parentNode;
+ node.parentNode.removeChild(node);
+ node.nextMathJaxNode.id = node.id;
+ }
+ return slice;
+ },
+
+ /****************************************************************/
+ //
+ // Create a new node for an element that is split in two
+ // Clone the original and update its ID.
+ // Link the old node to the new one so we can find it later
+ //
+ CHTMLcreateSliceNode: function (node) {
+ var NODE = this.CHTMLnodeElement(), n = 0;
+ if (this.href) NODE = NODE.parentNode;
+ var LAST = NODE; while (LAST.nextMathJaxNode) {LAST = LAST.nextMathJaxNode; n++}
+ var SLICE = NODE.cloneNode(false); LAST.nextMathJaxNode = SLICE; SLICE.nextMathJaxNode = null;
+ SLICE.id += "-MJX-Continue-"+n;
+ return node.appendChild(SLICE);
+ },
+
+ /****************************************************************/
+ //
+ // Move an element from its original node to its new location in
+ // a split element or the new line's node
+ //
+ CHTMLmoveNode: function (line,state,values) {
+ // FIXME: handle linebreakstyle === "duplicate"
+ // FIXME: handle linebreakmultchar
+ if (!(state.first || state.last) ||
+ (state.first && state.values.linebreakstyle === MML.LINEBREAKSTYLE.BEFORE) ||
+ (state.last && values.linebreakstyle === MML.LINEBREAKSTYLE.AFTER)) {
+ //
+ // Move node
+ //
+ var node = this.CHTMLnodeElement();
+ if (this.href) node = node.parentNode;
+ line.appendChild(node);
+ if (this.CHTML.pwidth && !line.style.width) line.style.width = this.CHTML.pwidth;
+ //
+ // If it is last, remove right margin
+ // If it is first, remove left margin
+ //
+ if (state.last) node.style.marginRight = "";
+ if (state.first || state.nextIsFirst) {
+ node.style.marginLeft = ""; this.CHTML.L = 0;
+ node.className = node.className.replace(/ MJXc-space\d/,"");
+ }
+ if (state.first && this.CHTML.w === 0) state.nextIsFirst = true;
+ else delete state.nextIsFirst;
+ //
+ // Update bounding box
+ //
+ state.bbox.combine(this.CHTML,state.bbox.w,0);
+ }
+ }
+ });
+
+ /**************************************************************************/
+
+ MML.mfenced.Augment({
+ CHTMLbetterBreak: function (info,state) {
+ //
+ // Get the current breakpoint position and other data
+ //
+ var index = info.index.slice(0), i = info.index.shift(),
+ m = this.data.length, W, w, scanW, broken = (info.index.length > 0), better = false;
+ if (i == null) i = -1; if (!broken) {i++; info.W += info.w; info.w = 0}
+ scanW = info.scanW = info.W; info.nest++;
+ //
+ // Create indices that include the delimiters and separators
+ //
+ if (!this.dataI) {
+ this.dataI = [];
+ if (this.data.open) this.dataI.push("open");
+ if (m) this.dataI.push(0);
+ for (var j = 1; j < m; j++) {
+ if (this.data["sep"+j]) this.dataI.push("sep"+j);
+ this.dataI.push(j);
+ }
+ if (this.data.close) this.dataI.push("close");
+ }
+ m = this.dataI.length;
+ //
+ // Look through the line for breakpoints, including the open, close, and separators
+ // (as long as we are not too far past the breaking width)
+ //
+ while (i < m && (info.scanW < PENALTY.maxwidth*CHTML.linebreakWidth || info.w === 0)) {
+ var k = this.dataI[i];
+ if (this.data[k]) {
+ if (this.data[k].CHTMLbetterBreak(info,state)) {
+ better = true; index = [i].concat(info.index); W = info.W; w = info.w;
+ if (info.penalty === PENALTY.newline) {
+ info.index = index;
+ if (info.nest) info.nest--;
+ return true;
+ }
+ }
+ scanW = (broken ? info.scanW : this.CHTMLaddWidth(i,info,scanW));
+ }
+ info.index = []; i++; broken = false;
+ }
+ if (info.nest) info.nest--;
+ info.index = index;
+ if (better) {info.W = W; info.w = w}
+ return better;
+ },
+
+ CHTMLmoveLine: function (start,end,node,state,values) {
+ var i = start[0], j = end[0];
+ if (i == null) i = -1; if (j == null) j = this.dataI.length-1;
+ if (i === j && start.length > 1) {
+ //
+ // If starting and ending in the same element move the subpiece to the new line
+ //
+ this.data[this.dataI[i]].CHTMLmoveSlice(start.slice(1),end.slice(1),node,state,values,"marginLeft");
+ } else {
+ //
+ // Otherwise, move the remainder of the initial item
+ // and any others (including open and separators) up to the last one
+ //
+ var last = state.last; state.last = false; var k = this.dataI[i];
+ while (i < j) {
+ if (this.data[k]) {
+ if (start.length <= 1) this.data[k].CHTMLmoveNode(node,state,values);
+ else this.data[k].CHTMLmoveSlice(start.slice(1),[],node,state,values,"marginLeft");
+ }
+ i++; k = this.dataI[i]; state.first = false; start = [];
+ }
+ //
+ // If the last item is complete, move it
+ //
+ state.last = last;
+ if (this.data[k]) {
+ if (end.length <= 1) this.data[k].CHTMLmoveNode(node,state,values);
+ else this.data[k].CHTMLmoveSlice([],end.slice(1),node,state,values,"marginRight");
+ }
+ }
+ }
+
+ });
+
+ /**************************************************************************/
+
+ MML.msubsup.Augment({
+ CHTMLbetterBreak: function (info,state) {
+ if (!this.data[this.base]) {return false}
+ //
+ // Get the current breakpoint position and other data
+ //
+ var index = info.index.slice(0), i = info.index.shift(),
+ W, w, scanW, broken = (info.index.length > 0), better = false;
+ if (!broken) {info.W += info.w; info.w = 0}
+ scanW = info.scanW = info.W;
+ //
+ // Record the width of the base and the super- and subscripts
+ //
+ if (i == null) {
+ this.CHTML.baseW = this.data[this.base].CHTML.w;
+ this.CHTML.dw = this.CHTML.w - this.CHTML.baseW;
+ }
+ //
+ // Check if the base can be broken
+ //
+ if (this.data[this.base].CHTMLbetterBreak(info,state)) {
+ better = true; index = [this.base].concat(info.index); W = info.W; w = info.w;
+ if (info.penalty === PENALTY.newline) better = broken = true;
+ }
+ //
+ // Add in the base if it is unbroken, and add the scripts
+ //
+ if (!broken) this.CHTMLaddWidth(this.base,info,scanW);
+ info.scanW += this.CHTML.dw; info.W = info.scanW;
+ info.index = []; if (better) {info.W = W; info.w = w; info.index = index}
+ return better;
+ },
+
+ CHTMLmoveLine: function (start,end,node,state,values) {
+ //
+ // Move the proper part of the base
+ //
+ if (this.data[this.base]) {
+ var base = CHTML.addElement(node,"mjx-base");
+ var ic = this.data[this.base].CHTML.ic;
+ if (ic) base.style.marginRight = CHTML.Em(-ic);
+ if (start.length > 1) {
+ this.data[this.base].CHTMLmoveSlice(start.slice(1),end.slice(1),base,state,values,"marginLeft");
+ } else {
+ if (end.length <= 1) this.data[this.base].CHTMLmoveNode(base,state,values);
+ else this.data[this.base].CHTMLmoveSlice([],end.slice(1),base,state,values,"marginRight");
+ }
+ }
+ //
+ // If this is the end, check for super and subscripts, and move those
+ // by moving the elements that contains them. Adjust the bounding box
+ // to include the super and subscripts.
+ //
+ if (end.length === 0) {
+ var NODE = this.CHTMLnodeElement(),
+ stack = CHTML.getNode(NODE,"mjx-stack"),
+ sup = CHTML.getNode(NODE,"mjx-sup"),
+ sub = CHTML.getNode(NODE,"mjx-sub");
+ if (stack) node.appendChild(stack);
+ else if (sup) node.appendChild(sup);
+ else if (sub) node.appendChild(sub);
+ var w = state.bbox.w, bbox;
+ if (sup) {
+ bbox = this.data[this.sup].CHTML;
+ state.bbox.combine(bbox,w,bbox.Y);
+ }
+ if (sub) {
+ bbox = this.data[this.sub].CHTML;
+ state.bbox.combine(bbox,w,bbox.Y);
+ }
+ }
+ }
+
+ });
+
+ /**************************************************************************/
+
+ MML.mmultiscripts.Augment({
+ CHTMLbetterBreak: function (info,state) {
+ if (!this.data[this.base]) return false;
+ //
+ // Get the current breakpoint position and other data
+ //
+ var index = info.index.slice(0); info.index.shift();
+ var W, w, scanW, broken = (info.index.length > 0), better = false;
+ if (!broken) {info.W += info.w; info.w = 0}
+ info.scanW = info.W;
+ //
+ // Get the bounding boxes and the width of the scripts
+ //
+ var bbox = this.CHTML, base = this.data[this.base].CHTML;
+ var dw = bbox.w - base.w - (bbox.X||0);
+ //
+ // Add in the width of the prescripts
+ //
+ info.scanW += bbox.X||0; scanW = info.scanW;
+ //
+ // Check if the base can be broken
+ //
+ if (this.data[this.base].CHTMLbetterBreak(info,state)) {
+ better = true; index = [this.base].concat(info.index); W = info.W; w = info.w;
+ if (info.penalty === PENALTY.newline) better = broken = true;
+ }
+ //
+ // Add in the base if it is unbroken, and add the scripts
+ //
+ if (!broken) this.CHTMLaddWidth(this.base,info,scanW);
+ info.scanW += dw; info.W = info.scanW;
+ info.index = []; if (better) {info.W = W; info.w = w; info.index = index}
+ return better;
+ },
+
+ CHTMLmoveLine: function (start,end,node,state,values) {
+ var NODE, BOX = this.CHTMLbbox, w;
+ //
+ // If this is the start, move the prescripts, if any.
+ //
+ if (start.length < 1) {
+ NODE = this.CHTMLnodeElement();
+ var prestack = CHTML.getNode(NODE,"mjx-prestack"),
+ presup = CHTML.getNode(NODE,"mjx-presup"),
+ presub = CHTML.getNode(NODE,"mjx-presub");
+ if (prestack) node.appendChild(prestack);
+ else if (presup) node.appendChild(presup);
+ else if (presub) node.appendChild(presub);
+ w = state.bbox.w;
+ if (presup) state.bbox.combine(BOX.presup,w+BOX.presup.X,BOX.presup.Y);
+ if (presub) state.bbox.combine(BOX.presub,w+BOX.presub.X,BOX.presub.Y);
+ }
+ //
+ // Move the proper part of the base
+ //
+ if (this.data[this.base]) {
+ var base = CHTML.addElement(node,"mjx-base");
+ if (start.length > 1) {
+ this.data[this.base].CHTMLmoveSlice(start.slice(1),end.slice(1),base,state,values,"marginLeft");
+ } else {
+ if (end.length <= 1) this.data[this.base].CHTMLmoveNode(base,state,values);
+ else this.data[this.base].CHTMLmoveSlice([],end.slice(1),base,state,values,"marginRight");
+ }
+ }
+ //
+ // If this is the end, check for super and subscripts, and move those
+ // by moving the elements that contains them. Adjust the bounding box
+ // to include the super and subscripts.
+ //
+ if (end.length === 0) {
+ NODE = this.CHTMLnodeElement();
+ var stack = CHTML.getNode(NODE,"mjx-stack"),
+ sup = CHTML.getNode(NODE,"mjx-sup"),
+ sub = CHTML.getNode(NODE,"mjx-sub");
+ if (stack) node.appendChild(stack);
+ else if (sup) node.appendChild(sup);
+ else if (sub) node.appendChild(sub);
+ w = state.bbox.w;
+ if (sup) state.bbox.combine(BOX.sup,w,BOX.sup.Y);
+ if (sub) state.bbox.combine(BOX.sub,w,BOX.sub.Y);
+ }
+ }
+
+ });
+
+ /**************************************************************************/
+
+ MML.mo.Augment({
+ //
+ // Override the method for checking line breaks to properly handle <mo>
+ //
+ CHTMLbetterBreak: function (info,state) {
+ if (info.values && info.values.id === this.CHTMLnodeID) return false;
+ var values = this.getValues(
+ "linebreak","linebreakstyle","lineleading","linebreakmultchar",
+ "indentalign","indentshift",
+ "indentalignfirst","indentshiftfirst",
+ "indentalignlast","indentshiftlast",
+ "texClass", "fence"
+ );
+ if (values.linebreakstyle === MML.LINEBREAKSTYLE.INFIXLINEBREAKSTYLE)
+ values.linebreakstyle = this.Get("infixlinebreakstyle");
+ //
+ // Adjust nesting by TeX class (helps output that does not include
+ // mrows for nesting, but can leave these unbalanced.
+ //
+ if (values.texClass === MML.TEXCLASS.OPEN) info.nest++;
+ if (values.texClass === MML.TEXCLASS.CLOSE && info.nest) info.nest--;
+ //
+ // Get the default penalty for this location
+ //
+ var W = info.scanW; delete info.embellished;
+ var w = this.CHTML.w + (this.CHTML.L||0) + (this.CHTML.R||0);
+ if (values.linebreakstyle === MML.LINEBREAKSTYLE.AFTER) {W += w; w = 0}
+ if (W - info.shift === 0 && values.linebreak !== MML.LINEBREAK.NEWLINE)
+ return false; // don't break at zero width (FIXME?)
+ var offset = CHTML.linebreakWidth - W;
+ // Adjust offest for explicit first-line indent and align
+ if (state.n === 0 && (values.indentshiftfirst !== state.VALUES.indentshiftfirst ||
+ values.indentalignfirst !== state.VALUES.indentalignfirst)) {
+ var align = this.CHTMLgetAlign(state,values),
+ shift = this.CHTMLgetShift(state,values,align);
+ offset += (info.shift - shift);
+ }
+ //
+ var penalty = Math.floor(offset / CHTML.linebreakWidth * 1000);
+ if (penalty < 0) penalty = PENALTY.toobig - 3*penalty;
+ if (values.fence) penalty += PENALTY.fence;
+ if ((values.linebreakstyle === MML.LINEBREAKSTYLE.AFTER &&
+ values.texClass === MML.TEXCLASS.OPEN) ||
+ values.texClass === MML.TEXCLASS.CLOSE) penalty += PENALTY.close;
+ penalty += info.nest * PENALTY.nestfactor;
+ //
+ // Get the penalty for this type of break and
+ // use it to modify the default penalty
+ //
+ var linebreak = PENALTY[values.linebreak||MML.LINEBREAK.AUTO]||0;
+ if (!MathJax.Object.isArray(linebreak)) {
+ // for breaks past the width, keep original penalty for newline
+ if (linebreak || offset >= 0) {penalty = linebreak * info.nest}
+ } else {penalty = Math.max(1,penalty + linebreak[0] * info.nest)}
+ //
+ // If the penalty is no better than the current one, return false
+ // Otherwise save the data for this breakpoint and return true
+ //
+ if (penalty >= info.penalty) return false;
+ info.penalty = penalty; info.values = values; info.W = W; info.w = w;
+ values.lineleading = this.CHTMLlength2em(values.lineleading,state.VALUES.lineleading);
+ values.id = this.CHTMLnodeID;
+ return true;
+ }
+ });
+
+ /**************************************************************************/
+
+ MML.mspace.Augment({
+ //
+ // Override the method for checking line breaks to properly handle <mspace>
+ //
+ CHTMLbetterBreak: function (info,state) {
+ if (info.values && info.values.id === this.CHTMLnodeID) return false;
+ var values = this.getValues("linebreak");
+ var linebreakValue = values.linebreak;
+ if (!linebreakValue || this.hasDimAttr()) {
+ // The MathML spec says that the linebreak attribute should be ignored
+ // if any dimensional attribute is set.
+ linebreakValue = MML.LINEBREAK.AUTO;
+ }
+ //
+ // Get the default penalty for this location
+ //
+ var W = info.scanW, w = this.CHTML.w + (this.CHTML.L||0) + (this.CHTML.R||0);
+ if (W - info.shift === 0) return false; // don't break at zero width (FIXME?)
+ var offset = CHTML.linebreakWidth - W;
+ //
+ var penalty = Math.floor(offset / CHTML.linebreakWidth * 1000);
+ if (penalty < 0) penalty = PENALTY.toobig - 3*penalty;
+ penalty += info.nest * PENALTY.nestfactor;
+ //
+ // Get the penalty for this type of break and
+ // use it to modify the default penalty
+ //
+ var linebreak = PENALTY[linebreakValue]||0;
+ if (linebreakValue === MML.LINEBREAK.AUTO && w >= PENALTY.spacelimit &&
+ !this.mathbackground && !this.background)
+ linebreak = [(w+PENALTY.spaceoffset)*PENALTY.spacefactor];
+ if (!MathJax.Object.isArray(linebreak)) {
+ // for breaks past the width, keep original penalty for newline
+ if (linebreak || offset >= 0) {penalty = linebreak * info.nest}
+ } else {penalty = Math.max(1,penalty + linebreak[0] * info.nest)}
+ //
+ // If the penalty is no better than the current one, return false
+ // Otherwise save the data for this breakpoint and return true
+ //
+ if (penalty >= info.penalty) return false;
+ info.penalty = penalty; info.values = values; info.W = W; info.w = w;
+ values.lineleading = state.VALUES.lineleading;
+ values.linebreakstyle = "before"; values.id = this.CHTMLnodeID;
+ return true;
+ }
+ });
+
+ //
+ // Hook into the mathchoice extension
+ //
+ MathJax.Hub.Register.StartupHook("TeX mathchoice Ready",function () {
+ MML.TeXmathchoice.Augment({
+ CHTMLbetterBreak: function (info,state) {
+ return this.Core().CHTMLbetterBreak(info,state);
+ },
+ CHTMLmoveLine: function (start,end,node,state,values) {
+ return this.Core().CHTMLmoveSlice(start,end,node,state,values);
+ }
+ });
+ });
+
+ //
+ // Have maction process only the selected item
+ //
+ MML.maction.Augment({
+ CHTMLbetterBreak: function (info,state) {
+ return this.Core().CHTMLbetterBreak(info,state);
+ },
+ CHTMLmoveLine: function (start,end,node,state,values) {
+ return this.Core().CHTMLmoveSlice(start,end,node,state,values);
+ }
+ });
+
+ //
+ // Have semantics only do the first element
+ // (FIXME: do we need to do anything special about annotation-xml?)
+ //
+ MML.semantics.Augment({
+ CHTMLbetterBreak: function (info,state) {
+ return (this.data[0] ? this.data[0].CHTMLbetterBreak(info,state) : false);
+ },
+ CHTMLmoveLine: function (start,end,node,state,values) {
+ return (this.data[0] ? this.data[0].CHTMLmoveSlice(start,end,node,state,values) : null);
+ }
+ });
+
+ /**************************************************************************/
+
+ MathJax.Hub.Startup.signal.Post("CommonHTML multiline Ready");
+ MathJax.Ajax.loadComplete(CHTML.autoloadDir+"/multiline.js");
+
+});
+// @license-end