20 lines
6.2 KiB
JavaScript
20 lines
6.2 KiB
JavaScript
/*
|
|
* /MathJax/jax/output/CommonHTML/autoload/mmultiscripts.js
|
|
*
|
|
* Copyright (c) 2009-2015 The MathJax Consortium
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
MathJax.Hub.Register.StartupHook("CommonHTML Jax Ready",function(){var c="2.6.0-beta";var a=MathJax.ElementJax.mml,b=MathJax.OutputJax.CommonHTML;a.mmultiscripts.Augment({toCommonHTML:function(J,O){if(!O){J=this.CHTMLcreateNode(J);this.CHTMLhandleStyle(J);this.CHTMLhandleScale(J);this.CHTMLgetVariant()}b.BBOX.empty(this.CHTML);var l,e;if(O){l=b.getNode(J,"mjx-base")}else{this.CHTMLaddChild(J,0,{type:"mjx-base",noBBox:true,forceChild:true});l=J.firstChild}e=this.CHTMLbboxFor(0);if(e.ic){e.R-=e.ic;if(!O){l.style.marginRight=b.Em(-e.ic)}Q=1.3*e.ic+0.05}var D={},m={};this.CHTMLgetScripts(D,m,O,J);var o=D.sub,f=D.sup,A=D.presub,k=D.presup;var G=m.sub,M=m.sup,j=m.presub,n=m.presup;if(!O){this.CHTMLaddBoxes(J,l,D)}var g=this.getValues("scriptlevel","scriptsizemultiplier");var i=(this.Get("scriptlevel")<3?g.scriptsizemultiplier:1);var N=b.TEX.x_height,E=b.TEX.scriptspace;var H=b.TEX.sup_drop*i,F=b.TEX.sub_drop*i;var B=e.h-H,z=e.d+F,Q=0,I;var K=this.data[this.base];if(K&&(K.type==="mi"||K.type==="mo")){if(K.data.join("").length===1&&e.rscale===1&&!e.sH&&!K.Get("largeop")){B=z=0}}g=this.getValues("displaystyle","subscriptshift","superscriptshift","texprimestyle");g.subscriptshift=(g.subscriptshift===""?0:this.CHTMLlength2em(g.subscriptshift));g.superscriptshift=(g.superscriptshift===""?0:this.CHTMLlength2em(g.superscriptshift));var y=(A?E+j.w:k?E+n.w-Q:0);this.CHTML.combine(e,y,0);var w=this.CHTML.w;if(!f&&!k){z=Math.max(z,b.TEX.sub1,g.subscriptshift);if(o){z=Math.max(z,G.h-(4/5)*N)}if(A){z=Math.max(z,j.h-(4/5)*N)}if(o){this.CHTMLplaceSubOnly(o,G,w,z,E)}if(A){this.CHTMLplacePresubOnly(A,j,z,E)}}else{if(!o&&!A){I=b.TEX[(g.displaystyle?"sup1":(g.texprimestyle?"sup3":"sup2"))];B=Math.max(B,I,g.superscriptshift);if(f){B=Math.max(B,M.d+(1/4)*N)}if(k){B=Math.max(B,n.d+(1/4)*N)}if(f){this.CHTMLplaceSupOnly(f,M,w,Q,B,E)}if(k){this.CHTMLplacePresupOnly(k,n,Q,B,E)}}else{z=Math.max(z,b.TEX.sub2);var C=b.TEX.rule_thickness;var L=(G||j).h,P=(M||n).d;if(A){L=Math.max(L,j.h)}if(k){P=Math.max(P,n.d)}if((B-P)-(L-z)<3*C){z=3*C-B+P+L;H=(4/5)*N-(B-P);if(H>0){B+=H;z-=H}}B=Math.max(B,g.superscriptshift);z=Math.max(z,g.subscriptshift);if(f){if(o){this.CHTMLplaceSubSup(o,G,f,M,w,Q,B,z,E)}else{this.CHTMLplaceSupOnly(f,M,w,Q,B,E)}}else{if(o){this.CHTMLplaceSubOnly(o,G,w,z,E)}}if(k){if(A){this.CHTMLplacePresubPresup(A,j,k,n,Q,B,z,E)}else{this.CHTMLplacePresupOnly(k,n,Q,B,E)}}else{if(A){this.CHTMLplacePresubOnly(A,j,z,E)}}}}this.CHTML.clean();this.CHTMLhandleSpace(J);this.CHTMLhandleBBox(J);this.CHTMLhandleColor(J);return J},CHTMLgetScripts:function(e,o,g,h){if(g){e.sub=b.getNode(h,"mjx-sub");e.sup=b.getNode(h,"mjx-sup");e.presub=b.getNode(h,"mjx-presub");e.presup=b.getNode(h,"mjx-presup");o.sub=this.CHTMLbbox.sub;o.sup=this.CHTMLbbox.sup;o.presub=this.CHTMLbbox.presub;o.presup=this.CHTMLbbox.presup;return}this.CHTMLbbox=o;var f={i:1,w:0,BOX:e,BBOX:o},i=this.data.length;var d="sub",j="sup";while(f.i<i){if((this.data[f.i]||{}).type==="mprescripts"){f.i++;f.w=0;d="presub";j="presup"}else{var k=this.CHTMLaddScript(d,f);var n=this.CHTMLaddScript(j,f);var l=Math.max((k?k.rscale*k.w:0),(n?n.rscale*n.w:0));this.CHTMLpadScript(d,l,k,f);this.CHTMLpadScript(j,l,n,f);f.w+=l}}if(o.sub){o.sub.clean()}if(o.sup){o.sup.clean()}if(o.presub){o.presub.clean()}if(o.presup){o.presup.clean()}},CHTMLaddScript:function(f,h){var e,d,g=this.data[h.i];if(g&&g.type!=="none"&&g.type!=="mprescripts"){e=h.BOX[f];if(!e){e=h.BOX[f]=b.Element("mjx-"+f);d=h.BBOX[f]=b.BBOX.empty();if(h.w){e.style.paddingLeft=b.Em(h.w);d.w=d.r=h.w;d.x=h.w}}g.toCommonHTML(e);d=g.CHTML}if(g&&g.type!=="mprescripts"){h.i++}return d},CHTMLpadScript:function(h,j,k,g){if(!k){k={w:0,fake:1,rscale:1}}var i=g.BBOX[h],l=0,e=0;if(i){if(k.rscale*k.w<j){var f=g.BOX[h];e=j-k.rscale*k.w;var d=b.Element("mjx-spacer",{style:{width:b.Em(e)}});if(h.substr(0,3)==="pre"&&!k.fake){f.insertBefore(d,f.lastChild);l=e;e=0}else{f.appendChild(d)}}if(k.fake){i.w+=l}else{i.combine(k,i.w+l,0)}i.w+=e}},CHTMLaddBoxes:function(h,f,e){var d=e.sub,i=e.sup,g=e.presub,k=e.presup;if(g&&k){var j=b.Element("mjx-prestack");h.insertBefore(j,f);j.appendChild(k);j.appendChild(g)}else{if(g){h.insertBefore(g,f)}if(k){h.insertBefore(k,f)}}if(d&&i){var l=b.addElement(h,"mjx-stack");l.appendChild(i);l.appendChild(d)}else{if(d){h.appendChild(d)}if(i){h.appendChild(i)}}},CHTMLplaceSubOnly:function(h,f,d,e,g){h.style.verticalAlign=b.Em(-e);h.style.marginRight=b.Em(g);f.w+=g;this.CHTML.combine(f,d,-e)},CHTMLplaceSupOnly:function(e,i,d,h,f,g){e.style.verticalAlign=b.Em(f);e.style.paddingLeft=b.Em(h);e.style.paddingRight=b.Em(g);i.w+=g;this.CHTML.combine(i,d+h,f)},CHTMLplaceSubSup:function(d,f,e,h,g,i,k,j,l){d.style.paddingRight=b.Em(l);f.w+=l;e.style.paddingBottom=b.Em(k+j-h.d-f.h);e.style.paddingLeft=b.Em(i+(h.x||0));e.style.paddingRight=b.Em(l);h.w+=l;e.parentNode.style.verticalAlign=b.Em(-j);this.CHTML.combine(f,g,-j);this.CHTML.combine(h,g+i,k)},CHTMLplacePresubOnly:function(e,d,f,g){e.style.verticalAlign=b.Em(-f);e.style.marginLeft=b.Em(g);this.CHTML.combine(d,g,-f)},CHTMLplacePresupOnly:function(g,f,h,d,e){g.style.verticalAlign=b.Em(d);g.style.paddingLeft=b.Em(e);g.style.paddingRight=b.Em(-h);this.CHTML.combine(f,e,d)},CHTMLplacePresubPresup:function(e,d,j,i,k,g,f,h){e.style.paddingLeft=b.Em(h);j.style.paddingBottom=b.Em(g+f-i.d-d.h);j.style.paddingLeft=b.Em(k+h+(i.x||0));j.style.paddingRight=b.Em(-k);j.parentNode.style.verticalAlign=b.Em(-f);this.CHTML.combine(d,h,-f);this.CHTML.combine(i,h+k,g)},CHTMLstretchH:a.mbase.CHTMLstretchH,CHTMLstretchV:a.mbase.CHTMLstretchV});MathJax.Hub.Startup.signal.Post("CommonHTML mmultiscripts Ready");MathJax.Ajax.loadComplete(b.autoloadDir+"/mmultiscripts.js")});
|