Skip to content

Commit 7b05eb7

Browse files
committed
Better fix for useMMLspacing and FORM attributes.
1 parent 66865a7 commit 7b05eb7

File tree

5 files changed

+14
-20
lines changed

5 files changed

+14
-20
lines changed

unpacked/jax/element/mml/jax.js

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ MathJax.ElementJax.mml.Augment({
338338
adjustChild_scriptlevel: function (i,nodef) {return this.Get("scriptlevel",nodef)}, // always inherit from parent
339339
adjustChild_displaystyle: function (i,nodef) {return this.Get("displaystyle",nodef)}, // always inherit from parent
340340
adjustChild_texprimestyle: function (i,nodef) {return this.Get("texprimestyle",nodef)}, // always inherit from parent
341+
hasMMLspacing: function () {return false},
341342
childPosition: function () {
342343
var child = this, parent = child.parent;
343344
while (parent.notParent) {child = parent; parent = child.parent}
@@ -559,12 +560,16 @@ MathJax.ElementJax.mml.Augment({
559560
indentshiftlast: MML.INDENTSHIFT.INDENTSHIFT,
560561
texClass: MML.TEXCLASS.REL // for MML, but TeX sets ORD explicitly
561562
},
562-
SPACE_ATTR: {lspace: 0x01, rspace: 0x02, form: 0x04},
563+
SPACE_ATTR: {lspace: 0x01, rspace: 0x02},
563564
useMMLspacing: 0x03,
565+
hasMMLspacing: function () {
566+
if (this.useMMLspacing) return true;
567+
return this.form && (this.OPTABLE[this.form]||{})[this.data.join('')];
568+
},
564569
autoDefault: function (name,nodefault) {
565570
var def = this.def;
566571
if (!def) {
567-
if (name === "form") {this.useMMLspacing &= ~this.SPACE_ATTR.form; return this.getForm()}
572+
if (name === "form") {return this.getForm()}
568573
var mo = this.data.join("");
569574
var forms = [this.Get("form"),MML.FORM.INFIX,MML.FORM.POSTFIX,MML.FORM.PREFIX];
570575
for (var i = 0, m = forms.length; i < m; i++) {
@@ -657,7 +662,7 @@ MathJax.ElementJax.mml.Augment({
657662
},
658663
setTeXclass: function (prev) {
659664
var values = this.getValues("form","lspace","rspace","fence"); // sets useMMLspacing
660-
if (this.useMMLspacing) {this.texClass = MML.TEXCLASS.NONE; return this}
665+
if (this.hasMMLspacing()) {this.texClass = MML.TEXCLASS.NONE; return this}
661666
if (values.fence && !this.texClass) {
662667
if (values.form === MML.FORM.PREFIX) {this.texClass = MML.TEXCLASS.OPEN}
663668
if (values.form === MML.FORM.POSTFIX) {this.texClass = MML.TEXCLASS.CLOSE}
@@ -996,10 +1001,6 @@ MathJax.ElementJax.mml.Augment({
9961001
this.SetData("open",MML.mo(values.open).With({
9971002
fence:true, form:MML.FORM.PREFIX, texClass:MML.TEXCLASS.OPEN
9981003
}));
999-
//
1000-
// Clear flag for using MML spacing even though form is specified
1001-
//
1002-
this.data.open.useMMLspacing = 0;
10031004
}
10041005
//
10051006
// Create fake nodes for the separators
@@ -1008,10 +1009,8 @@ MathJax.ElementJax.mml.Augment({
10081009
while (values.separators.length < this.data.length)
10091010
{values.separators += values.separators.charAt(values.separators.length-1)}
10101011
for (var i = 1, m = this.data.length; i < m; i++) {
1011-
if (this.data[i]) {
1012-
this.SetData("sep"+i,MML.mo(values.separators.charAt(i-1)).With({separator:true}))
1013-
this.data["sep"+i].useMMLspacing = 0;
1014-
}
1012+
if (this.data[i])
1013+
{this.SetData("sep"+i,MML.mo(values.separators.charAt(i-1)).With({separator:true}))}
10151014
}
10161015
}
10171016
//
@@ -1021,10 +1020,6 @@ MathJax.ElementJax.mml.Augment({
10211020
this.SetData("close",MML.mo(values.close).With({
10221021
fence:true, form:MML.FORM.POSTFIX, texClass:MML.TEXCLASS.CLOSE
10231022
}));
1024-
//
1025-
// Clear flag for using MML spacing even though form is specified
1026-
//
1027-
this.data.close.useMMLspacing = 0;
10281023
}
10291024
},
10301025
texClass: MML.TEXCLASS.OPEN,
@@ -1492,7 +1487,7 @@ MathJax.ElementJax.mml.Augment({
14921487
INTEGRAL2: [1,2,TEXCLASS.OP,{largeop: true, symmetric: true}],
14931488
BIN3: [3,3,TEXCLASS.BIN],
14941489
BIN4: [4,4,TEXCLASS.BIN],
1495-
BIN01: [0,1,TEXCLASS.ORD],
1490+
BIN01: [0,1,TEXCLASS.BIN],
14961491
BIN5: [5,5,TEXCLASS.BIN],
14971492
TALLBIN: [4,4,TEXCLASS.BIN,{stretchy: true}],
14981493
BINOP: [4,4,TEXCLASS.BIN,{largeop: true, movablelimits: true}],

unpacked/jax/input/TeX/jax.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1363,7 +1363,6 @@
13631363
form: MML.FORM.PREFIX,
13641364
texClass: MML.TEXCLASS.OP
13651365
});
1366-
mml.useMMLspacing &= ~mml.SPACE_ATTR.form; // don't count this explicit form setting
13671366
this.Push(this.mmlToken(mml));
13681367
},
13691368
Limits: function (name,limits) {

unpacked/jax/output/CommonHTML/jax.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1947,7 +1947,7 @@
19471947
return node;
19481948
},
19491949
CHTMLhandleSpace: function (node) {
1950-
if (this.useMMLspacing) {
1950+
if (this.hasMMLspacing()) {
19511951
var values = this.getValues("scriptlevel","lspace","rspace");
19521952
values.lspace = Math.max(0,this.CHTMLlength2em(values.lspace));
19531953
values.rspace = Math.max(0,this.CHTMLlength2em(values.rspace));

unpacked/jax/output/HTML-CSS/jax.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2097,7 +2097,7 @@
20972097
},
20982098

20992099
HTMLhandleSpace: function (span) {
2100-
if (this.useMMLspacing) {
2100+
if (this.hasMMLspacing()) {
21012101
if (this.type !== "mo") return;
21022102
var values = this.getValues("scriptlevel","lspace","rspace");
21032103
if (values.scriptlevel <= 0 || this.hasValue("lspace") || this.hasValue("rspace")) {

unpacked/jax/output/SVG/jax.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1287,7 +1287,7 @@
12871287
},
12881288

12891289
SVGhandleSpace: function (svg) {
1290-
if (this.useMMLspacing) {
1290+
if (this.hasMMLspacing()) {
12911291
if (this.type !== "mo") return;
12921292
var values = this.getValues("scriptlevel","lspace","rspace");
12931293
if (values.scriptlevel <= 0 || this.hasValue("lspace") || this.hasValue("rspace")) {

0 commit comments

Comments
 (0)