Handle primes followed by superscript as TeX does in TeX input jax (resolves issue #278)
This commit is contained in:
parent
a93c59e669
commit
0c02ab2670
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
@ -12,5 +12,5 @@
|
|||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*/
|
||||
|
||||
MathJax.InputJax.TeX=MathJax.InputJax({id:"TeX",version:"2.0.2",directory:MathJax.InputJax.directory+"/TeX",extensionDir:MathJax.InputJax.extensionDir+"/TeX",config:{TagSide:"right",TagIndent:"0.8em",MultLineWidth:"85%",equationNumbers:{autoNumber:"none",formatNumber:function(a){return a},formatTag:function(a){return"("+a+")"},formatID:function(a){return"mjx-eqn-"+String(a).replace(/[:"'<>&]/g,"")},formatURL:function(a){return"#"+escape(a)},useLabelIds:true}}});MathJax.InputJax.TeX.Register("math/tex");MathJax.InputJax.TeX.loadComplete("config.js");
|
||||
MathJax.InputJax.TeX=MathJax.InputJax({id:"TeX",version:"2.0.3",directory:MathJax.InputJax.directory+"/TeX",extensionDir:MathJax.InputJax.extensionDir+"/TeX",config:{TagSide:"right",TagIndent:"0.8em",MultLineWidth:"85%",equationNumbers:{autoNumber:"none",formatNumber:function(a){return a},formatTag:function(a){return"("+a+")"},formatID:function(a){return"mjx-eqn-"+String(a).replace(/[:"'<>&]/g,"")},formatURL:function(a){return"#"+escape(a)},useLabelIds:true}}});MathJax.InputJax.TeX.Register("math/tex");MathJax.InputJax.TeX.loadComplete("config.js");
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -24,7 +24,7 @@
|
|||
|
||||
MathJax.InputJax.TeX = MathJax.InputJax({
|
||||
id: "TeX",
|
||||
version: "2.0.2",
|
||||
version: "2.0.3",
|
||||
directory: MathJax.InputJax.directory + "/TeX",
|
||||
extensionDir: MathJax.InputJax.extensionDir + "/TeX",
|
||||
|
||||
|
|
|
@ -135,6 +135,16 @@
|
|||
type: "close", isClose: true
|
||||
});
|
||||
|
||||
STACKITEM.prime = STACKITEM.Subclass({
|
||||
type: "prime",
|
||||
checkItem: function (item) {
|
||||
if (this.data[0].type !== "msubsup")
|
||||
{return [MML.msup(this.data[0],this.data[1]),item]}
|
||||
this.data[0].SetData(this.data[0].sup,this.data[1]);
|
||||
return [this.data[0],item];
|
||||
}
|
||||
});
|
||||
|
||||
STACKITEM.subsup = STACKITEM.Subclass({
|
||||
type: "subsup",
|
||||
stopError: "Missing superscript or subscript argument",
|
||||
|
@ -142,6 +152,10 @@
|
|||
var script = ["","subscript","superscript"][this.position];
|
||||
if (item.type === "open" || item.type === "left") {return true}
|
||||
if (item.type === "mml") {
|
||||
if (this.primes) {
|
||||
if (this.position === 2) {item.data[0] = MML.mrow(this.primes,item.data[0])}
|
||||
else {this.data[0].SetData(2,this.primes)}
|
||||
}
|
||||
this.data[0].SetData(this.position,item.data[0]);
|
||||
return STACKITEM.mml(this.data[0]);
|
||||
}
|
||||
|
@ -1141,13 +1155,12 @@
|
|||
Superscript: function (c) {
|
||||
if (this.GetNext().match(/\d/)) // don't treat numbers as a unit
|
||||
{this.string = this.string.substr(0,this.i+1)+" "+this.string.substr(this.i+1)}
|
||||
var position, base = this.stack.Prev(); if (!base) {base = MML.mi("")}
|
||||
var position, primes, base, top = this.stack.Top();
|
||||
if (top.type === "prime") {base = top.data[0]; primes = top.data[1]; this.stack.Pop()}
|
||||
else {base = this.stack.Prev(); if (!base) {base = MML.mi("")}}
|
||||
if (base.isEmbellishedWrapper) {base = base.data[0].data[0]}
|
||||
if (base.type === "msubsup") {
|
||||
if (base.data[base.sup]) {
|
||||
if (!base.data[base.sup].isPrime) {TEX.Error("Double exponent: use braces to clarify")}
|
||||
base = MML.msubsup(base,null,null);
|
||||
}
|
||||
if (base.data[base.sup]) {TEX.Error("Double exponent: use braces to clarify")}
|
||||
position = base.sup;
|
||||
} else if (base.movesupsub) {
|
||||
if (base.type !== "munderover" || base.data[base.over]) {
|
||||
|
@ -1159,12 +1172,14 @@
|
|||
base = MML.msubsup(base,null,null);
|
||||
position = base.sup;
|
||||
}
|
||||
this.Push(STACKITEM.subsup(base).With({position: position}));
|
||||
this.Push(STACKITEM.subsup(base).With({position: position, primes: primes}));
|
||||
},
|
||||
Subscript: function (c) {
|
||||
if (this.GetNext().match(/\d/)) // don't treat numbers as a unit
|
||||
{this.string = this.string.substr(0,this.i+1)+" "+this.string.substr(this.i+1)}
|
||||
var position, base = this.stack.Prev(); if (!base) {base = MML.mi("")}
|
||||
var position, primes, base, top = this.stack.Top();
|
||||
if (top.type === "prime") {base = top.data[0]; primes = top.data[1]; this.stack.Pop()}
|
||||
else {base = this.stack.Prev(); if (!base) {base = MML.mi("")}}
|
||||
if (base.isEmbellishedWrapper) {base = base.data[0].data[0]}
|
||||
if (base.type === "msubsup") {
|
||||
if (base.data[base.sub]) {TEX.Error("Double subscripts: use braces to clarify")}
|
||||
|
@ -1179,7 +1194,7 @@
|
|||
base = MML.msubsup(base,null,null);
|
||||
position = base.sub;
|
||||
}
|
||||
this.Push(STACKITEM.subsup(base).With({position: position}));
|
||||
this.Push(STACKITEM.subsup(base).With({position: position, primes: primes}));
|
||||
},
|
||||
PRIME: "\u2032", SMARTQUOTE: "\u2019",
|
||||
Prime: function (c) {
|
||||
|
@ -1189,8 +1204,7 @@
|
|||
var sup = ""; this.i--;
|
||||
do {sup += this.PRIME; this.i++, c = this.GetNext()}
|
||||
while (c === "'" || c === this.SMARTQUOTE);
|
||||
sup = this.mmlToken(MML.mo(MML.chars(sup)).With({isPrime: true}));
|
||||
this.Push(MML.msup(base,sup));
|
||||
this.Push(STACKITEM.prime(base,this.mmlToken(MML.mo(sup))));
|
||||
},
|
||||
mi2mo: function (mi) {
|
||||
var mo = MML.mo(); mo.Append.apply(mo,mi.data); var id;
|
||||
|
|
Loading…
Reference in New Issue
Block a user