Skip to content

Commit

Permalink
Merge pull request #528 from fred-wang/issue481
Browse files Browse the repository at this point in the history
This resolves issue #481
  • Loading branch information
dpvc committed Aug 2, 2013
2 parents 02261ae + 108cda6 commit 1326cbd
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 46 deletions.
3 changes: 1 addition & 2 deletions unpacked/extensions/TeX/cancel.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ MathJax.Extension["TeX/cancel"] = {
// The attributes allowed in \enclose{notation}[attributes]{math}
//
ALLOWED: {
arrow: 1,
color: 1, mathcolor: 1,
background: 1, mathbackground: 1,
padding: 1,
Expand Down Expand Up @@ -97,7 +96,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
var value = this.ParseArg(name),
attr = this.GetBrackets(name,""),
math = this.ParseArg(name);
var def = CANCEL.setAttributes({notation: MML.NOTATION.UPDIAGONALSTRIKE, arrow:true},attr);
var def = CANCEL.setAttributes({notation: MML.NOTATION.UPDIAGONALSTRIKE+" "+MML.NOTATION.UPDIAGONALARROW},attr);
value = MML.mpadded(value).With({depth:"-.1em",height:"+.1em",voffset:".1em"});
this.Push(MML.msup(MML.menclose(math).With(def),value));
}
Expand Down
1 change: 0 additions & 1 deletion unpacked/extensions/toMathML.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ MathJax.Hub.Register.LoadHook("[MathJax]/jax/element/mml/jax.js",function () {
}
if (this.mathvariant && this.toMathMLvariants[this.mathvariant])
{CLASS.push("MJX"+this.mathvariant)}
if (this.arrow) {CLASS.push("MJX-arrow")}
if (this.variantForm) {CLASS.push("MJX-variant")}
if (CLASS.length) {attr.unshift('class="'+CLASS.join(" ")+'"')}
},
Expand Down
1 change: 1 addition & 0 deletions unpacked/jax/element/mml/jax.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@ MathJax.ElementJax.mml.Augment({
BOTTOM: "bottom",
UPDIAGONALSTRIKE: "updiagonalstrike",
DOWNDIAGONALSTRIKE: "downdiagonalstrike",
UPDIAGONALARROW: "updiagonalarrow",
VERTICALSTRIKE: "verticalstrike",
HORIZONTALSTRIKE: "horizontalstrike",
MADRUWB: "madruwb"
Expand Down
6 changes: 5 additions & 1 deletion unpacked/jax/input/MathML/jax.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,11 @@
for (var i = 0, m = CLASS.length; i < m; i++) {
if (CLASS[i].substr(0,4) === "MJX-") {
if (CLASS[i] === "MJX-arrow") {
mml.arrow = true;
// This class was used in former versions of MathJax to attach an
// arrow to the updiagonalstrike notation. For backward
// compatibility, let's continue to accept this case. See issue 481.
if (!mml.notation.match("/"+MML.NOTATION.UPDIAGONALARROW+"/"))
mml.notation += " "+MML.NOTATION.UPDIAGONALARROW;
} else if (CLASS[i] === "MJX-variant") {
mml.variantForm = true;
//
Expand Down
64 changes: 36 additions & 28 deletions unpacked/jax/output/HTML-CSS/autoload/menclose.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,18 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
var frame = HTMLCSS.createFrame(stack,H+D,0,W,t,"none");
frame.id = "MathJax-frame-"+this.spanID;
HTMLCSS.addBox(stack,frame); stack.insertBefore(frame,base); // move base to above background
var notation = MathJax.Hub.SplitList(values.notation);
var T = 0, B = 0, R = 0, L = 0, dx = 0, dy = 0; var svg, vml;
var w, h, r;
if (!values.mathcolor) {values.mathcolor = "black"} else {span.style.color = values.mathcolor}

for (var i = 0, m = notation.length; i < m; i++) {
switch (notation[i]) {

// perform some reduction e.g. eliminate duplicate notations.
var nl = MathJax.Hub.SplitList(values.notation), notation = {};
for (var i = 0, m = nl.length; i < m; i++) notation[nl[i]] = true;
if (notation[MML.NOTATION.UPDIAGONALARROW]) notation[MML.NOTATION.UPDIAGONALSTRIKE] = false;

for (var n in notation) {
if (!notation.hasOwnProperty(n) || !notation[n]) continue;
switch (n) {
case MML.NOTATION.BOX:
frame.style.border = SOLID; if (!HTMLCSS.msieBorderWidthBug) {T = B = L = R = t}
break;
Expand Down Expand Up @@ -133,32 +138,35 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
if (HTMLCSS.useVML) {
if (!vml) {vml = this.HTMLvml(stack,H,D,W,t,values.mathcolor)}
var line = this.HTMLvmlElement(vml,"line",{from: "0,"+this.HTMLpx(H+D-t), to: this.HTMLpx(W)+",0"});
if (this.arrow) {
this.HTMLvmlElement(line,"stroke",{endarrow:"classic"});
line.to = this.HTMLpx(W)+","+this.HTMLpx(t);
}
} else {
if (!svg) {svg = this.HTMLsvg(stack,H,D,W,t,values.mathcolor)}
if (this.arrow) {
var l = Math.sqrt(W*W + (H+D)*(H+D)), f = 1/l * 10*scale/HTMLCSS.em * t/.075;
w = W * f; h = (H+D) * f; var x = W - t/2, y = t/2;
if (y+h-.4*w < 0) {y = .4*w-h}
this.HTMLsvgElement(svg.firstChild,"line",{
x1:1, y1:this.HTMLpx(H+D-t), x2:this.HTMLpx(x-.7*w), y2:this.HTMLpx(y+.7*h)
});
this.HTMLsvgElement(svg.firstChild,"polygon",{
points: this.HTMLpx(x)+","+this.HTMLpx(y)+" "
+this.HTMLpx(x-w-.4*h)+","+this.HTMLpx(y+h-.4*w)+" "
+this.HTMLpx(x-.7*w)+","+this.HTMLpx(y+.7*h)+" "
+this.HTMLpx(x-w+.4*h)+","+this.HTMLpx(y+h+.4*w)+" "
+this.HTMLpx(x)+","+this.HTMLpx(y),
fill:values.mathcolor, stroke:"none"
});
} else {
this.HTMLsvgElement(svg.firstChild,"line",{
x1:1, y1:this.HTMLpx(H+D-t), x2:this.HTMLpx(W-t), y2:this.HTMLpx(t)
});
}
this.HTMLsvgElement(svg.firstChild,"line",{
x1:1, y1:this.HTMLpx(H+D-t), x2:this.HTMLpx(W-t), y2:this.HTMLpx(t)
});
}
break;

case MML.NOTATION.UPDIAGONALARROW:
if (HTMLCSS.useVML) {
if (!vml) {vml = this.HTMLvml(stack,H,D,W,t,values.mathcolor)}
var line = this.HTMLvmlElement(vml,"line",{from: "0,"+this.HTMLpx(H+D-t), to: this.HTMLpx(W)+","+this.HTMLpx(t)});
this.HTMLvmlElement(line,"stroke",{endarrow:"classic"});
} else {
if (!svg) {svg = this.HTMLsvg(stack,H,D,W,t,values.mathcolor)}
var l = Math.sqrt(W*W + (H+D)*(H+D)), f = 1/l * 10*scale/HTMLCSS.em * t/.075;
w = W * f; h = (H+D) * f; var x = W - t/2, y = t/2;
if (y+h-.4*w < 0) {y = .4*w-h}
this.HTMLsvgElement(svg.firstChild,"line",{
x1:1, y1:this.HTMLpx(H+D-t), x2:this.HTMLpx(x-.7*w), y2:this.HTMLpx(y+.7*h)
});
this.HTMLsvgElement(svg.firstChild,"polygon",{
points: this.HTMLpx(x)+","+this.HTMLpx(y)+" "
+this.HTMLpx(x-w-.4*h)+","+this.HTMLpx(y+h-.4*w)+" "
+this.HTMLpx(x-.7*w)+","+this.HTMLpx(y+.7*h)+" "
+this.HTMLpx(x-w+.4*h)+","+this.HTMLpx(y+h+.4*w)+" "
+this.HTMLpx(x)+","+this.HTMLpx(y),
fill:values.mathcolor, stroke:"none"
});
}
break;

Expand Down
1 change: 0 additions & 1 deletion unpacked/jax/output/NativeMML/jax.js
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,6 @@
}
if (this.mathvariant && this.NativeMMLvariants[this.mathvariant])
{CLASS.push("MJX"+this.mathvariant)}
if (this.arrow) {CLASS.push("MJX-arrow")}
if (this.variantForm) {CLASS.push("MJX-variant")}
if (CLASS.length) {tag.setAttribute("class",CLASS.join(" "))}
},
Expand Down
31 changes: 18 additions & 13 deletions unpacked/jax/output/SVG/autoload/menclose.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,17 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
var p = SVG.length2em(values.padding,mu,1/SVG.em) * scale; // padding for enclosure
var t = SVG.length2em(values.thickness,mu,1/SVG.em); // thickness of lines (not scaled, see issue #414)
var H = base.h+p+t, D = base.d+p+t, W = base.w+2*(p+t);
var notation = MathJax.Hub.SplitList(values.notation);
var dx = 0, w, h, i, m, borders = [false,false,false,false];
if (!values.mathcolor) {values.mathcolor = "black"}

// perform some reduction e.g. eliminate duplicate notations.
var nl = MathJax.Hub.SplitList(values.notation), notation = {};
for (var i = 0, m = nl.length; i < m; i++) notation[nl[i]] = true;
if (notation[MML.NOTATION.UPDIAGONALARROW]) notation[MML.NOTATION.UPDIAGONALSTRIKE] = false;

for (i = 0, m = notation.length; i < m; i++) {
switch (notation[i]) {
for (var n in notation) {
if (!notation.hasOwnProperty(n) || !notation[n]) continue;
switch (n) {
case MML.NOTATION.BOX:
borders = [true,true,true,true];
break;
Expand Down Expand Up @@ -157,16 +162,16 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
break;

case MML.NOTATION.UPDIAGONALSTRIKE:
if (this.arrow) {
var l = Math.sqrt(W*W + (H+D)*(H+D)), f = 1/l * 10/SVG.em * t/.075;
w = W * f; h = (H+D) * f; var x = .4*h;
svg.Add(BBOX.DLINE(H-.5*h,D,W-.5*w,t,values.mathcolor,"up"));
svg.Add(BBOX.FPOLY(
[[x+w,h], [x-.4*h,.4*w], [x+.3*w,.3*h], [x+.4*h,-.4*w], [x+w,h]],
values.mathcolor),W-w-x,H-h);
} else {
svg.Add(BBOX.DLINE(H,D,W,t,values.mathcolor,"up"));
}
svg.Add(BBOX.DLINE(H,D,W,t,values.mathcolor,"up"));
break;

case MML.NOTATION.UPDIAGONALARROW:
var l = Math.sqrt(W*W + (H+D)*(H+D)), f = 1/l * 10/SVG.em * t/.075;
w = W * f; h = (H+D) * f; var x = .4*h;
svg.Add(BBOX.DLINE(H-.5*h,D,W-.5*w,t,values.mathcolor,"up"));
svg.Add(BBOX.FPOLY(
[[x+w,h], [x-.4*h,.4*w], [x+.3*w,.3*h], [x+.4*h,-.4*w], [x+w,h]],
values.mathcolor),W-w-x,H-h);
break;

case MML.NOTATION.DOWNDIAGONALSTRIKE:
Expand Down

0 comments on commit 1326cbd

Please sign in to comment.