Merge branch 'issue956' into develop. Issue #956.
This commit is contained in:
commit
f42c71feca
|
@ -42,10 +42,13 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
|
||||||
var CE = MathJax.Object.Subclass({
|
var CE = MathJax.Object.Subclass({
|
||||||
string: "", // the \ce string being parsed
|
string: "", // the \ce string being parsed
|
||||||
i: 0, // the current position in the string
|
i: 0, // the current position in the string
|
||||||
tex: "", // the processed TeX result
|
tex: "", // the partially processed TeX result
|
||||||
|
TEX: "", // the full TeX result
|
||||||
atom: false, // last processed token is an atom
|
atom: false, // last processed token is an atom
|
||||||
sup: "", // pending superscript
|
sup: "", // pending superscript
|
||||||
sub: "", // pending subscript
|
sub: "", // pending subscript
|
||||||
|
presup: "", // pending pre-superscript
|
||||||
|
presub: "", // pending pre-subscript
|
||||||
|
|
||||||
//
|
//
|
||||||
// Store the string when a CE object is created
|
// Store the string when a CE object is created
|
||||||
|
@ -122,7 +125,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
|
||||||
else {this["Parse"+(this.ParseTable[c]||"Other")](c)}
|
else {this["Parse"+(this.ParseTable[c]||"Other")](c)}
|
||||||
}
|
}
|
||||||
this.FinishAtom();
|
this.FinishAtom();
|
||||||
return this.tex;
|
return this.TEX;
|
||||||
},
|
},
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -299,22 +302,24 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
|
||||||
// Handle the super and subscripts for an atom
|
// Handle the super and subscripts for an atom
|
||||||
//
|
//
|
||||||
FinishAtom: function () {
|
FinishAtom: function () {
|
||||||
if (this.sup || this.sub) {
|
if (this.sup || this.sub || this.presup || this.presub) {
|
||||||
if (this.sup && this.sub && !this.atom) {
|
if (!this.atom && this.tex === "") {
|
||||||
//
|
this.presup = this.sup, this.presub = this.sub; // save for later
|
||||||
// right-justify super- and subscripts when they are before the atom
|
this.sub = this.sup = "";
|
||||||
//
|
return;
|
||||||
var sup = this.sup, sub = this.sub;
|
}
|
||||||
if (!sup.match(/\d/)) {sup += "\\vphantom{0}"} // force common heights
|
if (this.sub && !this.sup) {this.sup = "\\Space{0pt}{0pt}{.2em}"} // forces subscripts to align properly
|
||||||
if (!sub.match(/\d/)) {sub += "\\vphantom{0}"}
|
if (this.presup || this.presub) {
|
||||||
this.tex += "\\raise 1pt{\\scriptstyle\\begin{CEscriptstack}"+sup+"\\\\"+
|
if (!this.presup && !this.sup) {this.presup = "\\Space{0pt}{0pt}{.2em}"}
|
||||||
sub+"\\end{CEscriptstack}}\\kern-.125em ";
|
this.tex = "\\CEprescripts{"+(this.presub||"\\CEnone")+"}{"+(this.presup||"\\CEnone")+"}"
|
||||||
|
+ "{"+this.tex+"}{"+(this.sub||"\\CEnone")+"}{"+(this.sup||"\\CEnone")+"}";
|
||||||
|
this.presub = this.presup = "";
|
||||||
} else {
|
} else {
|
||||||
if (!this.sup) {this.sup = "\\Space{0pt}{0pt}{.2em}"} // forces subscripts to align properly
|
|
||||||
this.tex += "^{"+this.sup+"}_{"+this.sub+"}";
|
this.tex += "^{"+this.sup+"}_{"+this.sub+"}";
|
||||||
}
|
}
|
||||||
this.sup = this.sub = "";
|
this.sup = this.sub = "";
|
||||||
}
|
}
|
||||||
|
this.TEX += this.tex; this.tex = "";
|
||||||
this.atom = false;
|
this.atom = false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -376,7 +381,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
|
||||||
ce: 'CE',
|
ce: 'CE',
|
||||||
cf: 'CE',
|
cf: 'CE',
|
||||||
cee: 'CE',
|
cee: 'CE',
|
||||||
|
|
||||||
//
|
//
|
||||||
// Make these load AMSmath package (redefined below when loaded)
|
// Make these load AMSmath package (redefined below when loaded)
|
||||||
//
|
//
|
||||||
|
@ -395,6 +400,12 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
|
||||||
//
|
//
|
||||||
hyphen: ["Macro","\\text{-}"],
|
hyphen: ["Macro","\\text{-}"],
|
||||||
|
|
||||||
|
//
|
||||||
|
// Handle prescripts and none
|
||||||
|
//
|
||||||
|
CEprescripts: "CEprescripts",
|
||||||
|
CEnone: "CEnone",
|
||||||
|
|
||||||
//
|
//
|
||||||
// Needed for \bond for the ~ forms
|
// Needed for \bond for the ~ forms
|
||||||
//
|
//
|
||||||
|
@ -405,8 +416,7 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
|
||||||
// Needed for \bond for the ~ forms
|
// Needed for \bond for the ~ forms
|
||||||
//
|
//
|
||||||
environment: {
|
environment: {
|
||||||
CEstack: ['Array',null,null,null,'r',null,"0.001em",'T',1],
|
CEstack: ['Array',null,null,null,'r',null,"0.001em",'T',1]
|
||||||
CEscriptstack: ['Array',null,null,null,'r',null,"0.2em",'S',1]
|
|
||||||
}
|
}
|
||||||
},null,true);
|
},null,true);
|
||||||
|
|
||||||
|
@ -445,6 +455,22 @@ MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
|
||||||
var arg = this.GetArgument(name);
|
var arg = this.GetArgument(name);
|
||||||
var tex = CE(arg).Parse();
|
var tex = CE(arg).Parse();
|
||||||
this.string = tex + this.string.substr(this.i); this.i = 0;
|
this.string = tex + this.string.substr(this.i); this.i = 0;
|
||||||
|
},
|
||||||
|
|
||||||
|
//
|
||||||
|
// Implements \CEprescripts{presub}{presup}{base}{sub}{sup}
|
||||||
|
//
|
||||||
|
CEprescripts: function (name) {
|
||||||
|
var presub = this.ParseArg(name),
|
||||||
|
presup = this.ParseArg(name),
|
||||||
|
base = this.ParseArg(name),
|
||||||
|
sub = this.ParseArg(name),
|
||||||
|
sup = this.ParseArg(name);
|
||||||
|
var MML = MathJax.ElementJax.mml;
|
||||||
|
this.Push(MML.mmultiscripts(base,sub,sup,MML.mprescripts(),presub,presup));
|
||||||
|
},
|
||||||
|
CEnone: function (name) {
|
||||||
|
this.Push(MathJax.ElementJax.mml.none());
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user