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