12345678910111213141516171819202122232425 |
- /* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
- /* vim: set ts=2 et sw=2 tw=80: */
- /*************************************************************
- *
- * MathJax/jax/output/HTML-CSS/autoload/mmultiscripts.js
- *
- * Implements the HTML-CSS output for <mmultiscripts> elements.
- *
- * ---------------------------------------------------------------------
- *
- * Copyright (c) 2010-2013 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("HTML-CSS Jax Ready",function(){var v=MathJax.ElementJax.mml,c=MathJax.OutputJax["HTML-CSS"];v.mmultiscripts.Augment({toHTML:function(r,p,a){r=this.HTMLcreateSpan(r);var e=this.HTMLgetScale(),b=c.createStack(r),f,l=c.createBox(b);if(this.data[this.base]){var d=this.data[this.base].toHTML(l);null!=a?this.data[this.base].HTMLstretchV(l,p,a):null!=p&&this.data[this.base].HTMLstretchH(l,p);c.Measured(d,l)}else l.bbox=this.HTMLzeroBBox();p=c.TeX.x_height*e;a=c.TeX.scriptspace*e*.75;d=this.HTMLgetScripts(b,a);f=d[0];for(var b=d[1],h=d[2],d=d[3],m=this.HTMLgetScale(),g=1;g<this.data.length;g++)if(this.data[g]&&this.data[g].spanID){m=this.data[g].HTMLgetScale();break}var q=c.TeX.sup_drop*m,g=l.bbox.h-q,k=l.bbox.d+c.TeX.sub_drop*m,t=0;l.bbox.ic&&(t=l.bbox.ic);!this.data[this.base]||"mi"!==this.data[this.base].type&&"mo"!==this.data[this.base].type||1!==this.data[this.base].data.join("").length||1!==l.bbox.scale||this.data[this.base].Get("largeop")||(g=k=0);var m=this.getValues("subscriptshift","superscriptshift"),n=this.HTMLgetMu(r);m.subscriptshift=""===m.subscriptshift?0:c.length2em(m.subscriptshift,n);m.superscriptshift=""===m.superscriptshift?0:c.length2em(m.superscriptshift,n);n=0;h?n=h.bbox.w+t:d&&(n=d.bbox.w-t);0>n&&(n=0);c.placeBox(l,n,0);if(b||d)if(f||h){var k=Math.max(k,c.TeX.sub2*e),e=c.TeX.rule_thickness*e,q=(f||h).bbox.h,u=(b||d).bbox.d;h&&(q=Math.max(q,h.bbox.h));d&&(u=Math.max(u,d.bbox.d));g-u-(q-k)<3*e&&(k=3*e-g+u+q,q=.8*p-(g-u),0<q&&(g+=q,k-=q));g=Math.max(g,m.superscriptshift);k=Math.max(k,m.subscriptshift);b&&c.placeBox(b,n+l.bbox.w+a,g);d&&c.placeBox(d,n+t-d.bbox.w,g);f&&c.placeBox(f,n+l.bbox.w+a-t,-k);h&&c.placeBox(h,n-h.bbox.w,-k)}else f=this.getValues("displaystyle","texprimestyle"),f=c.TeX[f.displaystyle?"sup1":f.texprimestyle?"sup3":"sup2"],g=Math.max(g,f*e,m.superscriptshift),b&&(g=Math.max(g,b.bbox.d+.25*p)),d&&(g=Math.max(g,d.bbox.d+.25*p)),b&&c.placeBox(b,n+l.bbox.w+a,g),d&&c.placeBox(d,0,g);else k=Math.max(k,c.TeX.sub1*e,m.subscriptshift),f&&(k=Math.max(k,f.bbox.h-.8*p)),h&&(k=Math.max(k,h.bbox.h-.8*p)),f&&c.placeBox(f,n+l.bbox.w+a-t,-k),h&&c.placeBox(h,0,-k);this.HTMLhandleSpace(r);this.HTMLhandleColor(r);return r},HTMLgetScripts:function(r,p){for(var a,e,b=[],f=1,l=this.data.length,d=0,h=0;4>h;h+=2){for(;f<l&&"mprescripts"!==this.data[f].type;){for(a=h;a<h+2;a++)this.data[f]&&"none"!==this.data[f].type&&(b[a]||(b[a]=c.createBox(r),b[a].bbox=this.HTMLemptyBBox({}),d&&(c.createBlank(b[a],d),b[a].bbox.w=b[a].bbox.rw=d)),this.data[f].toHTML(b[a]),this.HTMLcombineBBoxes(this.data[f],b[a].bbox)),f++;e=b[h];a=b[h+1];e&&a&&(e.bbox.w<a.bbox.w?(c.createBlank(e,a.bbox.w-e.bbox.w),e.bbox.w=a.bbox.w,e.bbox.rw=Math.max(e.bbox.w,e.bbox.rw)):e.bbox.w>a.bbox.w&&(c.createBlank(a,e.bbox.w-a.bbox.w),a.bbox.w=e.bbox.w,a.bbox.rw=Math.max(a.bbox.w,a.bbox.rw)));e?d=e.bbox.w:a&&(d=a.bbox.w)}f++;d=0}for(a=0;4>a;a++)b[a]&&(b[a].bbox.w+=p,b[a].bbox.rw=Math.max(b[a].bbox.w,b[a].bbox.rw),this.HTMLcleanBBox(b[a].bbox));return b},HTMLstretchH:v.mbase.HTMLstretchH,HTMLstretchV:v.mbase.HTMLstretchV});MathJax.Hub.Startup.signal.Post("HTML-CSS mmultiscripts Ready");MathJax.Ajax.loadComplete(c.autoloadDir+"/mmultiscripts.js")});
|