commit dc450d6bc714f29aaa6ed77731cedfba431c59ea
parent 3ba60663dfc6efd0269b1aab5250549e6fe5f5e8
Author: Davide P. Cervone <dpvc@union.edu>
Date: Sun, 24 Jan 2016 18:26:50 -0500
Handle movablelimits on TeXAtom elements. Resolves issue #1197.
Diffstat:
7 files changed, 35 insertions(+), 16 deletions(-)
diff --git a/unpacked/extensions/toMathML.js b/unpacked/extensions/toMathML.js
@@ -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 = [];
diff --git a/unpacked/jax/input/TeX/jax.js b/unpacked/jax/input/TeX/jax.js
@@ -1367,6 +1367,7 @@
}
op.movesupsub = (limits ? true : false);
op.Core().movablelimits = false;
+ if (op.movablelimits) op.movablelimits = false;
},
Over: function (name,open,close) {
diff --git a/unpacked/jax/output/CommonHTML/jax.js b/unpacked/jax/output/CommonHTML/jax.js
@@ -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");
diff --git a/unpacked/jax/output/HTML-CSS/jax.js b/unpacked/jax/output/HTML-CSS/jax.js
@@ -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) {
diff --git a/unpacked/jax/output/NativeMML/jax.js b/unpacked/jax/output/NativeMML/jax.js
@@ -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}
diff --git a/unpacked/jax/output/PreviewHTML/jax.js b/unpacked/jax/output/PreviewHTML/jax.js
@@ -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.
diff --git a/unpacked/jax/output/SVG/jax.js b/unpacked/jax/output/SVG/jax.js
@@ -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) {