Stackedit/lib/MathJax/jax/output/HTML-CSS/autoload/mtable.js

17 lines
11 KiB
JavaScript
Raw Normal View History

2013-05-12 00:48:25 +00:00
/*
* /MathJax/jax/output/HTML-CSS/autoload/mtable.js
*
* Copyright (c) 2012 Design Science, Inc.
*
* Part of the MathJax library.
* See http://www.mathjax.org for details.
*
* Licensed under the Apache License, Version 2.0;
* you may not use this file except in compliance with the License.
*
* http://www.apache.org/licenses/LICENSE-2.0
*/
MathJax.Hub.Register.StartupHook("HTML-CSS Jax Ready",function(){var c="2.1";var a=MathJax.ElementJax.mml,b=MathJax.OutputJax["HTML-CSS"];a.mtable.Augment({toHTML:function(r){r=this.HTMLcreateSpan(r);if(this.data.length===0){return r}var G=this.getValues("columnalign","rowalign","columnspacing","rowspacing","columnwidth","equalcolumns","equalrows","columnlines","rowlines","frame","framespacing","align","useHeight","width","side","minlabelspacing");var aF=G.width.match(/%$/);var av=b.createStack(r);var aC=this.HTMLgetScale(),ax=this.HTMLgetMu(r),ay=-1;var ao=[],ar=[],ai=[],au=[],at=[],ad,ac,an=-1,ab,am,V,aB,O,az,aK=[];var aj=b.FONTDATA.baselineskip*aC*G.useHeight,aP,E=b.FONTDATA.lineH*aC,L=b.FONTDATA.lineD*aC;for(ad=0,ab=this.data.length;ad<ab;ad++){aB=this.data[ad];V=(aB.type==="mlabeledtr"?ay:0);au[ad]=[];ao[ad]=ar[ad]=0;for(ac=V,am=aB.data.length+V;ac<am;ac++){if(ai[ac]==null){if(ac>an){an=ac}at[ac]=b.createStack(b.createBox(av));ai[ac]=-b.BIGDIMEN}au[ad][ac]=b.createBox(at[ac]);aK.push(aB.data[ac-V].toHTML(au[ad][ac]))}}b.MeasureSpans(aK);for(ad=0,ab=this.data.length;ad<ab;ad++){aB=this.data[ad];V=(aB.type==="mlabeledtr"?ay:0);for(ac=V,am=aB.data.length+V;ac<am;ac++){O=aB.data[ac-V];if(O.isMultiline){au[ad][ac].style.width="100%"}if(O.isEmbellished()){az=O.CoreMO();var aO=az.Get("minsize",true);if(aO){var aH=az.HTMLspanElement().bbox;if(az.HTMLcanStretch("Vertical")){aP=aH.h+aH.d;if(aP){aO=b.length2em(aO,ax,aP);if(aO*aH.h/aP>ao[ac]){ao[ac]=aO*aH.h/aP}if(aO*aH.d/aP>ar[ac]){ar[ac]=aO*aH.d/aP}}}else{if(az.HTMLcanStretch("Horizontal")){aO=b.length2em(aO,ax,aH.w);if(aO>ai[ac]){ai[ac]=aO}}}}}if(au[ad][ac].bbox.h>ao[ad]){ao[ad]=au[ad][ac].bbox.h}if(au[ad][ac].bbox.d>ar[ad]){ar[ad]=au[ad][ac].bbox.d}if(au[ad][ac].bbox.w>ai[ac]){ai[ac]=au[ad][ac].bbox.w}}}if(ao[0]+ar[0]){ao[0]=Math.max(ao[0],E)}if(ao[au.length-1]+ar[au.length-1]){ar[au.length-1]=Math.max(ar[au.length-1],L)}var aw=G.columnspacing.split(/ /),aM=G.rowspacing.split(/ /),e=G.columnalign.split(/ /),z=G.rowalign.split(/ /),d=G.columnlines.split(/ /),v=G.rowlines.split(/ /),aI=G.columnwidth.split(/ /),T=[];for(ad=0,ab=aw.length;ad<ab;ad++){aw[ad]=b.length2em(aw[ad],ax)}for(ad=0,ab=aM.length;ad<ab;ad++){aM[ad]=b.length2em(aM[ad],ax)}while(aw.length<an){aw.push(aw[aw.length-1])}while(e.length<=an){e.push(e[e.length-1])}while(d.length<an){d.push(d[d.length-1])}while(aI.length<=an){aI.push(aI[aI.length-1])}while(aM.length<au.length){aM.push(aM[aM.length-1])}while(z.length<=au.length){z.push(z[z.length-1])}while(v.length<au.length){v.push(v[v.length-1])}if(at[ay]){e[ay]=(G.side.substr(0,1)==="l"?"left":"right");aw[ay]=-ai[ay]}for(ad=0,ab=au.length;ad<ab;ad++){aB=this.data[ad];T[ad]=[];if(aB.rowalign){z[ad]=aB.rowalign}if(aB.columnalign){T[ad]=aB.columnalign.split(/ /);while(T[ad].length<=an){T[ad].push(T[ad][T[ad].length-1])}}}if(G.equalrows){var aA=Math.max.apply(Math,ao),U=Math.max.apply(Math,ar);for(ad=0,ab=au.length;ad<ab;ad++){V=((aA+U)-(ao[ad]+ar[ad]))/2;ao[ad]+=V;ar[ad]+=V}}aP=ao[0]+ar[au.length-1];for(ad=0,ab=au.length-1;ad<ab;ad++){aP+=Math.max((ao[ad]+ar[ad]?aj:0),ar[ad]+ao[ad+1]+aM[ad])}var aE=0,aD=0,aR,g=aP;if(G.frame!=="none"||(G.columnlines+G.rowlines).match(/solid|dashed/)){aE=b.length2em(G.framespacing.split(/[, ]+/)[0],ax);aD=b.length2em(G.framespacing.split(/[, ]+/)[1],ax);g=aP+2*aD}var ah,aQ,Z="";if(typeof(G.align)!=="string"){G.align=String(G.align)}if(G.align.match(/(top|bottom|center|baseline|axis)( +(-?\d+))?/)){Z=RegExp.$3;G.align=RegExp.$1}else{G.align=this.defaults.align}if(Z!==""){Z=parseInt(Z);if(Z<0){Z=au.length+1+Z}if(Z<1){Z=1}else{if(Z>au.length){Z=au.length}}ah=0;aQ=-(aP+aD)+ao[0];for(ad=0,ab=Z-1;ad<ab;ad++){var K=Math.max((ao[ad]+ar[ad]?aj:0),ar[ad]+ao[ad+1]+aM[ad]);ah+=K;aQ+=K}}else{ah=({top:-(ao[0]+aD),bottom:aP+aD-ao[0],center:aP/2-ao[0],baseline:aP/2-ao[0],axis:aP/2+b.TeX.axis_height*aC-ao[0]})[G.align];aQ=({top:-(aP+2*aD),bottom:0,center:-(aP/2+aD),baseline:-(aP/2+aD),axis:b.TeX.axis_height*aC-aP/2-aD})[G.align]}var aa,ae=0,w=0,I=0,X=0,af=0,al=[],aq=[],Q=1;if(G.equalcolumns&&G.width!=="auto"){if(aF){aa=(100/(an+1)).toFixed(2).replace(