Make an HTMLCSS.unEm() function to undo HTMLCSS.Em(), and use that rather than parseFloat() so that the code is not dependent on the use of em's but could be converted to px, for example, if that helps some spacing issues.
This commit is contained in:
parent
55f735c65f
commit
905cf229eb
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.OutputJax["HTML-CSS"]=MathJax.OutputJax({id:"HTML-CSS",version:"2.0.7",directory:MathJax.OutputJax.directory+"/HTML-CSS",extensionDir:MathJax.OutputJax.extensionDir+"/HTML-CSS",autoloadDir:MathJax.OutputJax.directory+"/HTML-CSS/autoload",fontDir:MathJax.OutputJax.directory+"/HTML-CSS/fonts",webfontDir:MathJax.OutputJax.fontDir+"/HTML-CSS",config:{scale:100,minScaleAdjust:50,availableFonts:["STIX","TeX"],preferredFont:"TeX",webFont:"TeX",imageFont:"TeX",undefinedFamily:"STIXGeneral,'Arial Unicode MS',serif",mtextFontInherit:false,EqnChunk:(MathJax.Hub.Browser.isMobile?10:50),EqnChunkFactor:1.5,EqnChunkDelay:100,linebreaks:{automatic:false,width:"container"},styles:{".MathJax_Display":{"text-align":"center",margin:"1em 0em"},".MathJax .merror":{"background-color":"#FFFF88",color:"#CC0000",border:"1px solid #CC0000",padding:"1px 3px","font-style":"normal","font-size":"90%"},"#MathJax_Tooltip":{"background-color":"InfoBackground",color:"InfoText",border:"1px solid black","box-shadow":"2px 2px 5px #AAAAAA","-webkit-box-shadow":"2px 2px 5px #AAAAAA","-moz-box-shadow":"2px 2px 5px #AAAAAA","-khtml-box-shadow":"2px 2px 5px #AAAAAA",filter:"progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color='gray', Positive='true')",padding:"3px 4px"}}}});if(MathJax.Hub.Browser.isMSIE&&document.documentMode>=9){delete MathJax.OutputJax["HTML-CSS"].config.styles["#MathJax_Tooltip"].filter}if(!MathJax.Hub.config.delayJaxRegistration){MathJax.OutputJax["HTML-CSS"].Register("jax/mml")}MathJax.Hub.Register.StartupHook("End Config",[function(b,c){var a=b.Insert({minBrowserVersion:{Firefox:3,Opera:9.52,MSIE:6,Chrome:0.3,Safari:2,Konqueror:4},inlineMathDelimiters:["$","$"],displayMathDelimiters:["$$","$$"],multilineDisplay:true,minBrowserTranslate:function(f){var e=b.getJaxFor(f),k=["[Math]"],j;var h=document.createElement("span",{className:"MathJax_Preview"});if(e.inputJax==="TeX"){if(e.root.Get("displaystyle")){j=a.displayMathDelimiters;k=[j[0]+e.originalText+j[1]];if(a.multilineDisplay){k=k[0].split(/\n/)}}else{j=a.inlineMathDelimiters;k=[j[0]+e.originalText.replace(/^\s+/,"").replace(/\s+$/,"")+j[1]]}}for(var g=0,d=k.length;g<d;g++){h.appendChild(document.createTextNode(k[g]));if(g<d-1){h.appendChild(document.createElement("br"))}}f.parentNode.insertBefore(h,f)}},(b.config["HTML-CSS"]||{}));if(b.Browser.version!=="0.0"&&!b.Browser.versionAtLeast(a.minBrowserVersion[b.Browser]||0)){c.Translate=a.minBrowserTranslate;b.Config({showProcessingMessages:false});MathJax.Message.Set("Your browser does not support MathJax",null,4000);b.Startup.signal.Post("MathJax not supported")}},MathJax.Hub,MathJax.OutputJax["HTML-CSS"]]);MathJax.OutputJax["HTML-CSS"].loadComplete("config.js");
|
||||
MathJax.OutputJax["HTML-CSS"]=MathJax.OutputJax({id:"HTML-CSS",version:"2.0.8",directory:MathJax.OutputJax.directory+"/HTML-CSS",extensionDir:MathJax.OutputJax.extensionDir+"/HTML-CSS",autoloadDir:MathJax.OutputJax.directory+"/HTML-CSS/autoload",fontDir:MathJax.OutputJax.directory+"/HTML-CSS/fonts",webfontDir:MathJax.OutputJax.fontDir+"/HTML-CSS",config:{scale:100,minScaleAdjust:50,availableFonts:["STIX","TeX"],preferredFont:"TeX",webFont:"TeX",imageFont:"TeX",undefinedFamily:"STIXGeneral,'Arial Unicode MS',serif",mtextFontInherit:false,EqnChunk:(MathJax.Hub.Browser.isMobile?10:50),EqnChunkFactor:1.5,EqnChunkDelay:100,linebreaks:{automatic:false,width:"container"},styles:{".MathJax_Display":{"text-align":"center",margin:"1em 0em"},".MathJax .merror":{"background-color":"#FFFF88",color:"#CC0000",border:"1px solid #CC0000",padding:"1px 3px","font-style":"normal","font-size":"90%"},"#MathJax_Tooltip":{"background-color":"InfoBackground",color:"InfoText",border:"1px solid black","box-shadow":"2px 2px 5px #AAAAAA","-webkit-box-shadow":"2px 2px 5px #AAAAAA","-moz-box-shadow":"2px 2px 5px #AAAAAA","-khtml-box-shadow":"2px 2px 5px #AAAAAA",filter:"progid:DXImageTransform.Microsoft.dropshadow(OffX=2, OffY=2, Color='gray', Positive='true')",padding:"3px 4px"}}}});if(MathJax.Hub.Browser.isMSIE&&document.documentMode>=9){delete MathJax.OutputJax["HTML-CSS"].config.styles["#MathJax_Tooltip"].filter}if(!MathJax.Hub.config.delayJaxRegistration){MathJax.OutputJax["HTML-CSS"].Register("jax/mml")}MathJax.Hub.Register.StartupHook("End Config",[function(b,c){var a=b.Insert({minBrowserVersion:{Firefox:3,Opera:9.52,MSIE:6,Chrome:0.3,Safari:2,Konqueror:4},inlineMathDelimiters:["$","$"],displayMathDelimiters:["$$","$$"],multilineDisplay:true,minBrowserTranslate:function(f){var e=b.getJaxFor(f),k=["[Math]"],j;var h=document.createElement("span",{className:"MathJax_Preview"});if(e.inputJax==="TeX"){if(e.root.Get("displaystyle")){j=a.displayMathDelimiters;k=[j[0]+e.originalText+j[1]];if(a.multilineDisplay){k=k[0].split(/\n/)}}else{j=a.inlineMathDelimiters;k=[j[0]+e.originalText.replace(/^\s+/,"").replace(/\s+$/,"")+j[1]]}}for(var g=0,d=k.length;g<d;g++){h.appendChild(document.createTextNode(k[g]));if(g<d-1){h.appendChild(document.createElement("br"))}}f.parentNode.insertBefore(h,f)}},(b.config["HTML-CSS"]||{}));if(b.Browser.version!=="0.0"&&!b.Browser.versionAtLeast(a.minBrowserVersion[b.Browser]||0)){c.Translate=a.minBrowserTranslate;b.Config({showProcessingMessages:false});MathJax.Message.Set("Your browser does not support MathJax",null,4000);b.Startup.signal.Post("MathJax not supported")}},MathJax.Hub,MathJax.OutputJax["HTML-CSS"]]);MathJax.OutputJax["HTML-CSS"].loadComplete("config.js");
|
||||
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -22,7 +22,7 @@
|
|||
*/
|
||||
|
||||
MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
|
||||
var VERSION = "2.0";
|
||||
var VERSION = "2.0.1";
|
||||
var MML = MathJax.ElementJax.mml,
|
||||
HTMLCSS = MathJax.OutputJax["HTML-CSS"];
|
||||
|
||||
|
@ -302,7 +302,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
|
|||
// Set width/position based on the type of column
|
||||
//
|
||||
if (CWIDTH[j].match(/%$/)) {
|
||||
var pp = parseFloat(CWIDTH[j]) * Wf;
|
||||
var pp = HTMLCSS.unEm(CWIDTH[j]) * Wf;
|
||||
if (f === 0) {
|
||||
CjStyle.width = (wp + pp) + "%"; xp += wp + pp;
|
||||
Cj = HTMLCSS.createBox(Cj); HTMLCSS.addBox(Cj,C[j].firstChild);
|
||||
|
@ -431,7 +431,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
|
|||
},
|
||||
HTMLhandleSpace: function (span) {
|
||||
span.bbox.keepPadding = true; span.bbox.exact = true;
|
||||
if (!this.hasFrame) {span.style.paddingLeft = span.style.paddingRight = ".1667em"}
|
||||
if (!this.hasFrame) {span.style.paddingLeft = span.style.paddingRight = HTMLCSS.Em(1/6)}
|
||||
this.SUPER(arguments).HTMLhandleSpace.call(this,span);
|
||||
}
|
||||
});
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
*/
|
||||
|
||||
MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
|
||||
var VERSION = "2.0.1";
|
||||
var VERSION = "2.0.2";
|
||||
var MML = MathJax.ElementJax.mml,
|
||||
HTMLCSS = MathJax.OutputJax["HTML-CSS"];
|
||||
|
||||
|
@ -163,8 +163,8 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
|
|||
if (!broken) {
|
||||
var span = this.data[i].HTMLspanElement();
|
||||
scanW += span.bbox.w;
|
||||
if (span.style.paddingLeft) {scanW += parseFloat(span.style.paddingLeft)}
|
||||
if (span.style.paddingRight) {scanW += parseFloat(span.style.paddingRight)}
|
||||
if (span.style.paddingLeft) {scanW += HTMLCSS.unEm(span.style.paddingLeft)}
|
||||
if (span.style.paddingRight) {scanW += HTMLCSS.unEm(span.style.paddingRight)}
|
||||
info.W = info.scanW = scanW;
|
||||
}
|
||||
}
|
||||
|
@ -394,7 +394,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
|
|||
//
|
||||
var W = info.scanW, mo = (info.embellished||this); delete info.embellished;
|
||||
var span = mo.HTMLspanElement(), w = span.bbox.w;
|
||||
if (span.style.paddingLeft) {w += parseFloat(span.style.paddingLeft)}
|
||||
if (span.style.paddingLeft) {w += HTMLCSS.unEm(span.style.paddingLeft)}
|
||||
if (values.linebreakstyle === MML.LINEBREAKSTYLE.AFTER) {W += w; w = 0}
|
||||
if (W - info.shift === 0) {return false} // don't break at zero width (FIXME?)
|
||||
var offset = HTMLCSS.linebreakWidth - W;
|
||||
|
@ -445,7 +445,7 @@ MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function () {
|
|||
// Get the default penalty for this location
|
||||
//
|
||||
var W = info.scanW, span = this.HTMLspanElement(), w = span.bbox.w;
|
||||
if (span.style.paddingLeft) {w += parseFloat(span.style.paddingLeft)}
|
||||
if (span.style.paddingLeft) {w += HTMLCSS.unEm(span.style.paddingLeft)}
|
||||
if (values.linebreakstyle === MML.LINEBREAKSTYLE.AFTER) {W += w; w = 0}
|
||||
if (W - info.shift === 0) {return false} // don't break at zero width (FIXME?)
|
||||
var offset = HTMLCSS.linebreakWidth - W;
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
|
||||
MathJax.OutputJax["HTML-CSS"] = MathJax.OutputJax({
|
||||
id: "HTML-CSS",
|
||||
version: "2.0.7",
|
||||
version: "2.0.8",
|
||||
directory: MathJax.OutputJax.directory + "/HTML-CSS",
|
||||
extensionDir: MathJax.OutputJax.extensionDir + "/HTML-CSS",
|
||||
autoloadDir: MathJax.OutputJax.directory + "/HTML-CSS/autoload",
|
||||
|
|
|
@ -807,6 +807,9 @@
|
|||
if (Math.abs(m) < .0006) {return "0em"}
|
||||
return m.toFixed(3).replace(/\.?0+$/,"") + "em";
|
||||
},
|
||||
unEm: function (m) {
|
||||
return parseFloat(m);
|
||||
},
|
||||
Percent: function (m) {
|
||||
return (100*m).toFixed(1).replace(/\.?0+$/,"") + "%";
|
||||
},
|
||||
|
@ -1053,7 +1056,7 @@
|
|||
var r = 0, c = -bbox.w/2, l = "50%";
|
||||
if (this.initialSkipBug) {r = bbox.w-bbox.rw-.1; c += bbox.lw}
|
||||
if (this.msieMarginScaleBug) {c = (c*this.em) + "px"} else {c = this.Em(c)}
|
||||
if (isRelative) {c = ""; l = (50 - parseFloat(bbox.width)/2) + "%"}
|
||||
if (isRelative) {c = ""; l = (50 - HTMLCSS.unEm(bbox.width)/2) + "%"}
|
||||
HUB.Insert(span.style,({
|
||||
right: {left:"", right: this.Em(r)},
|
||||
center: {left:l, marginLeft: c}
|
||||
|
@ -1223,7 +1226,7 @@
|
|||
if (this.safariVerticalAlignBug || this.konquerorVerticalAlignBug ||
|
||||
(this.operaVerticalAlignBug && span.isMultiChar)) {
|
||||
if (span.firstChild.style.display === "" && span.style.top !== "")
|
||||
{span = span.firstChild; h -= parseFloat(span.style.top)}
|
||||
{span = span.firstChild; h -= HTMLCSS.unEm(span.style.top)}
|
||||
span.style.position = "relative";
|
||||
span.style.top = this.Em(-h);
|
||||
} else {
|
||||
|
@ -1561,11 +1564,11 @@
|
|||
if (bbox.h > BBOX.h) {BBOX.h = bbox.h}
|
||||
if (bbox.D != null && bbox.D > BBOX.D) {BBOX.D = bbox.D}
|
||||
if (bbox.H != null && bbox.H > BBOX.H) {BBOX.H = bbox.H}
|
||||
if (child.style.paddingLeft) {BBOX.w += parseFloat(child.style.paddingLeft)*(child.scale||1)}
|
||||
if (child.style.paddingLeft) {BBOX.w += HTMLCSS.unEm(child.style.paddingLeft)*(child.scale||1)}
|
||||
if (BBOX.w + bbox.lw < BBOX.lw) {BBOX.lw = BBOX.w + bbox.lw}
|
||||
if (BBOX.w + bbox.rw > BBOX.rw) {BBOX.rw = BBOX.w + bbox.rw}
|
||||
BBOX.w += bbox.w;
|
||||
if (child.style.paddingRight) {BBOX.w += parseFloat(child.style.paddingRight)*(child.scale||1)}
|
||||
if (child.style.paddingRight) {BBOX.w += HTMLCSS.unEm(child.style.paddingRight)*(child.scale||1)}
|
||||
if (bbox.width) {BBOX.width = bbox.width}
|
||||
if (bbox.ic) {BBOX.ic = bbox.ic} else {delete BBOX.ic}
|
||||
if (BBOX.exactW && !bbox.exactW) {delete BBOX.exactW}
|
||||
|
@ -1665,8 +1668,8 @@
|
|||
var bbox = span.bbox, dd = (bbox.exact ? 0 : 1/HTMLCSS.em), lW = 0, rW = 0,
|
||||
lpad = span.style.paddingLeft, rpad = span.style.paddingRight;
|
||||
if (this.isToken) {lW = bbox.lw; rW = bbox.rw - bbox.w}
|
||||
if (lpad !== "") {lW += parseFloat(lpad)*(span.scale||1)}
|
||||
if (rpad !== "") {rW -= parseFloat(rpad)*(span.scale||1)}
|
||||
if (lpad !== "") {lW += HTMLCSS.unEm(lpad)*(span.scale||1)}
|
||||
if (rpad !== "") {rW -= HTMLCSS.unEm(rpad)*(span.scale||1)}
|
||||
var dw = (HTMLCSS.PaddingWidthBug || bbox.keepPadding || bbox.exactW ? 0 : rW - lW);
|
||||
var W = Math.max(0,HTMLCSS.getW(span) + dw);
|
||||
var H = bbox.h + bbox.d, D = -bbox.d, lp = 0, rp = 0;
|
||||
|
@ -1738,7 +1741,7 @@
|
|||
var space = this.texSpacing();
|
||||
if (space !== "") {
|
||||
space = HTMLCSS.length2em(space,this.HTMLgetScale())/(span.scale||1);
|
||||
if (span.style.paddingLeft) {space += parseFloat(span.style.paddingLeft)}
|
||||
if (span.style.paddingLeft) {space += HTMLCSS.unEm(span.style.paddingLeft)}
|
||||
span.style.paddingLeft = HTMLCSS.Em(space);
|
||||
}
|
||||
}
|
||||
|
@ -1961,7 +1964,7 @@
|
|||
var p = (span.bbox.h - span.bbox.d)/2 - HTMLCSS.TeX.axis_height*span.scale;
|
||||
if (HTMLCSS.safariVerticalAlignBug && span.lastChild.nodeName === "IMG") {
|
||||
span.lastChild.style.verticalAlign =
|
||||
HTMLCSS.Em(parseFloat(span.lastChild.style.verticalAlign||0)/HTMLCSS.em-p/span.scale);
|
||||
HTMLCSS.Em(HTMLCSS.unEm(span.lastChild.style.verticalAlign||0)/HTMLCSS.em-p/span.scale);
|
||||
} else if (HTMLCSS.konquerorVerticalAlignBug && span.lastChild.nodeName === "IMG") {
|
||||
span.style.position = "relative";
|
||||
span.lastChild.style.position="relative";
|
||||
|
@ -2268,8 +2271,8 @@
|
|||
HTMLhandleSpace: function (span) {
|
||||
if (!this.texWithDelims) {
|
||||
var space = (this.useMMLspacing ? 0 : HTMLCSS.length2em(this.texSpacing()||0)) + .12;
|
||||
span.style.paddingLeft = HTMLCSS.Em(space);
|
||||
span.style.paddingRight = ".12em";
|
||||
span.style.paddingLeft = HTMLCSS.Em(space);
|
||||
span.style.paddingRight = HTMLCSS.Em(.12);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user