commit 425c9df6e99fe77781c529b9e83d573f626afbc8
parent f3374f9c0544f30f720816679b5b1035bcb06320
Author: Davide P. Cervone <dpvc@union.edu>
Date: Wed, 5 Aug 2015 16:39:06 -0400
Move old CommonHTML to be FastHTML
Diffstat:
17 files changed, 1165 insertions(+), 22 deletions(-)
diff --git a/unpacked/MathJax.js b/unpacked/MathJax.js
@@ -2542,8 +2542,8 @@ MathJax.Hub.Startup = {
["Post",this.signal,"Begin Cookie"],
["Get",MathJax.HTML.Cookie,"menu",MathJax.Hub.config.menuSettings],
[function (config) {
- if (config.menuSettings.locale)
- {MathJax.Localization.resetLocale(config.menuSettings.locale)}
+ var SETTINGS = config.menuSettings;
+ if (SETTINGS.locale) MathJax.Localization.resetLocale(SETTINGS.locale);
var renderer = config.menuSettings.renderer, jax = config.jax;
if (renderer) {
var name = "output/"+renderer; jax.sort();
@@ -2555,8 +2555,12 @@ MathJax.Hub.Startup = {
}
jax.unshift(name);
}
- if (config.menuSettings.CHTMLpreview && !MathJax.Extension["CHTML-preview"])
- {MathJax.Hub.config.extensions.push("CHTML-preview.js")}
+ if (SETTINGS.CHTMLpreview != null) {
+ if (SETTINGS.FHTMLpreview == null) SETTINGS.FHTMLpreview = SETTINGS.CHTMLpreview;
+ delete SETTINGS.CHTMLpreview;
+ }
+ if (SETTINGS.FHTMLpreview && !MathJax.Extension["FHTML-preview"])
+ MathJax.Hub.config.extensions.push("FHTML-preview.js");
},MathJax.Hub.config],
["Post",this.signal,"End Cookie"]
);
diff --git a/unpacked/config/AM_HTMLorMML-full.js b/unpacked/config/AM_HTMLorMML-full.js
@@ -19,7 +19,7 @@
MathJax.Hub.Config({
config: ["MMLorHTML.js"],
extensions: ["asciimath2jax.js","MathEvents.js","MathZoom.js","MathMenu.js","toMathML.js","CHTML-preview.js"],
- jax: ["input/AsciiMath","output/HTML-CSS","output/NativeMML","output/CommonHTML"]
+ jax: ["input/AsciiMath","output/HTML-CSS","output/NativeMML","output/FastHTML"]
});
MathJax.Ajax.loadComplete("[MathJax]/config/AM_HTMLorMML-full.js");
diff --git a/unpacked/config/AM_HTMLorMML.js b/unpacked/config/AM_HTMLorMML.js
@@ -19,7 +19,7 @@
MathJax.Hub.Config({
config: ["MMLorHTML.js"],
extensions: ["asciimath2jax.js","MathEvents.js","MathZoom.js","MathMenu.js","toMathML.js","CHTML-preview.js"],
- jax: ["input/AsciiMath","output/HTML-CSS","output/NativeMML","output/CommonHTML"]
+ jax: ["input/AsciiMath","output/HTML-CSS","output/NativeMML","output/FastHTML"]
});
MathJax.Ajax.loadComplete("[MathJax]/config/AM_HTMLorMML.js");
diff --git a/unpacked/config/Accessible-full.js b/unpacked/config/Accessible-full.js
@@ -19,7 +19,7 @@
MathJax.Hub.Config({
config: ["MMLorHTML.js"],
extensions: ["tex2jax.js","mml2jax.js","MathEvents.js","MathZoom.js","MathMenu.js","toMathML.js","TeX/noErrors.js","TeX/noUndefined.js","TeX/AMSmath.js","TeX/AMSsymbols.js","CHTML-preview.js"],
- jax: ["input/TeX","input/MathML","output/HTML-CSS","output/NativeMML","output/CommonHTML"],
+ jax: ["input/TeX","input/MathML","output/HTML-CSS","output/NativeMML","output/FastHTML"],
menuSettings: {
zoom: "Double-Click",
mpContext: true,
diff --git a/unpacked/config/Accessible.js b/unpacked/config/Accessible.js
@@ -19,7 +19,7 @@
MathJax.Hub.Config({
config: ["MMLorHTML.js"],
extensions: ["tex2jax.js","mml2jax.js","MathEvents.js","MathZoom.js","MathMenu.js","toMathML.js","TeX/noErrors.js","TeX/noUndefined.js","TeX/AMSmath.js","TeX/AMSsymbols.js","CHTML-preview.js"],
- jax: ["input/TeX","input/MathML","output/HTML-CSS","output/NativeMML","output/CommonHTML"],
+ jax: ["input/TeX","input/MathML","output/HTML-CSS","output/NativeMML","output/FastHTML"],
menuSettings: {
zoom: "Double-Click",
mpContext: true,
diff --git a/unpacked/config/MML_HTMLorMML.js b/unpacked/config/MML_HTMLorMML.js
@@ -19,7 +19,7 @@
MathJax.Hub.Config({
config: ["MMLorHTML.js"],
extensions: ["mml2jax.js","MathEvents.js","MathZoom.js","MathMenu.js","toMathML.js","CHTML-preview.js"],
- jax: ["input/MathML","output/HTML-CSS","output/NativeMML","output/CommonHTML"]
+ jax: ["input/MathML","output/HTML-CSS","output/NativeMML","output/FastHTML"]
});
MathJax.Ajax.loadComplete("[MathJax]/config/MML_HTMLorMML.js");
diff --git a/unpacked/config/TeX-AMS-MML_HTMLorMML-full.js b/unpacked/config/TeX-AMS-MML_HTMLorMML-full.js
@@ -19,7 +19,7 @@
MathJax.Hub.Config({
config: ["MMLorHTML.js"],
extensions: ["tex2jax.js","mml2jax.js","MathEvents.js","MathZoom.js","MathMenu.js","toMathML.js","TeX/noErrors.js","TeX/noUndefined.js","TeX/AMSmath.js","TeX/AMSsymbols.js","CHTML-preview.js"],
- jax: ["input/TeX","input/MathML","output/HTML-CSS","output/NativeMML","output/CommonHTML"]
+ jax: ["input/TeX","input/MathML","output/HTML-CSS","output/NativeMML","output/FastHTML"]
});
MathJax.Ajax.loadComplete("[MathJax]/config/TeX-AMS-MML_HTMLorMML-full.js");
diff --git a/unpacked/config/TeX-AMS-MML_HTMLorMML.js b/unpacked/config/TeX-AMS-MML_HTMLorMML.js
@@ -19,7 +19,7 @@
MathJax.Hub.Config({
config: ["MMLorHTML.js"],
extensions: ["tex2jax.js","mml2jax.js","MathEvents.js","MathZoom.js","MathMenu.js","toMathML.js","TeX/noErrors.js","TeX/noUndefined.js","TeX/AMSmath.js","TeX/AMSsymbols.js","CHTML-preview.js"],
- jax: ["input/TeX","input/MathML","output/HTML-CSS","output/NativeMML","output/CommonHTML"]
+ jax: ["input/TeX","input/MathML","output/HTML-CSS","output/NativeMML","output/FastHTML"]
});
MathJax.Ajax.loadComplete("[MathJax]/config/TeX-AMS-MML_HTMLorMML.js");
diff --git a/unpacked/config/TeX-AMS-MML_SVG-full.js b/unpacked/config/TeX-AMS-MML_SVG-full.js
@@ -18,7 +18,7 @@
MathJax.Hub.Config({
extensions: ["tex2jax.js","mml2jax.js","MathEvents.js","MathZoom.js","MathMenu.js","toMathML.js","TeX/noErrors.js","TeX/noUndefined.js","TeX/AMSmath.js","TeX/AMSsymbols.js","CHTML-preview.js"],
- jax: ["input/TeX","input/MathML","output/SVG","output/CommonHTML"]
+ jax: ["input/TeX","input/MathML","output/SVG","output/FastHTML"]
});
MathJax.Ajax.loadComplete("[MathJax]/config/TeX-AMS-MML_SVG-full.js");
diff --git a/unpacked/config/TeX-AMS-MML_SVG.js b/unpacked/config/TeX-AMS-MML_SVG.js
@@ -18,7 +18,7 @@
MathJax.Hub.Config({
extensions: ["tex2jax.js","mml2jax.js","MathEvents.js","MathZoom.js","MathMenu.js","toMathML.js","TeX/noErrors.js","TeX/noUndefined.js","TeX/AMSmath.js","TeX/AMSsymbols.js","CHTML-preview.js"],
- jax: ["input/TeX","input/MathML","output/SVG","output/CommonHTML"]
+ jax: ["input/TeX","input/MathML","output/SVG","output/FastHTML"]
});
MathJax.Ajax.loadComplete("[MathJax]/config/TeX-AMS-MML_SVG.js");
diff --git a/unpacked/config/TeX-AMS_HTML-full.js b/unpacked/config/TeX-AMS_HTML-full.js
@@ -18,7 +18,7 @@
MathJax.Hub.Config({
extensions: ["tex2jax.js","MathEvents.js","MathZoom.js","MathMenu.js","toMathML.js","TeX/noErrors.js","TeX/noUndefined.js","TeX/AMSmath.js","TeX/AMSsymbols.js","CHTML-preview.js"],
- jax: ["input/TeX","output/HTML-CSS","output/CommonHTML"]
+ jax: ["input/TeX","output/HTML-CSS","output/FastHTML"]
});
MathJax.Ajax.loadComplete("[MathJax]/config/TeX-AMS_HTML-full.js");
diff --git a/unpacked/config/TeX-AMS_HTML.js b/unpacked/config/TeX-AMS_HTML.js
@@ -18,7 +18,7 @@
MathJax.Hub.Config({
extensions: ["tex2jax.js","MathEvents.js","MathZoom.js","MathMenu.js","toMathML.js","TeX/noErrors.js","TeX/noUndefined.js","TeX/AMSmath.js","TeX/AMSsymbols.js","CHTML-preview.js"],
- jax: ["input/TeX","output/HTML-CSS","output/CommonHTML"]
+ jax: ["input/TeX","output/HTML-CSS","output/FastHTML"]
});
MathJax.Ajax.loadComplete("[MathJax]/config/TeX-AMS_HTML.js");
diff --git a/unpacked/config/TeX-MML-AM_HTMLorMML-full.js b/unpacked/config/TeX-MML-AM_HTMLorMML-full.js
@@ -19,7 +19,7 @@
MathJax.Hub.Config({
config: ["MMLorHTML.js"],
extensions: ["tex2jax.js","mml2jax.js","asciimath2jax.js","MathEvents.js","MathZoom.js","MathMenu.js","toMathML.js","TeX/noErrors.js","TeX/noUndefined.js","TeX/AMSmath.js","TeX/AMSsymbols.js","CHTML-preview.js"],
- jax: ["input/TeX","input/MathML","input/AsciiMath","output/HTML-CSS","output/NativeMML","output/CommonHTML"]
+ jax: ["input/TeX","input/MathML","input/AsciiMath","output/HTML-CSS","output/NativeMML","output/FastHTML"]
});
MathJax.Ajax.loadComplete("[MathJax]/config/TeX-MML-AM_HTMLorMML-full.js");
diff --git a/unpacked/config/TeX-MML-AM_HTMLorMML.js b/unpacked/config/TeX-MML-AM_HTMLorMML.js
@@ -19,7 +19,7 @@
MathJax.Hub.Config({
config: ["MMLorHTML.js"],
extensions: ["tex2jax.js","mml2jax.js","asciimath2jax.js","MathEvents.js","MathZoom.js","MathMenu.js","toMathML.js","TeX/noErrors.js","TeX/noUndefined.js","TeX/AMSmath.js","TeX/AMSsymbols.js","CHTML-preview.js"],
- jax: ["input/TeX","input/MathML","input/AsciiMath","output/HTML-CSS","output/NativeMML","output/CommonHTML"]
+ jax: ["input/TeX","input/MathML","input/AsciiMath","output/HTML-CSS","output/NativeMML","output/FastHTML"]
});
MathJax.Ajax.loadComplete("[MathJax]/config/TeX-MML-AM_HTMLorMML.js");
diff --git a/unpacked/extensions/MathMenu.js b/unpacked/extensions/MathMenu.js
@@ -1089,12 +1089,13 @@
),
ITEM.RULE(),
ITEM.SUBMENU(["Renderer","Math Renderer"], {hidden:!CONFIG.showRenderer},
- ITEM.RADIO("HTML-CSS", "renderer", {action: MENU.Renderer}),
- ITEM.RADIO("Fast HTML", "renderer", {action: MENU.Renderer, value:"CommonHTML"}),
- ITEM.RADIO("MathML", "renderer", {action: MENU.Renderer, value:"NativeMML"}),
- ITEM.RADIO("SVG", "renderer", {action: MENU.Renderer}),
+ ITEM.RADIO("HTML-CSS", "renderer", {action: MENU.Renderer}),
+ ITEM.RADIO("Common HTML","renderer", {action: MENU.Renderer, value:"CommonHTML"}),
+ ITEM.RADIO("Fast HTML", "renderer", {action: MENU.Renderer, value:"FastHTML"}),
+ ITEM.RADIO("MathML", "renderer", {action: MENU.Renderer, value:"NativeMML"}),
+ ITEM.RADIO("SVG", "renderer", {action: MENU.Renderer}),
ITEM.RULE(),
- ITEM.CHECKBOX("Fast Preview", "CHTMLpreview")
+ ITEM.CHECKBOX("Fast Preview", "FHTMLpreview")
),
ITEM.SUBMENU("MathPlayer", {hidden:!HUB.Browser.isMSIE || !CONFIG.showMathPlayer,
disabled:!HUB.Browser.hasMathPlayer},
diff --git a/unpacked/jax/output/FastHTML/config.js b/unpacked/jax/output/FastHTML/config.js
@@ -0,0 +1,53 @@
+/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+
+/*************************************************************
+ *
+ * MathJax/jax/output/FastHTML/config.js
+ *
+ * Initializes the FastHTML OutputJax (the main definition is in
+ * MathJax/jax/input/FastHTML/jax.js, which is loaded when needed).
+ *
+ * ---------------------------------------------------------------------
+ *
+ * Copyright (c) 2013-2015 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.OutputJax.FastHTML = MathJax.OutputJax({
+ id: "FastHTML",
+ version: "2.5.0",
+ directory: MathJax.OutputJax.directory + "/FastHTML",
+ extensionDir: MathJax.OutputJax.extensionDir + "/FastHTML",
+
+ config: {
+ scale: 100, minScaleAdjust: 50, // global math scaling factor, and minimum adjusted scale factor
+ mtextFontInherit: false, // to make <mtext> be in page font rather than MathJax font
+
+ linebreaks: {
+ automatic: false, // when false, only process linebreak="newline",
+ // when true, insert line breaks automatically in long expressions.
+
+ width: "container" // maximum width of a line for automatic line breaks (e.g. "30em").
+ // use "container" to compute size from containing element,
+ // use "nn% container" for a portion of the container,
+ // use "nn%" for a portion of the window size
+ }
+
+ }
+});
+
+if (!MathJax.Hub.config.delayJaxRegistration) {MathJax.OutputJax.FastHTML.Register("jax/mml")}
+
+MathJax.OutputJax.FastHTML.loadComplete("config.js");
diff --git a/unpacked/jax/output/FastHTML/jax.js b/unpacked/jax/output/FastHTML/jax.js
@@ -0,0 +1,1085 @@
+/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+
+/*************************************************************
+ *
+ * MathJax/jax/output/FastHTML/jax.js
+ *
+ * Implements the FastHTML OutputJax that displays mathematics
+ * using HTML to position the characters from math fonts
+ * in their proper locations.
+ *
+ * ---------------------------------------------------------------------
+ *
+ * Copyright (c) 2013-2015 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.
+ */
+
+
+(function (AJAX,HUB,HTML,FHTML) {
+ var MML;
+
+ var EVENT, TOUCH, HOVER; // filled in later
+
+ var FONTS = "'Times New Roman',Times,STIXGeneral,serif";
+ var STYLES = {
+ ".MJXf-script": {"font-size":".8em"},
+
+ ".MJXf-right": {
+ "-webkit-transform-origin":"right",
+ "-moz-transform-origin":"right",
+ "-ms-transform-origin":"right",
+ "-o-transform-origin":"right",
+ "transform-origin":"right"
+ },
+
+ ".MJXf-bold": {"font-weight":"bold"},
+ ".MJXf-italic": {"font-style":"italic"},
+ ".MJXf-scr": {"font-family":"MathJax_Script,"+FONTS},
+ ".MJXf-frak": {"font-family":"MathJax_Fraktur,"+FONTS},
+ ".MJXf-sf": {"font-family":"MathJax_SansSerif,"+FONTS},
+ ".MJXf-cal": {"font-family":"MathJax_Caligraphic,"+FONTS},
+ ".MJXf-mono": {"font-family":"MathJax_Typewriter,"+FONTS},
+ ".MJXf-largeop": {"font-size":"150%"},
+ ".MJXf-largeop.MJXf-int": {"vertical-align":"-.2em"},
+
+ ".MJXf-math": {
+ "display": "inline-block",
+ "line-height": "1.2",
+ "text-indent": "0",
+ "font-family": FONTS,
+ "white-space":"nowrap",
+ "border-collapse":"collapse"
+ },
+ ".MJXf-display": {
+ "display": "block",
+ "text-align": "center",
+ "margin": "1em 0"
+ },
+ ".MJXf-math span": {"display": "inline-block"},
+ ".MJXf-box": {"display":"block!important", "text-align": "center"},
+ ".MJXf-box:after": {"content": '" "'}, // needed for when there is no DOCTYPE
+ ".MJXf-rule": {"display":"block!important", "margin-top":".1em"},
+ ".MJXf-char": {"display":"block!important"},
+
+ ".MJXf-mo": {"margin": "0 .15em"},
+
+ ".MJXf-mfrac": {"margin": "0 .125em", "vertical-align":".25em"},
+ ".MJXf-denom": {"display": "inline-table!important", "width":"100%"},
+ ".MJXf-denom > *": {"display": "table-row!important"},
+
+ ".MJXf-surd": {"vertical-align":"top"},
+ ".MJXf-surd > *": {"display":"block!important"},
+
+ ".MJXf-script-box > * ": {"display":"table!important", "height":"50%"},
+ ".MJXf-script-box > * > *": {"display":"table-cell!important","vertical-align":"top"},
+ ".MJXf-script-box > *:last-child > *": {"vertical-align":"bottom"},
+ ".MJXf-script-box > * > * > *": {"display":"block!important"},
+
+ ".MJXf-mphantom": {"visibility": "hidden"},
+
+ ".MJXf-munderover": {"display":"inline-table!important"},
+ ".MJXf-over": {"display":"inline-block!important","text-align":"center"},
+ ".MJXf-over > *": {"display":"block!important"},
+ ".MJXf-munderover > *": {"display":"table-row!important"},
+
+ ".MJXf-mtable": {"vertical-align":".25em", "margin":"0 .125em"},
+ ".MJXf-mtable > *": {"display":"inline-table!important", "vertical-align":"middle"},
+ ".MJXf-mtr": {"display":"table-row!important"},
+ ".MJXf-mtd": {"display":"table-cell!important","text-align":"center","padding":".5em 0 0 .5em"},
+ ".MJXf-mtr > .MJXf-mtd:first-child": {"padding-left":0},
+ ".MJXf-mtr:first-child > .MJXf-mtd": {"padding-top":0},
+ ".MJXf-mlabeledtr": {"display":"table-row!important"},
+ ".MJXf-mlabeledtr > .MJXf-mtd:first-child": {"padding-left":0},
+ ".MJXf-mlabeledtr:first-child > .MJXf-mtd": {"padding-top":0},
+
+ ".MJXf-merror": {
+ "background-color": "#FFFF88",
+ color: "#CC0000",
+ border: "1px solid #CC0000",
+ padding: "1px 3px",
+ "font-style": "normal",
+ "font-size": "90%"
+ }
+ };
+
+ (function () {
+ for (var i = 0; i < 10; i++) {
+ var scale = "scaleX(."+i+")";
+ STYLES[".MJXf-scale"+i] = {
+ "-webkit-transform":scale,
+ "-moz-transform":scale,
+ "-ms-transform":scale,
+ "-o-transform":scale,
+ "transform":scale
+ }
+ }
+ })();
+
+ var BIGDIMEN = 1000000;
+ var V = "V", H = "H";
+
+ FHTML.Augment({
+ settings: HUB.config.menuSettings,
+ config: {styles: STYLES},
+
+ hideProcessedMath: false, // use display:none until all math is processed
+
+ maxStretchyParts: 1000, // limit the number of parts allowed for
+ // stretchy operators. See issue 366.
+
+ Config: function () {
+ if (!this.require) {this.require = []}
+ this.SUPER(arguments).Config.call(this); var settings = this.settings;
+ if (settings.scale) {this.config.scale = settings.scale}
+ this.require.push(MathJax.OutputJax.extensionDir+"/MathEvents.js");
+ },
+
+ Startup: function () {
+ //
+ // Set up event handling
+ //
+ EVENT = MathJax.Extension.MathEvents.Event;
+ TOUCH = MathJax.Extension.MathEvents.Touch;
+ HOVER = MathJax.Extension.MathEvents.Hover;
+ this.ContextMenu = EVENT.ContextMenu;
+ this.Mousedown = EVENT.AltContextMenu;
+ this.Mouseover = HOVER.Mouseover;
+ this.Mouseout = HOVER.Mouseout;
+ this.Mousemove = HOVER.Mousemove;
+
+ //
+ // 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,["InitializeFHTML",this]);
+ },
+ InitializeFHTML: function () {
+ },
+
+ preTranslate: function (state) {
+ var scripts = state.jax[this.id], i, m = scripts.length,
+ script, prev, span, div, jax;
+ //
+ // Loop through the scripts
+ //
+ for (i = 0; i < m; i++) {
+ script = scripts[i]; if (!script.parentNode) continue;
+ //
+ // Remove any existing output
+ //
+ prev = script.previousSibling;
+ if (prev && String(prev.className).match(/^MathJax_FHTML(_Display)?( MathJax_Processing)?$/))
+ {prev.parentNode.removeChild(prev)}
+ //
+ // Add the span, and a div if in display mode,
+ // then set the role and mark it as being processed
+ //
+ jax = script.MathJax.elementJax; if (!jax) continue;
+ jax.FHTML = {display: (jax.root.Get("display") === "block")}
+ span = div = HTML.Element("span",{
+ className:"MathJax_FHTML", id:jax.inputID+"-Frame", isMathJax:true, jaxID:this.id,
+ oncontextmenu:EVENT.Menu, onmousedown: EVENT.Mousedown,
+ onmouseover:EVENT.Mouseover, onmouseout:EVENT.Mouseout, onmousemove:EVENT.Mousemove,
+ onclick:EVENT.Click, ondblclick:EVENT.DblClick
+ });
+ if (HUB.Browser.noContextMenu) {
+ span.ontouchstart = TOUCH.start;
+ span.ontouchend = TOUCH.end;
+ }
+ if (jax.FHTML.display) {
+ div = HTML.Element("div",{className:"MathJax_FHTML_Display"});
+ div.appendChild(span);
+ }
+ //
+ div.className += " MathJax_Processing";
+ script.parentNode.insertBefore(div,script);
+ }
+ },
+
+ Translate: function (script,state) {
+ if (!script.parentNode) return;
+
+ //
+ // Get the data about the math
+ //
+ var jax = script.MathJax.elementJax, math = jax.root,
+ span = document.getElementById(jax.inputID+"-Frame"),
+ div = (jax.FHTML.display ? span.parentNode : span);
+ //
+ // Typeset the math
+ //
+ this.initFHTML(math,span);
+// math.setTeXclass();
+ try {math.toFastHTML(span)} catch (err) {
+ if (err.restart) {while (span.firstChild) {span.removeChild(span.firstChild)}}
+ throw err;
+ }
+ //
+ // Put it in place, and remove the processing marker
+ //
+ div.className = div.className.split(/ /)[0];
+ //
+ // Check if we are hiding the math until more is processed
+ //
+ if (this.hideProcessedMath) {
+ //
+ // Hide the math and don't let its preview be removed
+ //
+ div.className += " MathJax_Processed";
+ if (script.MathJax.preview) {
+ jax.FHTML.preview = script.MathJax.preview;
+ delete script.MathJax.preview;
+ }
+ }
+ },
+
+ postTranslate: function (state) {
+ var scripts = state.jax[this.id];
+ if (!this.hideProcessedMath) return;
+ for (var i = 0, m = scripts.length; i < m; i++) {
+ var script = scripts[i];
+ if (script && script.MathJax.elementJax) {
+ //
+ // Remove the processed marker
+ //
+ script.previousSibling.className = script.previousSibling.className.split(/ /)[0];
+ var data = script.MathJax.elementJax.FHTML;
+ //
+ // Remove the preview, if any
+ //
+ if (data.preview) {
+ data.preview.innerHTML = "";
+ script.MathJax.preview = data.preview;
+ delete data.preview;
+ }
+ }
+ }
+ },
+
+ getJaxFromMath: function (math) {
+ if (math.parentNode.className === "MathJax_FHTML_Display") {math = math.parentNode}
+ do {math = math.nextSibling} while (math && math.nodeName.toLowerCase() !== "script");
+ return HUB.getJaxFor(math);
+ },
+ getHoverSpan: function (jax,math) {return jax.root.FHTMLspanElement()},
+ getHoverBBox: function (jax,span,math) {
+ var bbox = jax.root.FHTML, em = jax.FHTML.outerEm;
+ var BBOX = {w:bbox.w*em, h:bbox.h*em, d:bbox.d*em};
+ if (bbox.width) {BBOX.width = bbox.width}
+ return BBOX;
+ },
+
+ Zoom: function (jax,span,math,Mw,Mh) {
+ //
+ // Re-render at larger size
+ //
+ span.className = "MathJax";
+ this.idPostfix = "-zoom"; jax.root.toFHTML(span,span); this.idPostfix = "";
+ //
+ // Get height and width of zoomed math and original math
+ //
+ span.style.position = "absolute";
+ if (!width) {math.style.position = "absolute"}
+ var zW = span.offsetWidth, zH = span.offsetHeight,
+ mH = math.offsetHeight, mW = math.offsetWidth;
+ if (mW === 0) {mW = math.parentNode.offsetWidth}; // IE7 gets mW == 0?
+ span.style.position = math.style.position = "";
+ //
+ return {Y:-EVENT.getBBox(span).h, mW:mW, mH:mH, zW:zW, zH:zH};
+ },
+
+ initFHTML: function (math,span) {},
+
+ Remove: function (jax) {
+ var span = document.getElementById(jax.inputID+"-Frame");
+ if (span) {
+ if (jax.FHTML.display) {span = span.parentNode}
+ span.parentNode.removeChild(span);
+ }
+ delete jax.FHTML;
+ },
+
+ ID: 0, idPostfix: "",
+ GetID: function () {this.ID++; return this.ID},
+
+ VARIANT: {
+ "bold": "MJXf-bold",
+ "italic": "MJXf-italic",
+ "bold-italic": "MJXf-bold MJXf-italic",
+ "script": "MJXf-scr",
+ "bold-script": "MJXf-scr MJXf-bold",
+ "fraktur": "MJXf-frak",
+ "bold-fraktur": "MJXf-frak MJXf-bold",
+ "monospace": "MJXf-mono",
+ "sans-serif": "MJXf-sf",
+ "-tex-caligraphic": "MJXf-cal"
+ },
+ MATHSPACE: {
+ veryverythinmathspace: 1/18,
+ verythinmathspace: 2/18,
+ thinmathspace: 3/18,
+ mediummathspace: 4/18,
+ thickmathspace: 5/18,
+ verythickmathspace: 6/18,
+ veryverythickmathspace: 7/18,
+ negativeveryverythinmathspace: -1/18,
+ negativeverythinmathspace: -2/18,
+ negativethinmathspace: -3/18,
+ negativemediummathspace: -4/18,
+ negativethickmathspace: -5/18,
+ negativeverythickmathspace: -6/18,
+ negativeveryverythickmathspace: -7/18,
+
+ thin: .08,
+ medium: .1,
+ thick: .15,
+
+ infinity: BIGDIMEN
+ },
+ TeX: {
+ x_height: .430554
+ },
+ pxPerInch: 72,
+ em: 16,
+
+ // ### FIXME: add more here
+
+ DELIMITERS: {
+ "(": {dir:V},
+ "{": {dir:V, w:.58},
+ "[": {dir:V},
+ "|": {dir:V, w:.275},
+ ")": {dir:V},
+ "}": {dir:V, w:.58},
+ "]": {dir:V},
+ "/": {dir:V},
+ "\\": {dir:V},
+ "\u2223": {dir:V, w:.275},
+ "\u2225": {dir:V, w:.55},
+ "\u230A": {dir:V, w:.5},
+ "\u230B": {dir:V, w:.5},
+ "\u2308": {dir:V, w:.5},
+ "\u2309": {dir:V, w:.5},
+ "\u27E8": {dir:V, w:.5},
+ "\u27E9": {dir:V, w:.5},
+ "\u2191": {dir:V, w:.65},
+ "\u2193": {dir:V, w:.65},
+ "\u21D1": {dir:V, w:.75},
+ "\u21D3": {dir:V, w:.75},
+ "\u2195": {dir:V, w:.65},
+ "\u21D5": {dir:V, w:.75},
+ "\u27EE": {dir:V, w:.275},
+ "\u27EF": {dir:V, w:.275},
+ "\u23B0": {dir:V, w:.6},
+ "\u23B1": {dir:V, w:.6}
+ },
+
+ REMAPACCENT: {
+ "\u20D7":"\u2192", // vector arrow
+ "'": "\u02CB",
+ "`": "\u02CA",
+ ".": "\u02D9",
+ "^": "\u02C6",
+ "-": "\u02C9",
+ "~": "\u02DC",
+ "\u00AF": "\u02C9", // macron
+ "\u00B0": "\u02DA", // degree sign
+ "\u00B4": "\u02CA", // acute accent
+ "\u0300": "\u02CB", // combining grave
+ "\u0301": "\u02CA", // combining acute
+ "\u0302": "\u02C6", // combining circumflex
+ "\u0303": "\u02DC", // combinig tilde
+ "\u0304": "\u02C9", // combining macron
+ "\u0305": "\u02C9", // combining overline
+ "\u0306": "\u02D8", // combining breve
+ "\u0307": "\u02D9", // combining dot
+ "\u0308": "\u00A8", // combining double dot
+ "\u030C": "\u02C7" // combining caron
+ },
+ REMAPACCENTUNDER: {
+ },
+
+ length2em: function (length,size) {
+ if (typeof(length) !== "string") {length = length.toString()}
+ if (length === "") {return ""}
+ if (length === MML.SIZE.NORMAL) {return 1}
+ if (length === MML.SIZE.BIG) {return 2}
+ if (length === MML.SIZE.SMALL) {return .71}
+ if (this.MATHSPACE[length]) {return this.MATHSPACE[length]}
+ var match = length.match(/^\s*([-+]?(?:\.\d+|\d+(?:\.\d*)?))?(pt|em|ex|mu|px|pc|in|mm|cm|%)?/);
+ var m = parseFloat(match[1]||"1"), unit = match[2];
+ if (size == null) {size = 1}
+ if (unit === "em") {return m}
+ if (unit === "ex") {return m * this.TeX.x_height}
+ if (unit === "%") {return m / 100 * size}
+ if (unit === "px") {return m / this.em}
+ if (unit === "pt") {return m / 10} // 10 pt to an em
+ if (unit === "pc") {return m * 1.2} // 12 pt to a pc
+ if (unit === "in") {return m * this.pxPerInch / this.em}
+ if (unit === "cm") {return m * this.pxPerInch / this.em / 2.54} // 2.54 cm to an inch
+ if (unit === "mm") {return m * this.pxPerInch / this.em / 25.4} // 10 mm to a cm
+ if (unit === "mu") {return m / 18} // 18mu to an em for the scriptlevel
+ return m*size; // relative to given size (or 1em as default)
+ },
+
+ Em: function (m) {
+ if (Math.abs(m) < .001) return "0em";
+ return (m.toFixed(3).replace(/\.?0+$/,""))+"em";
+ },
+
+ arrayEntry: function (a,i) {return a[Math.max(0,Math.min(i,a.length-1))]}
+
+ });
+
+ MathJax.Hub.Register.StartupHook("mml Jax Ready",function () {
+ MML = MathJax.ElementJax.mml;
+
+ MML.mbase.Augment({
+ toFastHTML: function (span,options) {
+ return this.FHTMLdefaultSpan(span,options);
+ },
+
+ FHTMLdefaultSpan: function (span,options) {
+ if (!options) options = {};
+ span = this.FHTMLcreateSpan(span);
+ this.FHTMLhandleStyle(span);
+ this.FHTMLhandleColor(span);
+ if (this.isToken) this.FHTMLhandleToken(span);
+ for (var i = 0, m = this.data.length; i < m; i++) this.FHTMLaddChild(span,i,options);
+ return span;
+ },
+ FHTMLaddChild: function (span,i,options) {
+ var child = this.data[i];
+ if (child) {
+ if (options.childSpans)
+ span = HTML.addElement(span,"span",{className:options.className});
+ child.toFastHTML(span);
+ if (!options.noBBox) {
+ this.FHTML.w += child.FHTML.w + child.FHTML.l + child.FHTML.r;
+ if (child.FHTML.h > this.FHTML.h) this.FHTML.h = child.FHTML.h;
+ if (child.FHTML.d > this.FHTML.d) this.FHTML.d = child.FHTML.d;
+ if (child.FHTML.t > this.FHTML.t) this.FHTML.t = child.FHTML.t;
+ if (child.FHTML.b > this.FHTML.b) this.FHTML.b = child.FHTML.b;
+ }
+ } else if (options.forceChild) {HTML.addElement(span,"span")}
+ },
+ FHTMLstretchChild: function (i,H,D) {
+ var data = this.data[i];
+ if (data && data.FHTMLcanStretch("Vertical",H,D)) {
+ var bbox = this.FHTML, dbox = data.FHTML, w = dbox.w;
+ data.FHTMLstretchV(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;
+ }
+ },
+
+ FHTMLcreateSpan: function (span) {
+ if (!this.FHTML) this.FHTML = {};
+ this.FHTML = {w:0, h:0, d:0, l:0, r:0, t:0, b:0};
+ if (this.inferred) return span;
+ // ### FIXME: This is a hack to handle the different spacing of the
+ // ### integral sign in Times compared to CM fonts
+ if (this.type === "mo" && this.data.join("") === "\u222B") {FHTML.lastIsInt = true}
+ else if (this.type !== "mspace" || this.width !== "negativethinmathspace") {FHTML.lastIsInt = false}
+ // ###
+ if (!this.FHTMLspanID) {this.FHTMLspanID = FHTML.GetID()};
+ var id = (this.id || "MJXf-Span-"+this.FHTMLspanID);
+ return HTML.addElement(span,"span",{className:"MJXf-"+this.type, id:id});
+ },
+ FHTMLspanElement: function () {
+ if (!this.FHTMLspanID) {return null}
+ return document.getElementById(this.id||"MJXf-Span-"+this.FHTMLspanID);
+ },
+
+ FHTMLhandleToken: function (span) {
+ var values = this.getValues("mathvariant");
+ if (values.mathvariant !== MML.VARIANT.NORMAL) {
+ span.className += " "+FHTML.VARIANT[values.mathvariant];
+ }
+ },
+
+ FHTMLhandleStyle: function (span) {
+ if (this.style) span.style.cssText = this.style;
+ },
+
+ FHTMLhandleColor: function (span) {
+ if (this.mathcolor) {span.style.color = this.mathcolor}
+ if (this.mathbackground) {span.style.backgroundColor = this.mathbackground}
+ },
+
+ FHTMLhandleScriptlevel: function (span) {
+ // ### FIXME: Need to prevent getting too small
+ // ### and should keep track of scaling so it can be compensated for
+ var level = this.Get("scriptlevel");
+ if (level) span.className += " MJXf-script";
+ },
+
+ FHTMLhandleText: function (span,text) {
+ var c, n;
+ var H = 0, D = 0, W = 0;
+ for (var i = 0, m = text.length; i < m; i++) {
+ n = text.charCodeAt(i); c = text.charAt(i);
+ if (n >= 0xD800 && n < 0xDBFF) {
+ i++; n = (((n-0xD800)<<10)+(text.charCodeAt(i)-0xDC00))+0x10000;
+ }
+ var h = .7, d = .22, w = .5;
+ if (n < 127) {
+ if (c.match(/[A-Za-ehik-or-xz0-9]/)) d = 0;
+ if (c.match(/[A-HK-Z]/)) {w = .67} else if (c.match(/[IJ]/)) {w = .36}
+ if (c.match(/[acegm-su-z]/)) {h = .45} else if (c.match(/[ij]/)) {h = .75}
+ if (c.match(/[ijlt]/)) w = .28;
+ }
+ if (FHTML.DELIMITERS[c]) {w = FHTML.DELIMITERS[c].w || .4}
+ // ### FIXME: handle Greek
+ // ### Combining diacriticals (all sets), spacing modifiers
+ // ### arrows (all sets), widths of braces
+ if (h > H) H = h; if (d > D) D = d; W += w;
+ }
+ if (!this.CHML) this.FHTML = {};
+ this.FHTML = {h:.9, d:.3, w:W, l:0, r:0, t:H, b:D};
+ HTML.addText(span,text);
+ },
+
+ FHTMLbboxFor: function (n) {
+ if (this.data[n] && this.data[n].FHTML) return this.data[n].FHTML;
+ return {w:0, h:0, d:0, l:0, r:0, t:0, b:0};
+ },
+
+ FHTMLcanStretch: function (direction,H,D) {
+ if (this.isEmbellished()) {
+ var core = this.Core();
+ if (core && core !== this) {return core.FHTMLcanStretch(direction,H,D)}
+ }
+ return false;
+ },
+ FHTMLstretchV: function (h,d) {},
+ FHTMLstretchH: function (w) {},
+
+ CoreParent: function () {
+ var parent = this;
+ while (parent && parent.isEmbellished() &&
+ parent.CoreMO() === this && !parent.isa(MML.math)) {parent = parent.Parent()}
+ return parent;
+ },
+ CoreText: function (parent) {
+ if (!parent) {return ""}
+ if (parent.isEmbellished()) {return parent.CoreMO().data.join("")}
+ while ((parent.isa(MML.mrow) || parent.isa(MML.TeXAtom) ||
+ parent.isa(MML.mstyle) || parent.isa(MML.mphantom)) &&
+ parent.data.length === 1 && parent.data[0]) {parent = parent.data[0]}
+ if (!parent.isToken) {return ""} else {return parent.data.join("")}
+ }
+
+ });
+
+ MML.chars.Augment({
+ toFastHTML: function (span) {
+ var text = this.toString().replace(/[\u2061-\u2064]/g,"");
+ this.FHTMLhandleText(span,text);
+ }
+ });
+ MML.entity.Augment({
+ toFastHTML: function (span) {
+ var text = this.toString().replace(/[\u2061-\u2064]/g,"");
+ this.FHTMLhandleText(span,text);
+ }
+ });
+
+ MML.math.Augment({
+ toFastHTML: function (span) {
+ span = this.FHTMLdefaultSpan(span);
+ if (this.Get("display") === "block") {span.className += " MJXf-display"}
+ return span;
+ }
+ });
+
+ MML.mo.Augment({
+ toFastHTML: function (span) {
+ span = this.FHTMLdefaultSpan(span);
+ this.FHTMLadjustAccent(span);
+ var values = this.getValues("lspace","rspace","scriptlevel","displaystyle","largeop");
+ if (values.scriptlevel === 0) {
+ this.FHTML.l = FHTML.length2em(values.lspace);
+ this.FHTML.r = FHTML.length2em(values.rspace);
+ span.style.marginLeft = FHTML.Em(this.FHTML.l);
+ span.style.marginRight = FHTML.Em(this.FHTML.r);
+ } else {
+ this.FHTML.l = .15;
+ this.FHTML.r = .1;
+ }
+ if (values.displaystyle && values.largeop) {
+ var box = HTML.Element("span",{className:"MJXf-largeop"});
+ box.appendChild(span.firstChild); span.appendChild(box);
+ this.FHTML.h *= 1.2; this.FHTML.d *= 1.2;
+ if (this.data.join("") === "\u222B") box.className += " MJXf-int";
+ }
+ // ### FIXME: Handle embellished op spacing
+ // ### FIXME: Remap minus signs
+ return span;
+ },
+ FHTMLadjustAccent: function (span) {
+ var parent = this.CoreParent();
+ if (parent && parent.isa(MML.munderover) &&
+ this.CoreText(parent.data[parent.base]).length === 1) {
+ var over = parent.data[parent.over], under = parent.data[parent.under];
+ var c = this.data.join(""), C;
+ if (over && this === over.CoreMO() && parent.Get("accent")) {C = FHTML.REMAPACCENT[c]}
+ else if (under && this === under.CoreMO() && parent.Get("accentunder")) {C = FHTML.REMAPACCENTUNDER[c]}
+ if (C) c = span.innerHTML = C;
+ if (c.match(/[\u02C6-\u02DC\u00A8]/)) {this.FHTML.acc = -.52}
+ else if (c === "\u2192") {this.FHTML.acc = -.15; this.FHTML.vec = true}
+ }
+ },
+ FHTMLcanStretch: function (direction,H,D) {
+ if (!this.Get("stretchy")) {return false}
+ var c = this.data.join("");
+ if (c.length > 1) {return false}
+ c = FHTML.DELIMITERS[c];
+ var stretch = (c && c.dir === direction.substr(0,1));
+ if (stretch) {
+ stretch = (this.FHTML.h !== H || this.FHTML.d !== D ||
+ (this.Get("minsize",true) || this.Get("maxsize",true)));
+ }
+ return stretch;
+ },
+ FHTMLstretchV: function (h,d) {
+ var span = this.FHTMLspanElement(), bbox = this.FHTML; //bbox.w = .4; // ## adjust width
+ var values = this.getValues("symmetric","maxsize","minsize");
+ if (values.symmetric) {H = 2*Math.max(h-.25,d+.25)} else {H = h + d}
+ values.maxsize = FHTML.length2em(values.maxsize,bbox.h+bbox.d);
+ values.minsize = FHTML.length2em(values.minsize,bbox.h+bbox.d);
+ H = Math.max(values.minsize,Math.min(values.maxsize,H));
+ var scale = H/(bbox.h+bbox.d-.3); // ### adjusted for extra tall bbox
+ var box = HTML.Element("span",{style:{"font-size":FHTML.Em(scale)}});
+ if (scale > 1.25) {
+ var sX = Math.ceil(1.25/scale * 10);
+ box.className = "MJXf-right MJXf-scale"+sX;
+ box.style.marginLeft = FHTML.Em(bbox.w*(sX/10-1)+.07);
+ bbox.w *= scale*sX/10;
+ }
+ box.appendChild(span.firstChild); span.appendChild(box);
+ if (values.symmetric) span.style.verticalAlign = FHTML.Em(.25*(1-scale));
+ }
+ });
+
+ MML.mspace.Augment({
+ toFastHTML: function (span) {
+ span = this.FHTMLdefaultSpan(span);
+ var values = this.getValues("height","depth","width");
+ var w = FHTML.length2em(values.width),
+ h = FHTML.length2em(values.height),
+ d = FHTML.length2em(values.depth);
+ var bbox = this.FHTML;
+ bbox.w = w; bbox.h = h; bbox.d = d;
+ if (w < 0) {
+ // ### FIXME: lastIsInt hack
+ if (!FHTML.lastIsInt) span.style.marginLeft = FHTML.Em(w);
+ w = 0;
+ }
+ span.style.width = FHTML.Em(w);
+ span.style.height = FHTML.Em(h+d);
+ if (d) span.style.verticalAlign = FHTML.Em(-d);
+ return span;
+ }
+ });
+
+ MML.mpadded.Augment({
+ toFastHTML: function (span) {
+ span = this.FHTMLdefaultSpan(span,{
+ childSpans:true, className:"MJXf-box", forceChild:true
+ });
+ var child = span.firstChild;
+ var values = this.getValues("width","height","depth","lspace","voffset");
+ var dimen = this.FHTMLdimen(values.lspace);
+ var T = 0, B = 0, L = dimen.len, R = -dimen.len, V = 0;
+ if (values.width !== "") {
+ dimen = this.FHTMLdimen(values.width,"w",0);
+ if (dimen.pm) {R += dimen.len} else {span.style.width = FHTML.Em(dimen.len)}
+ }
+ if (values.height !== "") {
+ dimen = this.FHTMLdimen(values.height,"h",0);
+ if (!dimen.pm) T += -this.FHTMLbboxFor(0).h;
+ T += dimen.len;
+ }
+ if (values.depth !== "") {
+ dimen = this.FHTMLdimen(values.depth,"d",0);
+ if (!dimen.pm) {B += -this.FHTMLbboxFor(0).d; V += -dimen.len}
+ B += dimen.len;
+ }
+ if (values.voffset !== "") {
+ dimen = this.FHTMLdimen(values.voffset);
+ T -= dimen.len; B += dimen.len;
+ V += dimen.len;
+ }
+ if (T) child.style.marginTop = FHTML.Em(T);
+ if (B) child.style.marginBottom = FHTML.Em(B);
+ if (L) child.style.marginLeft = FHTML.Em(L);
+ if (R) child.style.marginRight = FHTML.Em(R);
+ if (V) span.style.verticalAlign = FHTML.Em(V);
+ return span;
+ },
+ FHTMLdimen: function (length,d,m) {
+ if (m == null) {m = -BIGDIMEN}
+ length = String(length);
+ var match = length.match(/width|height|depth/);
+ var size = (match ? this.FHTML[match[0].charAt(0)] : (d ? this.FHTML[d] : 0));
+ return {len: FHTML.length2em(length,size)||0, pm: !!length.match(/^[-+]/)};
+ }
+ });
+
+ MML.munderover.Augment({
+ toFastHTML: function (span) {
+ var values = this.getValues("displaystyle","accent","accentunder","align");
+ if (!values.displaystyle && this.data[this.base] != null &&
+ this.data[this.base].CoreMO().Get("movablelimits")) {
+ span = MML.msubsup.prototype.toFastHTML.call(this,span);
+ //
+ // Change class to msubsup for CSS rules.
+ // ### FIXME: should this be handled via adding another class instead?
+ //
+ span.className = span.className.replace(/munderover/,"msubsup");
+ return span;
+ }
+ span = this.FHTMLdefaultSpan(span,{childSpans:true, className:"", noBBox:true});
+ var obox = this.FHTMLbboxFor(this.over),
+ ubox = this.FHTMLbboxFor(this.under),
+ bbox = this.FHTMLbboxFor(this.base),
+ BBOX = this.FHTML, acc = obox.acc;
+ if (this.data[this.over]) {
+ span.lastChild.firstChild.style.marginLeft = obox.l =
+ span.lastChild.firstChild.style.marginRight = obox.r = 0;
+ var over = HTML.Element("span",{},[["span",{className:"MJXf-over"}]]);
+ over.firstChild.appendChild(span.lastChild);
+ if (span.childNodes.length > (this.data[this.under] ? 1 : 0))
+ over.firstChild.appendChild(span.firstChild);
+ this.data[this.over].FHTMLhandleScriptlevel(over.firstChild.firstChild);
+ if (acc != null) {
+ if (obox.vec) {
+ over.firstChild.firstChild.firstChild.style.fontSize = "60%";
+ obox.h *= .6; obox.d *= .6; obox.w *= .6;
+ }
+ acc = acc - obox.d + .1; if (bbox.t != null) {acc += bbox.t - bbox.h}
+ over.firstChild.firstChild.style.marginBottom = FHTML.Em(acc);
+ }
+ if (span.firstChild) {span.insertBefore(over,span.firstChild)}
+ else {span.appendChild(over)}
+ }
+ if (this.data[this.under]) {
+ span.lastChild.firstChild.style.marginLeft = ubox.l =
+ span.lastChild.firstChild.marginRight = ubox.r = 0;
+ this.data[this.under].FHTMLhandleScriptlevel(span.lastChild);
+ }
+ BBOX.w = Math.max(.8*obox.w,.8*ubox.w,bbox.w);
+ BBOX.h = .8*(obox.h+obox.d+(acc||0)) + bbox.h;
+ BBOX.d = bbox.d + .8*(ubox.h+ubox.d);
+ return span;
+ }
+ });
+
+ MML.msubsup.Augment({
+ toFastHTML: function (span) {
+ span = this.FHTMLdefaultSpan(span,{noBBox:true});
+ if (!this.data[this.base]) {
+ if (span.firstChild) {span.insertBefore(HTML.Element("span"),span.firstChild)}
+ else {span.appendChild(HTML.Element("span"))}
+ }
+ var base = this.data[this.base], sub = this.data[this.sub], sup = this.data[this.sup];
+ if (!base) base = {bbox: {h:.8, d:.2}};
+ span.firstChild.style.marginRight = ".05em";
+ var h = Math.max(.4,base.FHTML.h-.4),
+ d = Math.max(.2,base.FHTML.d+.1);
+ var bbox = this.FHTML;
+ if (sup && sub) {
+ var box = HTML.Element("span",{className:"MJXf-script-box", style:{
+ height: FHTML.Em(h+sup.FHTML.h*.8 + d+sub.FHTML.d*.8),
+ "vertical-align": FHTML.Em(-d-sub.FHTML.d*.8)
+ }},[
+ ["span",{},[["span",{},[["span",{
+ style:{"margin-bottom":FHTML.Em(-(sup.FHTML.d-.05))}
+ }]]]]],
+ ["span",{},[["span",{},[["span",{
+ style:{"margin-top":FHTML.Em(-(sup.FHTML.h-.05))}
+ }]]]]]
+ ]);
+ sub.FHTMLhandleScriptlevel(box.firstChild);
+ sup.FHTMLhandleScriptlevel(box.lastChild);
+ box.firstChild.firstChild.firstChild.appendChild(span.lastChild);
+ box.lastChild.firstChild.firstChild.appendChild(span.lastChild);
+ span.appendChild(box);
+ bbox.h = Math.max(base.FHTML.h,sup.FHTML.h*.8+h);
+ bbox.d = Math.max(base.FHTML.d,sub.FHTML.d*.8+d);
+ bbox.w = base.FHTML.w + Math.max(sup.FHTML.w,sub.FHTML.w) + .07;
+ } else if (sup) {
+ span.lastChild.style.verticalAlign = FHTML.Em(h);
+ sup.FHTMLhandleScriptlevel(span.lastChild);
+ bbox.h = Math.max(base.FHTML.h,sup.FHTML.h*.8+h);
+ bbox.d = Math.max(base.FHTML.d,sup.FHTML.d*.8-h);
+ bbox.w = base.FHTML.w + sup.FHTML.w + .07;
+ } else if (sub) {
+ span.lastChild.style.verticalAlign = FHTML.Em(-d);
+ sub.FHTMLhandleScriptlevel(span.lastChild);
+ bbox.h = Math.max(base.FHTML.h,sub.FHTML.h*.8-d);
+ bbox.d = Math.max(base.FHTML.d,sub.FHTML.d*.8+d);
+ bbox.w = base.FHTML.w + sub.FHTML.w + .07;
+ }
+ return span;
+ }
+ });
+
+ MML.mfrac.Augment({
+ toFastHTML: function (span) {
+ span = this.FHTMLdefaultSpan(span,{
+ childSpans:true, className:"MJXf-box", forceChild:true, noBBox:true
+ });
+ var values = this.getValues("linethickness","displaystyle");
+ if (!values.displaystyle) {
+ if (this.data[0]) this.data[0].FHTMLhandleScriptlevel(span.firstChild);
+ if (this.data[1]) this.data[1].FHTMLhandleScriptlevel(span.lastChild);
+ }
+ var denom = HTML.Element("span",{className:"MJXf-box",style:{"margin-top":"-.8em"}},[
+ ["span",{className:"MJXf-denom"},[ // inline-table
+ ["span",{},[["span",{className:"MJXf-rule"}]]],["span"] // spans are table-row
+ ]]
+ ]);
+ denom.firstChild.lastChild.appendChild(span.lastChild);
+ span.appendChild(denom);
+ var nbox = this.FHTMLbboxFor(0), dbox = this.FHTMLbboxFor(1), bbox = this.FHTML;
+ bbox.w = Math.max(nbox.w,dbox.w) * .8;
+ bbox.h = nbox.h+nbox.d + .1 + .25;
+ bbox.d = dbox.h+dbox.d - .25;
+ bbox.l = bbox.r = .125;
+ values.linethickness = Math.max(0,FHTML.length2em(values.linethickness||"0",0));
+ if (values.linethickness) {
+ var rule = denom.firstChild.firstChild.firstChild;
+ var t = FHTML.Em(values.linethickness);
+ rule.style.borderTop = (values.linethickness < .15 ? "1px" : t)+" solid";
+ rule.style.margin = t+" 0";
+ t = values.linethickness;
+ denom.style.marginTop = FHTML.Em(3*t-.9);
+ span.style.verticalAlign = FHTML.Em(1.5*t + .1);
+ bbox.h += 1.5*t - .1; bbox.d += 1.5*t;
+ }
+ return span;
+ }
+ });
+
+ MML.msqrt.Augment({
+ toFastHTML: function (span) {
+ span = this.FHTMLdefaultSpan(span,{
+ childSpans:true, className:"MJXf-box", forceChild:true, noBBox:true
+ });
+ this.FHTMLlayoutRoot(span,span.firstChild);
+ return span;
+ },
+ FHTMLlayoutRoot: function (span,base) {
+ var bbox = this.FHTMLbboxFor(0);
+ var scale = Math.ceil((bbox.h+bbox.d+.14)*100), t = FHTML.Em(14/scale);
+ var surd = HTML.Element("span",{className:"MJXf-surd"},[
+ ["span",{style:{"font-size":scale+"%","margin-top":t}},["\u221A"]]
+ ]);
+ var root = HTML.Element("span",{className:"MJXf-root"},[
+ ["span",{className:"MJXf-rule",style:{"border-top":".08em solid"}}]
+ ]);
+ var W = (1.2/2.2)*scale/100; // width-of-surd = (height/H-to-W-ratio)
+ if (scale > 150) {
+ var sX = Math.ceil(150/scale * 10);
+ surd.firstChild.className = "MJXf-right MJXf-scale"+sX;
+ surd.firstChild.style.marginLeft = FHTML.Em(W*(sX/10-1)/scale*100);
+ W = W*sX/10;
+ root.firstChild.style.borderTopWidth = FHTML.Em(.08/Math.sqrt(sX/10));
+ }
+ root.appendChild(base);
+ span.appendChild(surd);
+ span.appendChild(root);
+ this.FHTML.h = bbox.h + .18; this.FHTML.d = bbox.d;
+ this.FHTML.w = bbox.w + W;
+ return span;
+ }
+ });
+
+ MML.mroot.Augment({
+ toFastHTML: function (span) {
+ span = this.FHTMLdefaultSpan(span,{
+ childSpans:true, className:"MJXf-box", forceChild:true, noBBox:true
+ });
+ var rbox = this.FHTMLbboxFor(1), root = span.removeChild(span.lastChild);
+ var sqrt = this.FHTMLlayoutRoot(HTML.Element("span"),span.firstChild);
+ root.className = "MJXf-script"; // ### FIXME: should be scriptscript
+ var scale = parseInt(sqrt.firstChild.firstChild.style.fontSize);
+ var v = .55*(scale/120) + rbox.d*.8, r = -.6*(scale/120);
+ if (scale > 150) {r *= .95*Math.ceil(150/scale*10)/10}
+ root.style.marginRight = FHTML.Em(r); root.style.verticalAlign = FHTML.Em(v);
+ if (-r > rbox.w*.8) root.style.marginLeft = FHTML.Em(-r-rbox.w*.8); // ### depends on rbox.w
+ span.appendChild(root); span.appendChild(sqrt);
+ this.FHTML.w += Math.max(0,rbox.w*.8+r);
+ this.FHTML.h = Math.max(this.FHTML.h,rbox.h*.8+v);
+ return span;
+ },
+ FHTMLlayoutRoot: MML.msqrt.prototype.FHTMLlayoutRoot
+ });
+
+ MML.mfenced.Augment({
+ toFastHTML: function (span) {
+ span = this.FHTMLcreateSpan(span);
+ this.FHTMLhandleStyle(span);
+ this.FHTMLhandleColor(span);
+ //
+ // Make row of open, data, sep, ... data, close
+ //
+ this.addFakeNodes();
+ this.FHTMLaddChild(span,"open",{});
+ for (var i = 0, m = this.data.length; i < m; i++) {
+ this.FHTMLaddChild(span,"sep"+i,{});
+ this.FHTMLaddChild(span,i,{});
+ }
+ this.FHTMLaddChild(span,"close",{});
+ //
+ // Check for streching the elements
+ //
+ var H = this.FHTML.h, D = this.FHTML.d;
+ this.FHTMLstretchChild("open",H,D);
+ for (i = 0, m = this.data.length; i < m; i++) {
+ this.FHTMLstretchChild("sep"+i,H,D);
+ this.FHTMLstretchChild(i,H,D);
+ }
+ this.FHTMLstretchChild("close",H,D);
+ return span;
+ }
+ });
+
+ MML.mrow.Augment({
+ toFastHTML: function (span) {
+ span = this.FHTMLdefaultSpan(span);
+ var H = this.FHTML.h, D = this.FHTML.d;
+ for (var i = 0, m = this.data.length; i < m; i++) this.FHTMLstretchChild(i,H,D);
+ return span;
+ }
+ });
+
+ MML.mstyle.Augment({
+ toFastHTML: function (span) {
+ span = this.FHTMLdefaultSpan(span);
+ this.FHTMLhandleScriptlevel(span);
+ return span;
+ }
+ });
+
+ MML.TeXAtom.Augment({
+ toFastHTML: function (span) {
+ span = this.FHTMLdefaultSpan(span);
+ // ### FIXME: handle TeX class?
+ span.className = "MJXf-mrow";
+ return span;
+ }
+ });
+
+ MML.mtable.Augment({
+ toFastHTML: function (span) {
+ span = this.FHTMLdefaultSpan(span,{noBBox:true});
+ var values = this.getValues("columnalign","rowalign","columnspacing","rowspacing",
+ "columnwidth","equalcolumns","equalrows",
+ "columnlines","rowlines","frame","framespacing",
+ "align","width");
+ var SPLIT = MathJax.Hub.SplitList, i, m, j, n;
+ var CSPACE = SPLIT(values.columnspacing),
+ RSPACE = SPLIT(values.rowspacing),
+ CALIGN = SPLIT(values.columnalign),
+ RALIGN = SPLIT(values.rowalign);
+ for (i = 0, m = CSPACE.length; i < m; i++) {CSPACE[i] = FHTML.length2em(CSPACE[i])}
+ for (i = 0, m = RSPACE.length; i < m; i++) {RSPACE[i] = FHTML.length2em(RSPACE[i])}
+
+ var table = HTML.Element("span");
+ while (span.firstChild) table.appendChild(span.firstChild);
+ span.appendChild(table);
+ var H = 0, W = 0;
+ for (i = 0, m = this.data.length; i < m; i++) {
+ var row = this.data[i];
+ if (row) {
+ var rspace = FHTML.arrayEntry(RSPACE,i-1), ralign = FHTML.arrayEntry(RALIGN,i);
+ var rbox = row.FHTML, rspan = row.FHTMLspanElement();
+ rspan.style.verticalAlign = ralign;
+ var k = (row.type === "mlabeledtr" ? 1 : 0);
+ for (j = 0, n = row.data.length; j < n-k; j++) {
+ var cell = row.data[j+k];
+ if (cell) {
+ var cspace = FHTML.arrayEntry(CSPACE,j-1), calign = FHTML.arrayEntry(CALIGN,j);
+ var cspan = cell.FHTMLspanElement();
+ if (j) {rbox.w += cspace; cspan.style.paddingLeft = FHTML.Em(cspace)}
+ if (i) cspan.style.paddingTop = FHTML.Em(rspace);
+ cspan.style.textAlign = calign;
+ }
+ }
+ H += rbox.h + rbox.d; if (i) {H += rspace}
+ if (rbox.w > W) W = rbox.w;
+ }
+ }
+ var bbox = this.FHTML;
+ bbox.w = W; bbox.h = H/2 + .25; bbox.d = H/2 - .25;
+ bbox.l = bbox.r = .125;
+ return span;
+ }
+ });
+ MML.mlabeledtr.Augment({
+ FHTMLdefaultSpan: function (span,options) {
+ if (!options) options = {};
+ span = this.FHTMLcreateSpan(span);
+ this.FHTMLhandleStyle(span);
+ this.FHTMLhandleColor(span);
+ if (this.isToken) this.FHTMLhandleToken(span);
+ // skip label for now
+ for (var i = 1, m = this.data.length; i < m; i++) this.FHTMLaddChild(span,i,options);
+ return span;
+ }
+ });
+
+ MML.semantics.Augment({
+ toFastHTML: function (span) {
+ span = this.FHTMLcreateSpan(span);
+ if (this.data[0]) {
+ this.data[0].toFastHTML(span);
+ MathJax.Hub.Insert(this.data[0].FHTML||{},this.FHTML);
+ }
+ return span;
+ }
+ });
+ MML.annotation.Augment({toFastHTML: function(span) {}});
+ MML["annotation-xml"].Augment({toFastHTML: function(span) {}});
+
+ //
+ // Loading isn't complete until the element jax is modified,
+ // but can't call loadComplete within the callback for "mml Jax Ready"
+ // (it would call FastHTML's Require routine, asking for the mml jax again)
+ // so wait until after the mml jax has finished processing.
+ //
+ // We also need to wait for the onload handler to run, since the loadComplete
+ // will call Config and Startup, which need to modify the body.
+ //
+ MathJax.Hub.Register.StartupHook("onLoad",function () {
+ setTimeout(MathJax.Callback(["loadComplete",FHTML,"jax.js"]),0);
+ });
+ });
+
+ MathJax.Hub.Register.StartupHook("End Cookie", function () {
+ if (HUB.config.menuSettings.zoom !== "None")
+ {AJAX.Require("[MathJax]/extensions/MathZoom.js")}
+ });
+
+})(MathJax.Ajax,MathJax.Hub,MathJax.HTML,MathJax.OutputJax.FastHTML);