Fix conflicts with develop.

This commit is contained in:
Davide P. Cervone 2016-07-06 14:20:49 -04:00
commit 189239a9eb
22 changed files with 290 additions and 222 deletions

View File

@ -659,6 +659,8 @@ MathJax.cdnFileVersions = {}; // can be used to specify revisions for individua
var PATH = {}; var PATH = {};
PATH[BASENAME] = ""; // empty path gets the root URL PATH[BASENAME] = ""; // empty path gets the root URL
PATH.Contrib = (String(location.protocol).match(/^https?:/) ? "" : "http:") +
"//cdn.mathjax.org/mathjax/contrib"; // the third-party extensions
BASE.Ajax = { BASE.Ajax = {
loaded: {}, // files already loaded loaded: {}, // files already loaded

View File

@ -115,7 +115,8 @@
while (state.i < m) { while (state.i < m) {
jax = state.jax[state.i]; jax = state.jax[state.i];
frame = document.getElementById(jax.inputID+"-Frame"); frame = document.getElementById(jax.inputID+"-Frame");
if (jax.outputJax !== "NativeMML" && frame && !frame.getAttribute("data-mathml")) { if (jax.outputJax !== "NativeMML" && jax.outputJax !== "PlainSource" &&
frame && !frame.getAttribute("data-mathml")) {
try { try {
mml = jax.root.toMathML("").replace(/\n */g,"").replace(/<!--.*?-->/g,""); mml = jax.root.toMathML("").replace(/\n */g,"").replace(/<!--.*?-->/g,"");
} catch (err) { } catch (err) {

View File

@ -41,42 +41,9 @@ MathJax.Extension["HTML-CSS/handle-floats"] = {
}; };
// //
// Make the display DIV be a table-cell // This file is now obsolete, since the HTML-CSS output already handles
// Use padding to get the separation, since table cells don't do margin // floating elements properly.
// Make the width large (it will shrink to fit the remaining room)
// //
MathJax.Hub.Config({
"HTML-CSS": {
styles: {
".MathJax_Display": {
display: "table-cell",
padding: "1em 0 ! important",
width: (MathJax.Hub.Browser.isMSIE && (document.documentMode||0) < 8 ? "100%" : "1000em")
}
}
}
});
//
// Two consecutive equations would end up side-by-side, so force a separator
// (Needed by IE8, IE9, and Firefox, at least).
//
MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
var HTMLCSS = MathJax.OutputJax["HTML-CSS"],
TRANSLATE = HTMLCSS.Translate;
HTMLCSS.Augment({
Translate: function (script,state) {
TRANSLATE.apply(this,arguments);
if (script.MathJax.elementJax.HTMLCSS.display) {
var next = script.nextSibling;
if (!next || next.className !== "MathJax_MSIE_Separator") {
var span = HTMLCSS.Element("span",{className:"MathJax_MSIE_Separator"});
script.parentNode.insertBefore(span,next);
}
}
}
});
MathJax.Hub.Startup.signal.Post("HTML-CSS handle-floats Ready");
});
MathJax.Hub.Startup.signal.Post("HTML-CSS handle-floats Ready");
MathJax.Ajax.loadComplete("[MathJax]/extensions/HTML-CSS/handle-floats.js"); MathJax.Ajax.loadComplete("[MathJax]/extensions/HTML-CSS/handle-floats.js");

View File

@ -1,106 +1,129 @@
/*************************************************************
*
* MathJax/extensions/TeX/mediawiki-texvc.js
*
* Implements macros used by mediawiki with their texvc preprocessor.
*
* ---------------------------------------------------------------------
*
* Copyright (c) 2015-2016 The MathJax Consortium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
MathJax.Extension["TeX/mediawiki-texvc"] = { MathJax.Extension["TeX/mediawiki-texvc"] = {
version: "2.6.0-beta.2" version: "2.6.1"
}; };
MathJax.Hub.Register.StartupHook("TeX Jax Ready", function () { MathJax.Hub.Register.StartupHook("TeX Jax Ready", function () {
MathJax.InputJax.TeX.Definitions.Add({ MathJax.InputJax.TeX.Definitions.Add({
macros: { macros: {
AA: ["Macro", "\u00c5"], AA: ["Macro", "\u00c5"],
alef: ["Macro", "\\aleph"], alef: ["Macro", "\\aleph"],
alefsym: ["Macro", "\\aleph"], alefsym: ["Macro", "\\aleph"],
Alpha: ["Macro", "\\mathrm{A}"], Alpha: ["Macro", "\\mathrm{A}"],
and: ["Macro", "\\land"], and: ["Macro", "\\land"],
ang: ["Macro", "\\angle"], ang: ["Macro", "\\angle"],
Bbb: ["Macro", "\\mathbb"], Bbb: ["Macro", "\\mathbb"],
Beta: ["Macro", "\\mathrm{B}"], Beta: ["Macro", "\\mathrm{B}"],
bold: ["Macro", "\\mathbf"], bold: ["Macro", "\\mathbf"],
bull: ["Macro", "\\bullet"], bull: ["Macro", "\\bullet"],
C: ["Macro", "\\mathbb{C}"], C: ["Macro", "\\mathbb{C}"],
Chi: ["Macro", "\\mathrm{X}"], Chi: ["Macro", "\\mathrm{X}"],
clubs: ["Macro", "\\clubsuit"], clubs: ["Macro", "\\clubsuit"],
cnums: ["Macro", "\\mathbb{C}"], cnums: ["Macro", "\\mathbb{C}"],
Complex: ["Macro", "\\mathbb{C}"], Complex: ["Macro", "\\mathbb{C}"],
coppa: ["Macro", "\u03D9"], coppa: ["Macro", "\u03D9"],
Coppa: ["Macro", "\u03D8"], Coppa: ["Macro", "\u03D8"],
Dagger: ["Macro", "\\ddagger"], Dagger: ["Macro", "\\ddagger"],
Digamma: ["Macro", "\u03DC"], Digamma: ["Macro", "\u03DC"],
darr: ["Macro", "\\downarrow"], darr: ["Macro", "\\downarrow"],
dArr: ["Macro", "\\Downarrow"], dArr: ["Macro", "\\Downarrow"],
Darr: ["Macro", "\\Downarrow"], Darr: ["Macro", "\\Downarrow"],
diamonds: ["Macro", "\\diamondsuit"], diamonds: ["Macro", "\\diamondsuit"],
empty: ["Macro", "\\emptyset"], empty: ["Macro", "\\emptyset"],
Epsilon: ["Macro", "\\mathrm{E}"], Epsilon: ["Macro", "\\mathrm{E}"],
Eta: ["Macro", "\\mathrm{H}"], Eta: ["Macro", "\\mathrm{H}"],
euro: ["Macro", "\u20AC"], euro: ["Macro", "\u20AC"],
exist: ["Macro", "\\exists"], exist: ["Macro", "\\exists"],
geneuro: ["Macro", "\u20AC"], geneuro: ["Macro", "\u20AC"],
geneuronarrow: ["Macro", "\u20AC"], geneuronarrow: ["Macro", "\u20AC"],
geneurowide: ["Macro", "\u20AC"], geneurowide: ["Macro", "\u20AC"],
H: ["Macro", "\\mathbb{H}"], H: ["Macro", "\\mathbb{H}"],
hAar: ["Macro", "\\Leftrightarrow"], hAar: ["Macro", "\\Leftrightarrow"],
harr: ["Macro", "\\leftrightarrow"], harr: ["Macro", "\\leftrightarrow"],
Harr: ["Macro", "\\Leftrightarrow"], Harr: ["Macro", "\\Leftrightarrow"],
hearts: ["Macro", "\\heartsuit"], hearts: ["Macro", "\\heartsuit"],
image: ["Macro", "\\Im"], image: ["Macro", "\\Im"],
infin: ["Macro", "\\infty"], infin: ["Macro", "\\infty"],
Iota: ["Macro", "\\mathrm{I}"], Iota: ["Macro", "\\mathrm{I}"],
isin: ["Macro", "\\in"], isin: ["Macro", "\\in"],
Kappa: ["Macro", "\\mathrm{K}"], Kappa: ["Macro", "\\mathrm{K}"],
koppa: ["Macro", "\u03DF"], koppa: ["Macro", "\u03DF"],
Koppa: ["Macro", "\u03DE"], Koppa: ["Macro", "\u03DE"],
lang: ["Macro", "\\langle"], lang: ["Macro", "\\langle"],
larr: ["Macro", "\\leftarrow"], larr: ["Macro", "\\leftarrow"],
Larr: ["Macro", "\\Leftarrow"], Larr: ["Macro", "\\Leftarrow"],
lArr: ["Macro", "\\Leftarrow"], lArr: ["Macro", "\\Leftarrow"],
lrarr: ["Macro", "\\leftrightarrow"], lrarr: ["Macro", "\\leftrightarrow"],
Lrarr: ["Macro", "\\Leftrightarrow"], Lrarr: ["Macro", "\\Leftrightarrow"],
lrArr: ["Macro", "\\Leftrightarrow"], lrArr: ["Macro", "\\Leftrightarrow"],
Mu: ["Macro", "\\mathrm{M}"], Mu: ["Macro", "\\mathrm{M}"],
N: ["Macro", "\\mathbb{N}"], N: ["Macro", "\\mathbb{N}"],
natnums: ["Macro", "\\mathbb{N}"], natnums: ["Macro", "\\mathbb{N}"],
Nu: ["Macro", "\\mathrm{N}"], Nu: ["Macro", "\\mathrm{N}"],
O: ["Macro", "\\emptyset"], O: ["Macro", "\\emptyset"],
officialeuro: ["Macro", "\u20AC"], officialeuro: ["Macro", "\u20AC"],
Omicron: ["Macro", "\\mathrm{O}"], Omicron: ["Macro", "\\mathrm{O}"],
or: ["Macro", "\\lor"], or: ["Macro", "\\lor"],
P: ["Macro", "\u00B6"], P: ["Macro", "\u00B6"],
pagecolor: ['Macro','',1], // ignore \pagecolor{} pagecolor: ['Macro','',1], // ignore \pagecolor{}
part: ["Macro", "\\partial"], part: ["Macro", "\\partial"],
plusmn: ["Macro", "\\pm"], plusmn: ["Macro", "\\pm"],
Q: ["Macro", "\\mathbb{Q}"], Q: ["Macro", "\\mathbb{Q}"],
R: ["Macro", "\\mathbb{R}"], R: ["Macro", "\\mathbb{R}"],
rang: ["Macro", "\\rangle"], rang: ["Macro", "\\rangle"],
rarr: ["Macro", "\\rightarrow"], rarr: ["Macro", "\\rightarrow"],
Rarr: ["Macro", "\\Rightarrow"], Rarr: ["Macro", "\\Rightarrow"],
rArr: ["Macro", "\\Rightarrow"], rArr: ["Macro", "\\Rightarrow"],
real: ["Macro", "\\Re"], real: ["Macro", "\\Re"],
reals: ["Macro", "\\mathbb{R}"], reals: ["Macro", "\\mathbb{R}"],
Reals: ["Macro", "\\mathbb{R}"], Reals: ["Macro", "\\mathbb{R}"],
Rho: ["Macro", "\\mathrm{P}"], Rho: ["Macro", "\\mathrm{P}"],
sdot: ["Macro", "\\cdot"], sdot: ["Macro", "\\cdot"],
sampi: ["Macro", "\u03E1"], sampi: ["Macro", "\u03E1"],
Sampi: ["Macro", "\u03E0"], Sampi: ["Macro", "\u03E0"],
sect: ["Macro", "\\S"], sect: ["Macro", "\\S"],
spades: ["Macro", "\\spadesuit"], spades: ["Macro", "\\spadesuit"],
stigma: ["Macro", "\u03DB"], stigma: ["Macro", "\u03DB"],
Stigma: ["Macro", "\u03DA"], Stigma: ["Macro", "\u03DA"],
sub: ["Macro", "\\subset"], sub: ["Macro", "\\subset"],
sube: ["Macro", "\\subseteq"], sube: ["Macro", "\\subseteq"],
supe: ["Macro", "\\supseteq"], supe: ["Macro", "\\supseteq"],
Tau: ["Macro", "\\mathrm{T}"], Tau: ["Macro", "\\mathrm{T}"],
textvisiblespace: ["Macro", "\u2423"], textvisiblespace: ["Macro", "\u2423"],
thetasym: ["Macro", "\\vartheta"], thetasym: ["Macro", "\\vartheta"],
uarr: ["Macro", "\\uparrow"], uarr: ["Macro", "\\uparrow"],
uArr: ["Macro", "\\Uparrow"], uArr: ["Macro", "\\Uparrow"],
Uarr: ["Macro", "\\Uparrow"], Uarr: ["Macro", "\\Uparrow"],
varcoppa: ["Macro", "\u03D9"], varcoppa: ["Macro", "\u03D9"],
varstigma: ["Macro", "\u03DB"], varstigma: ["Macro", "\u03DB"],
vline: ['Macro','\\smash{\\large\\lvert}',0], vline: ['Macro','\\smash{\\large\\lvert}',0],
weierp: ["Macro", "\\wp"], weierp: ["Macro", "\\wp"],
Z: ["Macro", "\\mathbb{Z}"], Z: ["Macro", "\\mathbb{Z}"],
Zeta: ["Macro", "\\mathrm{Z}"] Zeta: ["Macro", "\\mathrm{Z}"]
} }
}); });
}); });
MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/mediawiki-texvc.js"); MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/mediawiki-texvc.js");

View File

@ -207,11 +207,13 @@ MathJax.Extension.asciimath2jax = {
}, },
createPreview: function (mode,asciimath) { createPreview: function (mode,asciimath) {
var previewClass = MathJax.Hub.config.preRemoveClass;
var preview = this.config.preview; var preview = this.config.preview;
if (preview === "none") return; if (preview === "none") return;
if ((this.search.close.previousSibling||{}).className === previewClass) return;
if (preview === "AsciiMath") {preview = [this.filterPreview(asciimath)]} if (preview === "AsciiMath") {preview = [this.filterPreview(asciimath)]}
if (preview) { if (preview) {
preview = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass},preview); preview = MathJax.HTML.Element("span",{className:previewClass},preview);
this.insertNode(preview); this.insertNode(preview);
} }
}, },

View File

@ -73,10 +73,13 @@ MathJax.Extension.jsMath2jax = {
}, },
createPreview: function (node) { createPreview: function (node) {
var previewClass = MathJax.Hub.config.preRemoveClass;
var preview = this.config.preview; var preview = this.config.preview;
if (preview === "none") return;
if ((node.previousSibling||{}).className === previewClass) return;
if (preview === "TeX") {preview = [this.filterPreview(node.innerHTML)]} if (preview === "TeX") {preview = [this.filterPreview(node.innerHTML)]}
if (preview) { if (preview) {
preview = MathJax.HTML.Element("span",{className: MathJax.Hub.config.preRemoveClass},preview); preview = MathJax.HTML.Element("span",{className:previewClass},preview);
node.parentNode.insertBefore(preview,node); node.parentNode.insertBefore(preview,node);
} }
}, },

View File

@ -203,6 +203,8 @@ MathJax.Extension.mml2jax = {
var preview = this.config.preview; var preview = this.config.preview;
if (preview === "none") return; if (preview === "none") return;
var isNodePreview = false; var isNodePreview = false;
var previewClass = MathJax.Hub.config.preRemoveClass;
if ((script.previousSibling||{}).className === previewClass) return;
if (preview === "mathml") { if (preview === "mathml") {
isNodePreview = true; isNodePreview = true;
// mathml preview does not work with IE < 9, so fallback to alttext. // mathml preview does not work with IE < 9, so fallback to alttext.
@ -225,10 +227,10 @@ MathJax.Extension.mml2jax = {
if (preview) { if (preview) {
var span; var span;
if (isNodePreview) { if (isNodePreview) {
span = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass}); span = MathJax.HTML.Element("span",{className:previewClass});
span.appendChild(preview); span.appendChild(preview);
} else { } else {
span = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass},preview); span = MathJax.HTML.Element("span",{className:previewClass},preview);
} }
script.parentNode.insertBefore(span,script); script.parentNode.insertBefore(span,script);
} }

View File

@ -277,11 +277,13 @@ MathJax.Extension.tex2jax = {
}, },
createPreview: function (mode,tex) { createPreview: function (mode,tex) {
var previewClass = MathJax.Hub.config.preRemoveClass;
var preview = this.config.preview; var preview = this.config.preview;
if (preview === "none") return; if (preview === "none") return;
if ((this.search.close.previousSibling||{}).className === previewClass) return;
if (preview === "TeX") {preview = [this.filterPreview(tex)]} if (preview === "TeX") {preview = [this.filterPreview(tex)]}
if (preview) { if (preview) {
preview = MathJax.HTML.Element("span",{className:MathJax.Hub.config.preRemoveClass},preview); preview = MathJax.HTML.Element("span",{className:previewClass},preview);
this.insertNode(preview); this.insertNode(preview);
} }
}, },

View File

@ -142,8 +142,14 @@
value = this.filterAttribute(name,value); value = this.filterAttribute(name,value);
var defaults = (mml.type === "mstyle" ? MML.math.prototype.defaults : mml.defaults); var defaults = (mml.type === "mstyle" ? MML.math.prototype.defaults : mml.defaults);
if (value != null) { if (value != null) {
if (value.toLowerCase() === "true") {value = true} var val = value.toLowerCase();
else if (value.toLowerCase() === "false") {value = false} if (val === "true" || val === "false") {
if (typeof (defaults[name]) === "boolean" || defaults[name] === MML.INHERIT ||
(defaults[name] === MML.AUTO &&
(mml.defaultDef == null || typeof(mml.defaultDef[name]) === "boolean"))) {
value = (val === "true");
}
}
if (defaults[name] != null || MML.copyAttributes[name]) if (defaults[name] != null || MML.copyAttributes[name])
{mml[name] = value} else {mml.attr[name] = value} {mml[name] = value} else {mml.attr[name] = value}
mml.attrNames.push(name); mml.attrNames.push(name);

View File

@ -53,8 +53,10 @@
else if (top) { else if (top) {
this.data.push(item); this.data.push(item);
if (item.env) { if (item.env) {
for (var id in this.env) if (item.copyEnv !== false) {
{if (this.env.hasOwnProperty(id)) {item.env[id] = this.env[id]}} for (var id in this.env)
{if (this.env.hasOwnProperty(id)) {item.env[id] = this.env[id]}}
}
this.env = item.env; this.env = item.env;
} else {item.env = this.env} } else {item.env = this.env}
} }
@ -256,9 +258,9 @@
}); });
STACKITEM.array = STACKITEM.Subclass({ STACKITEM.array = STACKITEM.Subclass({
type: "array", isOpen: true, arraydef: {}, type: "array", isOpen: true, copyEnv: false, arraydef: {},
Init: function () { Init: function () {
this.table = []; this.row = []; this.env = {}; this.frame = []; this.hfill = []; this.table = []; this.row = []; this.frame = []; this.hfill = [];
this.SUPER(arguments).Init.apply(this,arguments); this.SUPER(arguments).Init.apply(this,arguments);
}, },
checkItem: function (item) { checkItem: function (item) {
@ -1335,9 +1337,11 @@
Middle: function (name) { Middle: function (name) {
var delim = this.GetDelimiter(name); var delim = this.GetDelimiter(name);
this.Push(MML.TeXAtom().With({texClass:MML.TEXCLASS.CLOSE}));
if (this.stack.Top().type !== "left") if (this.stack.Top().type !== "left")
{TEX.Error(["MisplacedMiddle","%1 must be within \\left and \\right",name])} {TEX.Error(["MisplacedMiddle","%1 must be within \\left and \\right",name])}
this.Push(MML.mo(delim).With({stretchy:true})); this.Push(MML.mo(delim).With({stretchy:true}));
this.Push(MML.TeXAtom().With({texClass:MML.TEXCLASS.OPEN}));
}, },
NamedFn: function (name,id) { NamedFn: function (name,id) {
@ -1433,6 +1437,8 @@
var def = {accent: true}; if (this.stack.env.font) {def.mathvariant = this.stack.env.font} var def = {accent: true}; if (this.stack.env.font) {def.mathvariant = this.stack.env.font}
var mml = this.mmlToken(MML.mo(MML.entity("#x"+accent)).With(def)); var mml = this.mmlToken(MML.mo(MML.entity("#x"+accent)).With(def));
mml.stretchy = (stretchy ? true : false); mml.stretchy = (stretchy ? true : false);
var mo = (c.isEmbellished() ? c.CoreMO() : c);
if (mo.isa(MML.mo)) mo.movablelimits = false;
this.Push(MML.TeXAtom(MML.munderover(c,null,mml).With({accent: true}))); this.Push(MML.TeXAtom(MML.munderover(c,null,mml).With({accent: true})));
}, },
@ -2211,9 +2217,9 @@
fenced: function (open,mml,close) { fenced: function (open,mml,close) {
var mrow = MML.mrow().With({open:open, close:close, texClass:MML.TEXCLASS.INNER}); var mrow = MML.mrow().With({open:open, close:close, texClass:MML.TEXCLASS.INNER});
mrow.Append( mrow.Append(
MML.mo(open).With({fence:true, stretchy:true, texClass:MML.TEXCLASS.OPEN}), MML.mo(open).With({fence:true, stretchy:true, symmetric:true, texClass:MML.TEXCLASS.OPEN}),
mml, mml,
MML.mo(close).With({fence:true, stretchy:true, texClass:MML.TEXCLASS.CLOSE}) MML.mo(close).With({fence:true, stretchy:true, symmetric:true, texClass:MML.TEXCLASS.CLOSE})
); );
return mrow; return mrow;
}, },

View File

@ -60,15 +60,15 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
var img = CHTML.addElement(node,"img",{ var img = CHTML.addElement(node,"img",{
isMathJax:true, src:values.src, alt:values.alt, title:values.alt isMathJax:true, src:values.src, alt:values.alt, title:values.alt
}); });
var w = bbox.img.img.width/CHTML.em, h = bbox.img.img.height/CHTML.em; var w = values.width, h = values.height;
if (values.width !== "") img.style.width = CHTML.Em(this.CHTMLlength2em(values.width,w)); var W = bbox.img.img.width/CHTML.em, H = bbox.img.img.height/CHTML.em;
if (values.height !== "") img.style.height = CHTML.Em(this.CHTMLlength2em(values.height,h)); var WW = W, HH = H;
// if (w !== "") {W = this.CHTMLlength2em(w,WW); H = (WW ? W/WW * HH : 0)}
// Warning: causes page reflows 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;
bbox.w = bbox.r = img.offsetWidth/CHTML.em; bbox.h = bbox.t = img.offsetHeight/CHTML.em; img.style.height = CHTML.Em(H); bbox.h = bbox.t = H;
if (values.valign) { if (values.valign) {
bbox.d = bbox.b = -this.CHTMLlength2em(values.valign,h); bbox.d = bbox.b = -this.CHTMLlength2em(values.valign,HH);
img.style.verticalAlign = CHTML.Em(-bbox.d); img.style.verticalAlign = CHTML.Em(-bbox.d);
bbox.h -= bbox.d; bbox.t = bbox.h; bbox.h -= bbox.d; bbox.t = bbox.h;
} }

View File

@ -154,8 +154,8 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
state.i++; state.w = 0; state.i++; state.w = 0;
sub = "presub"; sup = "presup"; sub = "presub"; sup = "presup";
} else { } else {
var sbox = this.CHTMLaddScript(sub,state); var sbox = this.CHTMLaddScript(sub,state,node);
var Sbox = this.CHTMLaddScript(sup,state); var Sbox = this.CHTMLaddScript(sup,state,node);
var w = Math.max((sbox ? sbox.rscale*sbox.w : 0),(Sbox ? Sbox.rscale*Sbox.w : 0)); var w = Math.max((sbox ? sbox.rscale*sbox.w : 0),(Sbox ? Sbox.rscale*Sbox.w : 0));
this.CHTMLpadScript(sub,w,sbox,state); this.CHTMLpadScript(sub,w,sbox,state);
this.CHTMLpadScript(sup,w,Sbox,state); this.CHTMLpadScript(sup,w,Sbox,state);
@ -172,12 +172,17 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
// and padding the box to account for any <none/> elements. // and padding the box to account for any <none/> elements.
// Return the bounding box for the script for later use. // Return the bounding box for the script for later use.
// //
CHTMLaddScript: function (type,state) { CHTMLaddScript: function (type,state,node) {
var BOX, BBOX, data = this.data[state.i]; var BOX, BBOX, data = this.data[state.i];
if (data && data.type !== "none" && data.type !== "mprescripts") { if (data && data.type !== "none" && data.type !== "mprescripts") {
BOX = state.BOX[type]; BOX = state.BOX[type];
if (!BOX) { if (!BOX) {
BOX = state.BOX[type] = CHTML.Element("mjx-"+type); //
// 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(); BBOX = state.BBOX[type] = CHTML.BBOX.empty();
if (state.w) { if (state.w) {
BOX.style.paddingLeft = CHTML.Em(state.w); BOX.style.paddingLeft = CHTML.Em(state.w);

View File

@ -187,8 +187,6 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
CALIGN = state.CALIGN, RALIGN = state.RALIGN, CALIGN = state.CALIGN, RALIGN = state.RALIGN,
RCALIGN = state.RCALIGN; RCALIGN = state.RCALIGN;
CSPACE[state.J] *= 2; RSPACE[ROWS.length-1] *= 2; // since halved below CSPACE[state.J] *= 2; RSPACE[ROWS.length-1] *= 2; // since halved below
var LH = CHTML.FONTDATA.lineH * values.useHeight,
LD = CHTML.FONTDATA.lineD * values.useHeight;
var T = "0", B, R, L, border, cbox, align; var T = "0", B, R, L, border, cbox, align;
if (values.fspace) T = CHTML.Em(state.FSPACE[1]); if (values.fspace) T = CHTML.Em(state.FSPACE[1]);
for (var i = 0, m = ROWS.length; i < m; i++) { for (var i = 0, m = ROWS.length; i < m; i++) {
@ -197,7 +195,7 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
// Space and borders between rows // Space and borders between rows
// //
B = RSPACE[i]/2; border = null; L = "0"; B = RSPACE[i]/2; border = null; L = "0";
if (RLINES[i] !== MML.LINES.NONE) { if (RLINES[i] !== MML.LINES.NONE && RLINES[i] !== "") {
border = state.t+" "+RLINES[i]; border = state.t+" "+RLINES[i];
B -= 1/CHTML.em/2; B -= 1/CHTML.em/2;
} }
@ -245,11 +243,12 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
); );
} }
// //
// Pad cells that are too short // Adjust height and depth of cells
// //
cell = row[j].firstChild.style; cell = row[j].firstChild.style;
if (cbox.h < LH) cell.marginTop = CHTML.Em(LH-cbox.h); var H = Math.max(1,cbox.h);
if (cbox.d < LD) cell.marginBottom = CHTML.Em(LD-cbox.d); if (H !== state.H[i]) cell.marginTop = CHTML.Em(state.H[i]-H);
if (cbox.d < state.D[i]) cell.marginBottom = CHTML.Em(state.D[i]-cbox.d);
} }
T = B; T = B;
} }
@ -494,7 +493,7 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
if (LABELS[i] && this.data[i].data[0]) { if (LABELS[i] && this.data[i].data[0]) {
labels.appendChild(LABELS[i]); labels.appendChild(LABELS[i]);
var lbox = this.data[i].data[0].CHTML; var lbox = this.data[i].data[0].CHTML;
T += h - lbox.h; T += h - Math.max(1,lbox.h);
if (T) LABELS[i].style.marginTop = CHTML.Em(T); if (T) LABELS[i].style.marginTop = CHTML.Em(T);
T = d - lbox.d; T = d - lbox.d;
} else { } else {
@ -563,6 +562,7 @@ MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function () {
MML.mtd.Augment({ MML.mtd.Augment({
toCommonHTML: function (node,options) { toCommonHTML: function (node,options) {
node = this.CHTMLdefaultNode(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 // Determine if this is stretchy or not
// //

View File

@ -71,13 +71,23 @@
".mjx-chtml[tabindex]:focus, body :focus .mjx-chtml[tabindex]": { ".mjx-chtml[tabindex]:focus, body :focus .mjx-chtml[tabindex]": {
display: "inline-table" // see issues #1282 and #1338 display: "inline-table" // see issues #1282 and #1338
}, },
".mjx-full-width": {
display: "table-cell",
width: "10000em"
},
".mjx-math": { ".mjx-math": {
"display": "inline-block", "display": "inline-block",
"border-collapse": "separate", "border-collapse": "separate",
"border-spacing": 0, "border-spacing": 0,
}, },
".mjx-math *": {display:"inline-block", "text-align":"left"}, ".mjx-math *": {
display:"inline-block",
"-webkit-box-sizing": "content-box!important",
"-moz-box-sizing": "content-box!important",
"box-sizing": "content-box!important", // override bootstrap settings
"text-align":"left"
},
".mjx-numerator": {display:"block", "text-align":"center"}, ".mjx-numerator": {display:"block", "text-align":"center"},
".mjx-denominator": {display:"block", "text-align":"center"}, ".mjx-denominator": {display:"block", "text-align":"center"},
@ -170,6 +180,12 @@
position: "absolute", position: "absolute",
width:"1px", height:"60ex" width:"1px", height:"60ex"
}, },
".mjx-line-box-test": {
display: "table-cell!important",
width: "10000em!important",
"min-width":0, "max-width":"none",
padding:0, border:0, margin:0
},
"#MathJax_CHTML_Tooltip": { "#MathJax_CHTML_Tooltip": {
"background-color": "InfoBackground", color: "InfoText", "background-color": "InfoBackground", color: "InfoText",
@ -232,6 +248,11 @@
// //
this.TestSpan = CHTML.Element("mjx-test",{style:{left:"1em"}},[["mjx-ex-box-test"]]); this.TestSpan = CHTML.Element("mjx-test",{style:{left:"1em"}},[["mjx-ex-box-test"]]);
//
// Used in preTranslate to get linebreak width
//
this.linebreakSpan = HTML.Element("span",{className:"mjx-line-box-test"});
// //
// Set up styles and preload web fonts // Set up styles and preload web fonts
// //
@ -260,9 +281,11 @@
// Get the default sizes (need styles in place to do this) // Get the default sizes (need styles in place to do this)
// //
document.body.appendChild(this.TestSpan); document.body.appendChild(this.TestSpan);
document.body.appendChild(this.linebreakSpan);
this.defaultEm = this.getFontSize(this.TestSpan); this.defaultEm = this.getFontSize(this.TestSpan);
this.defaultEx = this.TestSpan.firstChild.offsetHeight/60; this.defaultEx = this.TestSpan.firstChild.offsetHeight/60;
this.defaultWidth = this.TestSpan.offsetWidth; this.defaultWidth = this.linebreakSpan.offsetWidth;
document.body.removeChild(this.linebreakSpan);
document.body.removeChild(this.TestSpan); document.body.removeChild(this.TestSpan);
}, },
getFontSize: (window.getComputedStyle ? getFontSize: (window.getComputedStyle ?
@ -336,34 +359,29 @@
ucMatch: HTML.ucMatch, ucMatch: HTML.ucMatch,
setScript: HTML.setScript, setScript: HTML.setScript,
getNodesByClass: (document.getElementsByClassName ? //
function (node,type) {return node.getElementsByClassName(type)} : // Look through the direct children of a node for one with the given
function (node,type) { // type (but if the node has intervening containers for its children,
var NODES = []; // step into them; note that elements corresponding to MathML nodes
var nodes = node.getElementsByTagName("span"); // will have id's so we don't step into them).
var name = RegExp("\\b"+type+"\\b"); //
for (var i = 0, m = nodes.length; i < m; i++) { // This is used by munderover and msubsup to locate their child elements
if (name.test(nodes[i].className)) NODES.push = nodes[i]; // when they are part of an embellished operator that is being stretched.
} // We don't use querySelector because we want to find only the direct child
return NODES; // nodes, not nodes that might be nested deeper in the tree (see issue #1447).
} //
),
getNode: function (node,type) { getNode: function (node,type) {
var nodes = this.getNodesByClass(node,type); while (node && node.childNodes.length === 1 && node.firstChild.id == null)
if (nodes.length === 1) return nodes[0]; node = node.firstChild;
var closest = nodes[0], N = this.getNodeDepth(node,closest); if (node) {
for (var i = 1, m = nodes.length; i < m; i++) { var name = RegExp("\\b"+type+"\\b");
var n = this.getNodeDepth(node,nodes[i]); for (var i = 0, m = node.childNodes.length; i < m; i++) {
if (n < N) {closest = nodes[i]; N = n} var child = node.childNodes[i];
if (name.test(child.className)) return child;
}
} }
return closest; return null;
}, },
getNodeDepth: function (parent,node) {
var n = 0;
while (node && node !== parent) {node = node.parentNode; n++}
return n;
},
/********************************************/ /********************************************/
@ -422,6 +440,7 @@
// //
// Add test nodes for determineing scales and linebreak widths // Add test nodes for determineing scales and linebreak widths
// //
script.parentNode.insertBefore(this.linebreakSpan.cloneNode(true),script);
script.parentNode.insertBefore(this.TestSpan.cloneNode(true),script); script.parentNode.insertBefore(this.TestSpan.cloneNode(true),script);
} }
// //
@ -434,12 +453,10 @@
jax = script.MathJax.elementJax; if (!jax) continue; jax = script.MathJax.elementJax; if (!jax) continue;
em = CHTML.getFontSize(test); em = CHTML.getFontSize(test);
ex = test.firstChild.offsetHeight/60; ex = test.firstChild.offsetHeight/60;
if (ex === 0 || ex === "NaN") ex = this.defaultEx cwidth = Math.max(0,test.previousSibling.offsetWidth-2);
node = test; if (ex === 0 || ex === "NaN") {
while (node) { ex = this.defaultEx;
cwidth = node.offsetWidth; if (cwidth) break; cwidth = this.defaultWidth;
cwidth = CHTML.getMaxWidth(node); if (cwidth) break;
node = node.parentNode;
} }
if (relwidth) maxwidth = cwidth; if (relwidth) maxwidth = cwidth;
scale = (this.config.matchFontHeight ? ex/this.TEX.x_height/em : 1); scale = (this.config.matchFontHeight ? ex/this.TEX.x_height/em : 1);
@ -455,7 +472,9 @@
for (i = 0; i < m; i++) { for (i = 0; i < m; i++) {
script = scripts[i]; if (!script.parentNode) continue; script = scripts[i]; if (!script.parentNode) continue;
test = scripts[i].previousSibling; test = scripts[i].previousSibling;
span = test.previousSibling;
jax = scripts[i].MathJax.elementJax; if (!jax) continue; jax = scripts[i].MathJax.elementJax; if (!jax) continue;
span.parentNode.removeChild(span);
test.parentNode.removeChild(test); test.parentNode.removeChild(test);
} }
state.CHTMLeqn = state.CHTMLlast = 0; state.CHTMLi = -1; state.CHTMLeqn = state.CHTMLlast = 0; state.CHTMLi = -1;
@ -1307,6 +1326,7 @@
updateFrom: function (cbox) { updateFrom: function (cbox) {
this.h = cbox.h; this.d = cbox.d; this.w = cbox.w; this.r = cbox.r; this.l = cbox.l; this.h = cbox.h; this.d = cbox.d; this.w = cbox.w; this.r = cbox.r; this.l = cbox.l;
this.t = cbox.t; this.b = cbox.b; this.t = cbox.t; this.b = cbox.b;
if (cbox.pwidth) this.pwidth = cbox.pwidth;
if (cbox.D) this.D = cbox.D; else delete this.D; if (cbox.D) this.D = cbox.D; else delete this.D;
}, },
adjust: function (m,x,X,M) { adjust: function (m,x,X,M) {
@ -1324,7 +1344,8 @@
empty: function (bbox) { empty: function (bbox) {
if (!bbox) bbox = CHTML.BBOX.zero(); if (!bbox) bbox = CHTML.BBOX.zero();
bbox.h = bbox.d = bbox.r = bbox.t = bbox.b = -BIGDIMEN; bbox.h = bbox.d = bbox.r = bbox.t = bbox.b = -BIGDIMEN;
bbox.w = 0; bbox.l = BIGDIMEN; bbox.w = 0; bbox.l = BIGDIMEN;
delete bbox.pwidth;
return bbox; return bbox;
}, },
// //
@ -1723,8 +1744,8 @@
var alttext = this.Get("alttext"); var alttext = this.Get("alttext");
if (alttext && !node.getAttribute("aria-label")) node.setAttribute("aria-label",alttext); if (alttext && !node.getAttribute("aria-label")) node.setAttribute("aria-label",alttext);
if (this.CHTML.pwidth) { if (this.CHTML.pwidth) {
node.parentNode.style.width = this.CHTML.pwidth;
node.parentNode.style.minWidth = this.CHTML.mwidth||CHTML.Em(this.CHTML.w); node.parentNode.style.minWidth = this.CHTML.mwidth||CHTML.Em(this.CHTML.w);
node.parentNode.className += " mjx-full-width";
} else if (!this.isMultiline && this.Get("display") === "block") { } else if (!this.isMultiline && this.Get("display") === "block") {
var values = this.getValues("indentalignfirst","indentshiftfirst","indentalign","indentshift"); var values = this.getValues("indentalignfirst","indentshiftfirst","indentalign","indentshift");
if (values.indentalignfirst !== MML.INDENTALIGN.INDENTALIGN) values.indentalign = values.indentalignfirst; if (values.indentalignfirst !== MML.INDENTALIGN.INDENTALIGN) values.indentalign = values.indentalignfirst;
@ -2659,6 +2680,7 @@
if (this.data[0]) { if (this.data[0]) {
this.data[0].toCommonHTML(node); this.data[0].toCommonHTML(node);
this.CHTML.updateFrom(this.data[0].CHTML); this.CHTML.updateFrom(this.data[0].CHTML);
this.CHTMLhandleBBox(node);
} }
return node; return node;
} }

View File

@ -401,11 +401,11 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
y = Y; y = Y;
for (i = 0, m = A.length-1; i < m; i++) { for (i = 0, m = A.length-1; i < m; i++) {
dy = Math.max(0,D[i]+H[i+1]+RSPACE[i]); dy = Math.max(0,D[i]+H[i+1]+RSPACE[i]);
if (RLINES[i] !== "none") { if (RLINES[i] !== MML.LINES.NONE && RLINES[i] !== "") {
line = HTMLCSS.createRule(stack,1.25/HTMLCSS.em,0,fW); HTMLCSS.addBox(stack,line); line = HTMLCSS.createRule(stack,1.25/HTMLCSS.em,0,fW); HTMLCSS.addBox(stack,line);
line.bbox = {h:1.25/HTMLCSS.em, d:0, w:fW, rw:fW, lw:0}; line.bbox = {h:1.25/HTMLCSS.em, d:0, w:fW, rw:fW, lw:0};
HTMLCSS.placeBox(line,0,y - D[i] - (dy-D[i]-H[i+1])/2,true); HTMLCSS.placeBox(line,0,y - D[i] - (dy-D[i]-H[i+1])/2,true);
if (RLINES[i] === "dashed") line.style.borderTopStyle = "dashed"; if (RLINES[i] === MML.LINES.DASHED) line.style.borderTopStyle = "dashed";
if (hasRelativeWidth) line.style.width = "100%" if (hasRelativeWidth) line.style.width = "100%"
} }
y -= dy; y -= dy;

View File

@ -246,6 +246,7 @@
REMAPACCENT: { REMAPACCENT: {
"\u007E": "\u0303", "\u007E": "\u0303",
"\u2192": "\u20D7", "\u2192": "\u20D7",
"\u2190": "\u20D6",
"\u0060": "\u0300", "\u0060": "\u0300",
"\u005E": "\u0302", "\u005E": "\u0302",
"\u00B4": "\u0301", "\u00B4": "\u0301",

View File

@ -140,6 +140,7 @@
REMAPACCENT: { REMAPACCENT: {
"\u007E": "\u0303", "\u007E": "\u0303",
"\u2192": "\u20D7", "\u2192": "\u20D7",
"\u2190": "\u20D6",
"\u0060": "\u0300", "\u0060": "\u0300",
"\u005E": "\u0302", "\u005E": "\u0302",
"\u00B4": "\u0301", "\u00B4": "\u0301",

View File

@ -241,6 +241,8 @@
var EVENT, TOUCH, HOVER; // filled in later var EVENT, TOUCH, HOVER; // filled in later
var oldIE = MathJax.Hub.Browser.isMSIE && (document.documentMode||0) < 8;
HTMLCSS.Augment({ HTMLCSS.Augment({
config: { config: {
styles: { styles: {
@ -278,6 +280,11 @@
"min-width": 0, "min-height": 0, "min-width": 0, "min-height": 0,
width: "100%" width: "100%"
}, },
".MathJax.MathJax_FullWidth": {
display: (oldIE ? "block" : "table-cell") + "!important",
width: (oldIE ? "100%" : "10000em") + "!important"
},
".MathJax img, .MathJax nobr, .MathJax a": { ".MathJax img, .MathJax nobr, .MathJax a": {
border: 0, padding: 0, margin: 0, border: 0, padding: 0, margin: 0,
@ -331,6 +338,12 @@
width:"1px", height:"60em", width:"1px", height:"60em",
"min-height": 0, "max-height":"none" "min-height": 0, "max-height":"none"
}, },
".MathJax_LineBox": {
display: (oldIE ? "block" : "table-cell") + "!important",
width: (oldIE ? "100%" : "10000em") + "!important",
"min-width":0, "max-width":"none",
padding:0, border:0, margin:0
},
".MathJax .MathJax_HitBox": { ".MathJax .MathJax_HitBox": {
cursor: "text", cursor: "text",
@ -340,7 +353,7 @@
".MathJax .MathJax_HitBox *": { ".MathJax .MathJax_HitBox *": {
filter: "none", opacity:1, background:"transparent" // for IE filter: "none", opacity:1, background:"transparent" // for IE
}, },
"#MathJax_Tooltip": { "#MathJax_Tooltip": {
position: "absolute", left: 0, top: 0, position: "absolute", left: 0, top: 0,
width: "auto", height: "auto", width: "auto", height: "auto",
@ -482,8 +495,7 @@
); );
// Used in preTranslate to get linebreak width // Used in preTranslate to get linebreak width
this.linebreakSpan = this.Element("span",null, this.linebreakSpan = MathJax.HTML.Element("span",{className:"MathJax_LineBox"});
[["hr",{style: {width:"100%", size:1, padding:0, border:0, margin:0}}]]);
// Set up styles and preload web fonts // Set up styles and preload web fonts
return AJAX.Styles(this.config.styles,["InitializeHTML",this]); return AJAX.Styles(this.config.styles,["InitializeHTML",this]);
@ -539,7 +551,7 @@
document.body.appendChild(this.linebreakSpan); document.body.appendChild(this.linebreakSpan);
this.defaultEx = this.EmExSpan.firstChild.offsetHeight/60; this.defaultEx = this.EmExSpan.firstChild.offsetHeight/60;
this.defaultEm = this.EmExSpan.lastChild.firstChild.offsetHeight/60; this.defaultEm = this.EmExSpan.lastChild.firstChild.offsetHeight/60;
this.defaultWidth = this.linebreakSpan.firstChild.offsetWidth; this.defaultWidth = this.linebreakSpan.offsetWidth;
document.body.removeChild(this.linebreakSpan); document.body.removeChild(this.linebreakSpan);
document.body.removeChild(this.EmExSpan); document.body.removeChild(this.EmExSpan);
}, },
@ -609,7 +621,7 @@
jax = script.MathJax.elementJax; if (!jax) continue; jax = script.MathJax.elementJax; if (!jax) continue;
ex = test.firstChild.offsetHeight/60; ex = test.firstChild.offsetHeight/60;
em = test.lastChild.firstChild.offsetHeight/60; em = test.lastChild.firstChild.offsetHeight/60;
cwidth = div.previousSibling.firstChild.offsetWidth; cwidth = Math.max(0,div.previousSibling.offsetWidth - 2);
if (relwidth) {maxwidth = cwidth} if (relwidth) {maxwidth = cwidth}
if (ex === 0 || ex === "NaN") { if (ex === 0 || ex === "NaN") {
// can't read width, so move to hidden div for processing // can't read width, so move to hidden div for processing
@ -2951,7 +2963,8 @@
if (math && math.bbox.width != null) { if (math && math.bbox.width != null) {
span.style.minWidth = (math.bbox.minWidth || span.style.width); span.style.minWidth = (math.bbox.minWidth || span.style.width);
span.style.width = math.bbox.width; span.style.width = math.bbox.width;
box.style.width = stack.style.width = SPAN.style.width = "100%"; box.style.width = stack.style.width = "100%";
SPAN.className += " MathJax_FullWidth";
} }
// //
// Add color (if any) // Add color (if any)

View File

@ -82,7 +82,7 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
} else { } else {
var mu = this.SVGgetMu(svg); var mu = this.SVGgetMu(svg);
svg.Add(BBOX.MGLYPH(this.img.img,values.width,values.height,values.valign,mu, svg.Add(BBOX.MGLYPH(this.img.img,values.width,values.height,values.valign,mu,
{src:values.src, alt:values.alt, title:values.alt})); {alt:values.alt, title:values.alt}));
} }
} }
svg.Clean(); svg.Clean();

View File

@ -308,7 +308,7 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
y = Y - lw/2; y = Y - lw/2;
for (i = 0, m = A.length-1; i < m; i++) { for (i = 0, m = A.length-1; i < m; i++) {
dy = Math.max(0,D[i]+H[i+1]+RSPACE[i]); dy = Math.max(0,D[i]+H[i+1]+RSPACE[i]);
if (RLINES[i] !== "none") if (RLINES[i] !== MML.LINES.NONE && RLINES[i] !== "")
{svg.Add(BBOX.HLINE(fW,lw,RLINES[i]),0,y-D[i]-(dy-D[i]-H[i+1])/2)} {svg.Add(BBOX.HLINE(fW,lw,RLINES[i]),0,y-D[i]-(dy-D[i]-H[i+1])/2)}
y -= dy; y -= dy;
} }

View File

@ -243,6 +243,7 @@
REMAPACCENT: { REMAPACCENT: {
"\u007E": "\u0303", "\u007E": "\u0303",
"\u2192": "\u20D7", "\u2192": "\u20D7",
"\u2190": "\u20D6",
"\u0060": "\u0300", "\u0060": "\u0300",
"\u005E": "\u0302", "\u005E": "\u0302",
"\u00B4": "\u0301", "\u00B4": "\u0301",

View File

@ -100,6 +100,12 @@
"min-height": 0, "max-height":"none", "min-height": 0, "max-height":"none",
padding:0, border: 0, margin: 0 padding:0, border: 0, margin: 0
}, },
".MathJax_SVG_LineBox": {
display: "table-cell!important",
width: "10000em!important",
"min-width":0, "max-width":"none",
padding:0, border:0, margin:0
},
"#MathJax_SVG_Tooltip": { "#MathJax_SVG_Tooltip": {
position: "absolute", left: 0, top: 0, position: "absolute", left: 0, top: 0,
@ -173,8 +179,7 @@
); );
// Used in preTranslate to get linebreak width // Used in preTranslate to get linebreak width
this.linebreakSpan = HTML.Element("span",null, this.linebreakSpan = HTML.Element("span",{className:"MathJax_SVG_LineBox"});
[["hr",{style: {width:"auto", size:1, padding:0, border:0, margin:0}}]]);
// Set up styles // Set up styles
return AJAX.Styles(this.config.styles,["InitializeSVG",this]); return AJAX.Styles(this.config.styles,["InitializeSVG",this]);
@ -190,7 +195,7 @@
document.body.appendChild(this.ExSpan); document.body.appendChild(this.ExSpan);
document.body.appendChild(this.linebreakSpan); document.body.appendChild(this.linebreakSpan);
this.defaultEx = this.ExSpan.firstChild.offsetHeight/60; this.defaultEx = this.ExSpan.firstChild.offsetHeight/60;
this.defaultWidth = this.linebreakSpan.firstChild.offsetWidth; this.defaultWidth = this.linebreakSpan.offsetWidth;
document.body.removeChild(this.linebreakSpan); document.body.removeChild(this.linebreakSpan);
document.body.removeChild(this.ExSpan); document.body.removeChild(this.ExSpan);
}, },
@ -256,16 +261,15 @@
test = script.previousSibling; div = test.previousSibling; test = script.previousSibling; div = test.previousSibling;
jax = script.MathJax.elementJax; if (!jax) continue; jax = script.MathJax.elementJax; if (!jax) continue;
ex = test.firstChild.offsetHeight/60; ex = test.firstChild.offsetHeight/60;
cwidth = div.previousSibling.firstChild.offsetWidth / this.config.scale * 100; cwidth = Math.max(0,(div.previousSibling.offsetWidth-2) / this.config.scale * 100);
if (relwidth) {maxwidth = cwidth}
if (ex === 0 || ex === "NaN") { if (ex === 0 || ex === "NaN") {
// can't read width, so move to hidden div for processing // can't read width, so move to hidden div for processing
// (this will cause a reflow for each math element that is hidden) // (this will cause a reflow for each math element that is hidden)
this.hiddenDiv.appendChild(div); this.hiddenDiv.appendChild(div);
jax.SVG.isHidden = true; jax.SVG.isHidden = true;
ex = this.defaultEx; cwidth = this.defaultWidth; ex = this.defaultEx; cwidth = this.defaultWidth;
if (relwidth) {maxwidth = cwidth}
} }
if (relwidth) {maxwidth = cwidth}
jax.SVG.ex = ex; jax.SVG.ex = ex;
jax.SVG.em = em = ex / SVG.TeX.x_height * 1000; // scale ex to x_height jax.SVG.em = em = ex / SVG.TeX.x_height * 1000; // scale ex to x_height
jax.SVG.cwidth = cwidth/em * 1000; jax.SVG.cwidth = cwidth/em * 1000;
@ -2089,13 +2093,14 @@
var style = svg.element.style, px = SVG.TeX.x_height/SVG.ex; var style = svg.element.style, px = SVG.TeX.x_height/SVG.ex;
var H = (Math.ceil(svg.H/px)+1)*px+SVG.HFUZZ, // round to pixels and add padding var H = (Math.ceil(svg.H/px)+1)*px+SVG.HFUZZ, // round to pixels and add padding
D = (Math.ceil(svg.D/px)+1)*px+SVG.DFUZZ; D = (Math.ceil(svg.D/px)+1)*px+SVG.DFUZZ;
svg.element.setAttribute("width",SVG.Ex(l+svg.w+r)); var w = l + svg.w + r;
svg.element.setAttribute("width",SVG.Ex(w));
svg.element.setAttribute("height",SVG.Ex(H+D)); svg.element.setAttribute("height",SVG.Ex(H+D));
style.verticalAlign = SVG.Ex(-D); style.verticalAlign = SVG.Ex(-D);
if (l) style.marginLeft = SVG.Ex(-l); if (l) style.marginLeft = SVG.Ex(-l);
if (r) style.marginRight = SVG.Ex(-r); if (r) style.marginRight = SVG.Ex(-r);
svg.element.setAttribute("viewBox",SVG.Fixed(-l,1)+" "+SVG.Fixed(-H,1)+" "+ svg.element.setAttribute("viewBox",SVG.Fixed(-l,1)+" "+SVG.Fixed(-H,1)+" "+
SVG.Fixed(l+svg.w+r,1)+" "+SVG.Fixed(H+D,1)); SVG.Fixed(w,1)+" "+SVG.Fixed(H+D,1));
// //
// If there is extra height or depth, hide that // If there is extra height or depth, hide that
// //
@ -2105,6 +2110,12 @@
style.verticalAlign = SVG.Ex(-svg.d); style.verticalAlign = SVG.Ex(-svg.d);
} }
// //
// The approximate ex can cause full-width equations to be too wide,
// so if they are close to full width, make sure they aren't too big.
//
if (Math.abs(w-SVG.cwidth) < 10)
style.maxWidth = SVG.Fixed(SVG.cwidth*SVG.em/1000);
//
// Add it to the MathJax span // Add it to the MathJax span
// //
var alttext = this.Get("alttext"); var alttext = this.Get("alttext");
@ -2131,7 +2142,7 @@
if (shift) { if (shift) {
HUB.Insert(style,({ HUB.Insert(style,({
left: {marginLeft: SVG.Ex(shift)}, left: {marginLeft: SVG.Ex(shift)},
right: {marginRight: SVG.Ex(-shift), marginLeft: SVG.Ex(Math.max(0,shift-(l+svg.w+r)))}, right: {marginRight: SVG.Ex(-shift), marginLeft: SVG.Ex(Math.max(0,shift-w))},
center: {marginLeft: SVG.Ex(shift), marginRight: SVG.Ex(-shift)} center: {marginLeft: SVG.Ex(shift), marginRight: SVG.Ex(-shift)}
})[values.indentalign]); })[values.indentalign]);
} }