Replace nonstandard MJX-arrow class by an "updiagonalarrow" menclose notation. Fix issue #481.
This commit is contained in:
parent
55b5803d0a
commit
cc34c39def
|
@ -38,7 +38,6 @@ MathJax.Extension["TeX/cancel"] = {
|
||||||
// The attributes allowed in \enclose{notation}[attributes]{math}
|
// The attributes allowed in \enclose{notation}[attributes]{math}
|
||||||
//
|
//
|
||||||
ALLOWED: {
|
ALLOWED: {
|
||||||
arrow: 1,
|
|
||||||
color: 1, mathcolor: 1,
|
color: 1, mathcolor: 1,
|
||||||
background: 1, mathbackground: 1,
|
background: 1, mathbackground: 1,
|
||||||
padding: 1,
|
padding: 1,
|
||||||
|
@ -97,7 +96,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
|
||||||
var value = this.ParseArg(name),
|
var value = this.ParseArg(name),
|
||||||
attr = this.GetBrackets(name,""),
|
attr = this.GetBrackets(name,""),
|
||||||
math = this.ParseArg(name);
|
math = this.ParseArg(name);
|
||||||
var def = CANCEL.setAttributes({notation: MML.NOTATION.UPDIAGONALSTRIKE, arrow:true},attr);
|
var def = CANCEL.setAttributes({notation: MML.NOTATION.UPDIAGONALARROW},attr);
|
||||||
value = MML.mpadded(value).With({depth:"-.1em",height:"+.1em",voffset:".1em"});
|
value = MML.mpadded(value).With({depth:"-.1em",height:"+.1em",voffset:".1em"});
|
||||||
this.Push(MML.msup(MML.menclose(math).With(def),value));
|
this.Push(MML.msup(MML.menclose(math).With(def),value));
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,7 +84,6 @@ MathJax.Hub.Register.LoadHook("[MathJax]/jax/element/mml/jax.js",function () {
|
||||||
}
|
}
|
||||||
if (this.mathvariant && this.toMathMLvariants[this.mathvariant])
|
if (this.mathvariant && this.toMathMLvariants[this.mathvariant])
|
||||||
{CLASS.push("MJX"+this.mathvariant)}
|
{CLASS.push("MJX"+this.mathvariant)}
|
||||||
if (this.arrow) {CLASS.push("MJX-arrow")}
|
|
||||||
if (this.variantForm) {CLASS.push("MJX-variant")}
|
if (this.variantForm) {CLASS.push("MJX-variant")}
|
||||||
if (CLASS.length) {attr.unshift('class="'+CLASS.join(" ")+'"')}
|
if (CLASS.length) {attr.unshift('class="'+CLASS.join(" ")+'"')}
|
||||||
},
|
},
|
||||||
|
|
|
@ -132,6 +132,7 @@ MathJax.ElementJax.mml.Augment({
|
||||||
BOTTOM: "bottom",
|
BOTTOM: "bottom",
|
||||||
UPDIAGONALSTRIKE: "updiagonalstrike",
|
UPDIAGONALSTRIKE: "updiagonalstrike",
|
||||||
DOWNDIAGONALSTRIKE: "downdiagonalstrike",
|
DOWNDIAGONALSTRIKE: "downdiagonalstrike",
|
||||||
|
UPDIAGONALARROW: "updiagonalarrow",
|
||||||
VERTICALSTRIKE: "verticalstrike",
|
VERTICALSTRIKE: "verticalstrike",
|
||||||
HORIZONTALSTRIKE: "horizontalstrike",
|
HORIZONTALSTRIKE: "horizontalstrike",
|
||||||
MADRUWB: "madruwb"
|
MADRUWB: "madruwb"
|
||||||
|
|
|
@ -96,7 +96,11 @@
|
||||||
for (var i = 0, m = CLASS.length; i < m; i++) {
|
for (var i = 0, m = CLASS.length; i < m; i++) {
|
||||||
if (CLASS[i].substr(0,4) === "MJX-") {
|
if (CLASS[i].substr(0,4) === "MJX-") {
|
||||||
if (CLASS[i] === "MJX-arrow") {
|
if (CLASS[i] === "MJX-arrow") {
|
||||||
mml.arrow = true;
|
// This class was used in former version of MathJax to add an
|
||||||
|
// arrow to the updiagonalstrike notation. For backward
|
||||||
|
// compatibility, continue to handle this as updiagonalarrow.
|
||||||
|
mml.notation = mml.notation.replace(MML.NOTATION.UPDIAGONALSTRIKE,
|
||||||
|
MML.NOTATION.UPDIAGONALARROW);
|
||||||
} else if (CLASS[i] === "MJX-variant") {
|
} else if (CLASS[i] === "MJX-variant") {
|
||||||
mml.variantForm = true;
|
mml.variantForm = true;
|
||||||
//
|
//
|
||||||
|
|
|
@ -52,13 +52,18 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
|
||||||
var frame = HTMLCSS.createFrame(stack,H+D,0,W,t,"none");
|
var frame = HTMLCSS.createFrame(stack,H+D,0,W,t,"none");
|
||||||
frame.id = "MathJax-frame-"+this.spanID;
|
frame.id = "MathJax-frame-"+this.spanID;
|
||||||
HTMLCSS.addBox(stack,frame); stack.insertBefore(frame,base); // move base to above background
|
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 T = 0, B = 0, R = 0, L = 0, dx = 0, dy = 0; var svg, vml;
|
||||||
var w, h, r;
|
var w, h, r;
|
||||||
if (!values.mathcolor) {values.mathcolor = "black"} else {span.style.color = values.mathcolor}
|
if (!values.mathcolor) {values.mathcolor = "black"} else {span.style.color = values.mathcolor}
|
||||||
|
|
||||||
for (var i = 0, m = notation.length; i < m; i++) {
|
// perform some reduction e.g. eliminate duplicate notations.
|
||||||
switch (notation[i]) {
|
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[n]) continue;
|
||||||
|
switch (n) {
|
||||||
case MML.NOTATION.BOX:
|
case MML.NOTATION.BOX:
|
||||||
frame.style.border = SOLID; if (!HTMLCSS.msieBorderWidthBug) {T = B = L = R = t}
|
frame.style.border = SOLID; if (!HTMLCSS.msieBorderWidthBug) {T = B = L = R = t}
|
||||||
break;
|
break;
|
||||||
|
@ -130,16 +135,17 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MML.NOTATION.UPDIAGONALSTRIKE:
|
case MML.NOTATION.UPDIAGONALSTRIKE:
|
||||||
|
case MML.NOTATION.UPDIAGONALARROW:
|
||||||
if (HTMLCSS.useVML) {
|
if (HTMLCSS.useVML) {
|
||||||
if (!vml) {vml = this.HTMLvml(stack,H,D,W,t,values.mathcolor)}
|
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"});
|
var line = this.HTMLvmlElement(vml,"line",{from: "0,"+this.HTMLpx(H+D-t), to: this.HTMLpx(W)+",0"});
|
||||||
if (this.arrow) {
|
if (n == MML.NOTATION.UPDIAGONALARROW) {
|
||||||
this.HTMLvmlElement(line,"stroke",{endarrow:"classic"});
|
this.HTMLvmlElement(line,"stroke",{endarrow:"classic"});
|
||||||
line.to = this.HTMLpx(W)+","+this.HTMLpx(t);
|
line.to = this.HTMLpx(W)+","+this.HTMLpx(t);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!svg) {svg = this.HTMLsvg(stack,H,D,W,t,values.mathcolor)}
|
if (!svg) {svg = this.HTMLsvg(stack,H,D,W,t,values.mathcolor)}
|
||||||
if (this.arrow) {
|
if (n == MML.NOTATION.UPDIAGONALARROW) {
|
||||||
var l = Math.sqrt(W*W + (H+D)*(H+D)), f = 1/l * 10*scale/HTMLCSS.em * t/.075;
|
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;
|
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}
|
if (y+h-.4*w < 0) {y = .4*w-h}
|
||||||
|
|
|
@ -493,7 +493,6 @@
|
||||||
}
|
}
|
||||||
if (this.mathvariant && this.NativeMMLvariants[this.mathvariant])
|
if (this.mathvariant && this.NativeMMLvariants[this.mathvariant])
|
||||||
{CLASS.push("MJX"+this.mathvariant)}
|
{CLASS.push("MJX"+this.mathvariant)}
|
||||||
if (this.arrow) {CLASS.push("MJX-arrow")}
|
|
||||||
if (this.variantForm) {CLASS.push("MJX-variant")}
|
if (this.variantForm) {CLASS.push("MJX-variant")}
|
||||||
if (CLASS.length) {tag.setAttribute("class",CLASS.join(" "))}
|
if (CLASS.length) {tag.setAttribute("class",CLASS.join(" "))}
|
||||||
},
|
},
|
||||||
|
|
|
@ -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 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 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 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];
|
var dx = 0, w, h, i, m, borders = [false,false,false,false];
|
||||||
if (!values.mathcolor) {values.mathcolor = "black"}
|
if (!values.mathcolor) {values.mathcolor = "black"}
|
||||||
|
|
||||||
for (i = 0, m = notation.length; i < m; i++) {
|
// perform some reduction e.g. eliminate duplicate notations.
|
||||||
switch (notation[i]) {
|
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[n]) continue;
|
||||||
|
switch (n) {
|
||||||
case MML.NOTATION.BOX:
|
case MML.NOTATION.BOX:
|
||||||
borders = [true,true,true,true];
|
borders = [true,true,true,true];
|
||||||
break;
|
break;
|
||||||
|
@ -157,7 +162,8 @@ MathJax.Hub.Register.StartupHook("SVG Jax Ready",function () {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MML.NOTATION.UPDIAGONALSTRIKE:
|
case MML.NOTATION.UPDIAGONALSTRIKE:
|
||||||
if (this.arrow) {
|
case MML.NOTATION.UPDIAGONALARROW:
|
||||||
|
if (n == MML.NOTATION.UPDIAGONALARROW) {
|
||||||
var l = Math.sqrt(W*W + (H+D)*(H+D)), f = 1/l * 10/SVG.em * t/.075;
|
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;
|
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.DLINE(H-.5*h,D,W-.5*w,t,values.mathcolor,"up"));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user