Implement TeX spacing (as well as MathML spacing)
This commit is contained in:
parent
2837c5f114
commit
8e1e853346
|
@ -65,7 +65,7 @@
|
||||||
".MJXc-rule": {"display":"block!important", "margin-top":"1px"},
|
".MJXc-rule": {"display":"block!important", "margin-top":"1px"},
|
||||||
".MJXc-char": {"display":"block!important"},
|
".MJXc-char": {"display":"block!important"},
|
||||||
|
|
||||||
".MJXc-mo": {"margin": "0 .15em"},
|
// ".MJXc-mo": {"margin": "0 .15em"},
|
||||||
|
|
||||||
".MJXc-mfrac": {"margin": "0 .125em", "vertical-align":".25em",
|
".MJXc-mfrac": {"margin": "0 .125em", "vertical-align":".25em",
|
||||||
"display": "inline-table!important", "text-align":"center"},
|
"display": "inline-table!important", "text-align":"center"},
|
||||||
|
@ -238,7 +238,7 @@
|
||||||
// Typeset the math
|
// Typeset the math
|
||||||
//
|
//
|
||||||
this.initCHTML(math,span);
|
this.initCHTML(math,span);
|
||||||
// math.setTeXclass();
|
math.setTeXclass();
|
||||||
try {math.toCommonHTML(span)} catch (err) {
|
try {math.toCommonHTML(span)} catch (err) {
|
||||||
if (err.restart) {while (span.firstChild) {span.removeChild(span.firstChild)}}
|
if (err.restart) {while (span.firstChild) {span.removeChild(span.firstChild)}}
|
||||||
throw err;
|
throw err;
|
||||||
|
@ -574,6 +574,9 @@
|
||||||
REMAPACCENTUNDER: {
|
REMAPACCENTUNDER: {
|
||||||
},
|
},
|
||||||
|
|
||||||
|
//
|
||||||
|
// ### FIXME: Handle mu's
|
||||||
|
//
|
||||||
length2em: function (length,size) {
|
length2em: function (length,size) {
|
||||||
if (typeof(length) !== "string") {length = length.toString()}
|
if (typeof(length) !== "string") {length = length.toString()}
|
||||||
if (length === "") {return ""}
|
if (length === "") {return ""}
|
||||||
|
@ -625,9 +628,9 @@
|
||||||
CHTMLdefaultSpan: function (span,options) {
|
CHTMLdefaultSpan: function (span,options) {
|
||||||
if (!options) options = {};
|
if (!options) options = {};
|
||||||
span = this.CHTMLcreateSpan(span);
|
span = this.CHTMLcreateSpan(span);
|
||||||
|
this.CHTMLhandleSpace(span);
|
||||||
this.CHTMLhandleStyle(span);
|
this.CHTMLhandleStyle(span);
|
||||||
this.CHTMLhandleColor(span);
|
this.CHTMLhandleColor(span);
|
||||||
if (this.isToken) this.CHTMLhandleToken(span);
|
|
||||||
for (var i = 0, m = this.data.length; i < m; i++) this.CHTMLaddChild(span,i,options);
|
for (var i = 0, m = this.data.length; i < m; i++) this.CHTMLaddChild(span,i,options);
|
||||||
if (!options.noMargins && !options.noBBox) this.CHTMLhandleMargins(span);
|
if (!options.noMargins && !options.noBBox) this.CHTMLhandleMargins(span);
|
||||||
return span;
|
return span;
|
||||||
|
@ -675,9 +678,6 @@
|
||||||
return document.getElementById(this.id||"MJXc-Span-"+this.CHTMLspanID);
|
return document.getElementById(this.id||"MJXc-Span-"+this.CHTMLspanID);
|
||||||
},
|
},
|
||||||
|
|
||||||
CHTMLhandleToken: function (span) {
|
|
||||||
},
|
|
||||||
|
|
||||||
CHTMLhandleStyle: function (span) {
|
CHTMLhandleStyle: function (span) {
|
||||||
if (this.style) span.style.cssText = this.style;
|
if (this.style) span.style.cssText = this.style;
|
||||||
},
|
},
|
||||||
|
@ -689,6 +689,13 @@
|
||||||
else if (this.background) {span.style.backgroundColor = this.background}
|
else if (this.background) {span.style.backgroundColor = this.background}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
CHTMLhandleSpace: function (span) {
|
||||||
|
if (!this.useMMLspacing) {
|
||||||
|
var space = this.texSpacing();
|
||||||
|
if (space !== "") span.style.marginLeft = CHTML.Em(CHTML.length2em(space));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
CHTMLhandleScriptlevel: function (span,dlevel) {
|
CHTMLhandleScriptlevel: function (span,dlevel) {
|
||||||
var level = this.Get("scriptlevel");
|
var level = this.Get("scriptlevel");
|
||||||
if (level === 0) return;
|
if (level === 0) return;
|
||||||
|
@ -782,16 +789,18 @@
|
||||||
toCommonHTML: function (span) {
|
toCommonHTML: function (span) {
|
||||||
span = this.CHTMLdefaultSpan(span);
|
span = this.CHTMLdefaultSpan(span);
|
||||||
this.CHTMLadjustAccent(span);
|
this.CHTMLadjustAccent(span);
|
||||||
var values = this.getValues("lspace","rspace","scriptlevel","displaystyle","largeop");
|
var values = this.getValues(/*"lspace","rspace","scriptlevel",*/"displaystyle","largeop");
|
||||||
if (values.scriptlevel === 0) {
|
/*
|
||||||
this.CHTML.L = CHTML.length2em(values.lspace);
|
* if (values.scriptlevel === 0) {
|
||||||
this.CHTML.R = CHTML.length2em(values.rspace);
|
* this.CHTML.L = CHTML.length2em(values.lspace);
|
||||||
span.style.marginLeft = CHTML.Em(this.CHTML.L);
|
* this.CHTML.R = CHTML.length2em(values.rspace);
|
||||||
span.style.marginRight = CHTML.Em(this.CHTML.R);
|
* span.style.marginLeft = CHTML.Em(this.CHTML.L);
|
||||||
} else {
|
* span.style.marginRight = CHTML.Em(this.CHTML.R);
|
||||||
this.CHTML.L = .15;
|
* } else {
|
||||||
this.CHTML.R = .1;
|
* this.CHTML.L = .15;
|
||||||
}
|
* this.CHTML.R = .1;
|
||||||
|
* }
|
||||||
|
*/
|
||||||
if (values.displaystyle && values.largeop) {
|
if (values.displaystyle && values.largeop) {
|
||||||
var box = HTML.Element("span",{className:"MJXc-largeop"});
|
var box = HTML.Element("span",{className:"MJXc-largeop"});
|
||||||
box.appendChild(span.firstChild); span.appendChild(box);
|
box.appendChild(span.firstChild); span.appendChild(box);
|
||||||
|
@ -802,6 +811,24 @@
|
||||||
// ### FIXME: Remap minus signs
|
// ### FIXME: Remap minus signs
|
||||||
return span;
|
return span;
|
||||||
},
|
},
|
||||||
|
CHTMLhandleSpace: function (span) {
|
||||||
|
if (this.useMMLspacing) {
|
||||||
|
var values = this.getValues("scriptlevel","lspace","rspace");
|
||||||
|
values.lspace = Math.max(0,CHTML.length2em(values.lspace));
|
||||||
|
values.rspace = Math.max(0,CHTML.length2em(values.rspace));
|
||||||
|
if (values.scriptlevel > 0) {
|
||||||
|
if (!this.hasValue("lspace")) values.lspace = .15;
|
||||||
|
if (!this.hasValue("rspace")) values.rspace = .15;
|
||||||
|
}
|
||||||
|
var core = this, parent = this.Parent();
|
||||||
|
while (parent && parent.isEmbellished() && parent.Core() === core)
|
||||||
|
{core = parent; parent = parent.Parent(); span = core.CHTMLspanElement()}
|
||||||
|
if (values.lspace) {span.style.paddingLeft = CHTML.Em(values.lspace)}
|
||||||
|
if (values.rspace) {span.style.paddingRight = CHTML.Em(values.rspace)}
|
||||||
|
} else {
|
||||||
|
this.SUPER(arguments).CHTMLhandleSpace.apply(this,arguments);
|
||||||
|
}
|
||||||
|
},
|
||||||
CHTMLadjustAccent: function (span) {
|
CHTMLadjustAccent: function (span) {
|
||||||
var parent = this.CoreParent();
|
var parent = this.CoreParent();
|
||||||
if (parent && parent.isa(MML.munderover) &&
|
if (parent && parent.isa(MML.munderover) &&
|
||||||
|
@ -1116,6 +1143,7 @@
|
||||||
MML.mfenced.Augment({
|
MML.mfenced.Augment({
|
||||||
toCommonHTML: function (span) {
|
toCommonHTML: function (span) {
|
||||||
span = this.CHTMLcreateSpan(span);
|
span = this.CHTMLcreateSpan(span);
|
||||||
|
this.CHTMLhandleSpace(span);
|
||||||
this.CHTMLhandleStyle(span);
|
this.CHTMLhandleStyle(span);
|
||||||
this.CHTMLhandleColor(span);
|
this.CHTMLhandleColor(span);
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue
Block a user