Properly set displaystyle and scriptlevel, and make sure the contents is enclosed in a single element. Resolves both parts of issue #1152, but at the cost of possibly redundent mstyle elements. These could be filtered out in the combineRelations() post-filter, when we can check if the displaystyle and script levels need setting.
This commit is contained in:
parent
48b594afce
commit
3beda8db4e
|
@ -2014,15 +2014,12 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Break up a string into text and math blocks
|
* Break up a string into text and math blocks
|
||||||
* @@@ FIXME: skip over braced groups? @@@
|
|
||||||
* @@@ FIXME: pass environment to TEX.Parse? @@@
|
* @@@ FIXME: pass environment to TEX.Parse? @@@
|
||||||
*/
|
*/
|
||||||
InternalMath: function (text,level) {
|
InternalMath: function (text,level) {
|
||||||
var def = {displaystyle: false}; if (level != null) {def.scriptlevel = level}
|
var def = (this.stack.env.font ? {mathvariant: this.stack.env.font} : {});
|
||||||
if (this.stack.env.font) {def.mathvariant = this.stack.env.font}
|
var mml = [], i = 0, k = 0, c, match = '';
|
||||||
if (!text.match(/\\?[${}\\]|\\\(|\\(eq)?ref\s*\{/)) {return [this.InternalText(text,def)]}
|
if (text.match(/\\?[${}\\]|\\\(|\\(eq)?ref\s*\{/)) {
|
||||||
var i = 0, k = 0, c, match = '';
|
|
||||||
var mml = [];
|
|
||||||
while (i < text.length) {
|
while (i < text.length) {
|
||||||
c = text.charAt(i++);
|
c = text.charAt(i++);
|
||||||
if (c === '$') {
|
if (c === '$') {
|
||||||
|
@ -2030,7 +2027,7 @@
|
||||||
mml.push(MML.TeXAtom(TEX.Parse(text.slice(k,i-1),{}).mml().With(def)));
|
mml.push(MML.TeXAtom(TEX.Parse(text.slice(k,i-1),{}).mml().With(def)));
|
||||||
match = ''; k = i;
|
match = ''; k = i;
|
||||||
} else if (match === '') {
|
} else if (match === '') {
|
||||||
if (k < i-1) {mml.push(this.InternalText(text.slice(k,i-1),def))}
|
if (k < i-1) mml.push(this.InternalText(text.slice(k,i-1),def));
|
||||||
match = '$'; k = i;
|
match = '$'; k = i;
|
||||||
}
|
}
|
||||||
} else if (c === '}' && match === '}') {
|
} else if (c === '}' && match === '}') {
|
||||||
|
@ -2038,12 +2035,12 @@
|
||||||
match = ''; k = i;
|
match = ''; k = i;
|
||||||
} else if (c === '\\') {
|
} else if (c === '\\') {
|
||||||
if (match === '' && text.substr(i).match(/^(eq)?ref\s*\{/)) {
|
if (match === '' && text.substr(i).match(/^(eq)?ref\s*\{/)) {
|
||||||
if (k < i-1) {mml.push(this.InternalText(text.slice(k,i-1),def))}
|
if (k < i-1) mml.push(this.InternalText(text.slice(k,i-1),def));
|
||||||
match = '}'; k = i-1;
|
match = '}'; k = i-1;
|
||||||
} else {
|
} else {
|
||||||
c = text.charAt(i++);
|
c = text.charAt(i++);
|
||||||
if (c === '(' && match === '') {
|
if (c === '(' && match === '') {
|
||||||
if (k < i-2) {mml.push(this.InternalText(text.slice(k,i-2),def))}
|
if (k < i-2) mml.push(this.InternalText(text.slice(k,i-2),def));
|
||||||
match = ')'; k = i;
|
match = ')'; k = i;
|
||||||
} else if (c === ')' && match === ')') {
|
} else if (c === ')' && match === ')') {
|
||||||
mml.push(MML.TeXAtom(TEX.Parse(text.slice(k,i-2),{}).mml().With(def)));
|
mml.push(MML.TeXAtom(TEX.Parse(text.slice(k,i-2),{}).mml().With(def)));
|
||||||
|
@ -2054,9 +2051,11 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (match !== '')
|
if (match !== '') TEX.Error(["MathNotTerminated","Math not terminated in text box"]);
|
||||||
{TEX.Error(["MathNotTerminated","Math not terminated in text box"])}
|
}
|
||||||
if (k < text.length) {mml.push(this.InternalText(text.slice(k),def))}
|
if (k < text.length) mml.push(this.InternalText(text.slice(k),def));
|
||||||
|
var mml = [MML.mstyle.apply(MML,mml).With({displaystyle:false})];
|
||||||
|
if (level != null) mml[0].scriptlevel = level;
|
||||||
return mml;
|
return mml;
|
||||||
},
|
},
|
||||||
InternalText: function (text,def) {
|
InternalText: function (text,def) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user