Handle movablelimits on TeXAtom elements. Resolves issue #1197.

This commit is contained in:
Davide P. Cervone 2016-01-24 18:26:50 -05:00
parent 3ba60663df
commit dc450d6bc7
7 changed files with 35 additions and 16 deletions

View File

@ -186,8 +186,15 @@ MathJax.Hub.Register.LoadHook("[MathJax]/jax/element/mml/jax.js",function () {
MML.munderover.Augment({
toMathML: function (space) {
var tag = this.type;
if (this.data[this.under] == null) {tag = "mover"}
if (this.data[this.over] == null) {tag = "munder"}
var base = this.data[this.base];
if (base && base.isa(MML.TeXAtom) && base.movablelimits && !base.Get("displaystyle")) {
type = "msubsup";
if (this.data[this.under] == null) {tag = "msup"}
if (this.data[this.over] == null) {tag = "msub"}
} else {
if (this.data[this.under] == null) {tag = "mover"}
if (this.data[this.over] == null) {tag = "munder"}
}
var attr = this.toMathMLattributes();
delete this.data[0].inferred;
var data = [];

View File

@ -1367,6 +1367,7 @@
}
op.movesupsub = (limits ? true : false);
op.Core().movablelimits = false;
if (op.movablelimits) op.movablelimits = false;
},
Over: function (name,open,close) {

View File

@ -2054,13 +2054,14 @@
MML.munderover.Augment({
toCommonHTML: function (node,stretch) {
var values = this.getValues("displaystyle","accent","accentunder","align");
if (!values.displaystyle && this.data[this.base] != null &&
this.data[this.base].CoreMO().Get("movablelimits"))
var base = this.data[this.base];
if (!values.displaystyle && base != null &&
(base.movablelimits || base.CoreMO().Get("movablelimits")))
return MML.msubsup.prototype.toCommonHTML.call(this,node,stretch);
//
// Get the nodes for base and limits
//
var base, under, over, nodes = [];
var under, over, nodes = [];
if (stretch) {
base = CHTML.getNode(node,"mjx-op");
under = CHTML.getNode(node,"mjx-under");

View File

@ -2713,8 +2713,9 @@
MML.munderover.Augment({
toHTML: function (span,HW,D) {
var values = this.getValues("displaystyle","accent","accentunder","align");
if (!values.displaystyle && this.data[this.base] != null &&
this.data[this.base].CoreMO().Get("movablelimits"))
var base = this.data[this.base];
if (!values.displaystyle && base != null &&
(base.movablelimits || base.CoreMO().Get("movablelimits")))
{return MML.msubsup.prototype.toHTML.call(this,span)}
span = this.HTMLcreateSpan(span); var scale = this.HTMLgetScale();
var stack = HTMLCSS.createStack(span);
@ -2753,8 +2754,8 @@
if (box.bbox.w > WW) {WW = box.bbox.w}
}}
var t = HTMLCSS.TeX.rule_thickness * this.mscale, factor = HTMLCSS.FONTDATA.TeX_factor;
var base = boxes[this.base] || {bbox: this.HTMLzeroBBox()};
var x, y, z1, z2, z3, dw, k, delta = 0;
base = boxes[this.base] || {bbox: this.HTMLzeroBBox()};
if (base.bbox.ic) {delta = 1.3*base.bbox.ic + .05} // adjust faked IC to be more in line with expeted results
for (i = 0, m = this.data.length; i < m; i++) {
if (this.data[i] != null) {

View File

@ -630,12 +630,19 @@
MML.munderover.Augment({
//
// Use proper version of munder, mover, or munderover, depending on
// which items are present
// which items are present. Handle movablelimits on TeXAtom base.
//
toNativeMML: function (parent) {
var type = this.type;
if (this.data[this.under] == null) {type = "mover"}
if (this.data[this.over] == null) {type = "munder"}
var base = this.data[this.base];
if (base && base.isa(MML.TeXAtom) && base.movablelimits && !base.Get("displaystyle")) {
type = "msubsup";
if (this.data[this.under] == null) {type = "msup"}
if (this.data[this.over] == null) {type = "msub"}
} else {
if (this.data[this.under] == null) {type = "mover"}
if (this.data[this.over] == null) {type = "munder"}
}
var tag = this.NativeMMLelement(type);
this.NativeMMLattributes(tag);
if (this.data[0]) {delete this.data[0].inferred}

View File

@ -750,8 +750,9 @@
MML.munderover.Augment({
toPreviewHTML: 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")) {
var base = this.data[this.base];
if (!values.displaystyle && base != null &&
(base.movablelimits || base.CoreMO().Get("movablelimits"))) {
span = MML.msubsup.prototype.toPreviewHTML.call(this,span);
//
// Change class to msubsup for CSS rules.

View File

@ -1882,8 +1882,9 @@
toSVG: function (HW,D) {
this.SVGgetStyles();
var values = this.getValues("displaystyle","accent","accentunder","align");
if (!values.displaystyle && this.data[this.base] != null &&
this.data[this.base].CoreMO().Get("movablelimits"))
var base = this.data[this.base];
if (!values.displaystyle && base != null &&
(base.movablelimits || base.CoreMO().Get("movablelimits")))
{return MML.msubsup.prototype.toSVG.call(this)}
var svg = this.SVG(), scale = this.SVGgetScale(svg); this.SVGhandleSpace(svg);
var boxes = [], stretch = [], box, i, m, W = -SVG.BIGDIMEN, WW = W;
@ -1909,8 +1910,8 @@
if (boxes[i].w > WW) {WW = boxes[i].w}
}}
var t = SVG.TeX.rule_thickness * this.mscale;
var base = boxes[this.base] || {w:0, h:0, d:0, H:0, D:0, l:0, r:0, y:0, scale:scale};
var x, y, z1, z2, z3, dw, k, delta = 0;
base = boxes[this.base] || {w:0, h:0, d:0, H:0, D:0, l:0, r:0, y:0, scale:scale};
if (base.ic) {delta = 1.3*base.ic + .05} // adjust faked IC to be more in line with expeted results
for (i = 0, m = this.data.length; i < m; i++) {
if (this.data[i] != null) {