You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

20 lines
14 KiB
JavaScript

/*
* /MathJax/jax/output/HTML-CSS/autoload/multiline.js
*
* Copyright (c) 2009-2018 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 d="2.7.5";var a=MathJax.ElementJax.mml,b=MathJax.OutputJax["HTML-CSS"];var f=a.mo().With({HTMLspanElement:function(){return{bbox:{w:0},style:{}}}});var e={newline:0,nobreak:1000000,goodbreak:[-200],badbreak:[+200],auto:[0],maxwidth:1.33,toobig:800,nestfactor:400,spacefactor:-100,spaceoffset:2,spacelimit:1,fence:500,close:500};var c={linebreakstyle:"after"};a.mbase.Augment({HTMLlinebreakPenalty:e,HTMLmultiline:function(o){var p=this;while(p.inferred||(p.parent&&p.parent.type==="mrow"&&p.isEmbellished())){p=p.parent}var m=((p.type==="math"&&p.Get("display")==="block")||p.type==="mtd");p.isMultiline=true;var q=this.getValues("linebreak","linebreakstyle","lineleading","linebreakmultchar","indentalign","indentshift","indentalignfirst","indentshiftfirst","indentalignlast","indentshiftlast");if(q.linebreakstyle===a.LINEBREAKSTYLE.INFIXLINEBREAKSTYLE){q.linebreakstyle=this.Get("infixlinebreakstyle")}q.lineleading=b.length2em(q.lineleading,1,0.5);this.HTMLremoveColor(o);var n=b.createStack(o);this.HTMLgetScale();var g={n:0,Y:0,scale:this.scale||1,isTop:m,values:{},VALUES:q},l=this.HTMLgetAlign(g,{}),i=this.HTMLgetShift(g,{},l),h=[],j={index:[],penalty:e.nobreak,w:0,W:i,shift:i,scanW:i,nest:0},k=false;while(this.HTMLbetterBreak(j,g,true)&&(j.scanW>=b.linebreakWidth||j.penalty===e.newline)){this.HTMLaddLine(n,h,j.index,g,j.values,k);h=j.index.slice(0);k=true;l=this.HTMLgetAlign(g,j.values);i=this.HTMLgetShift(g,j.values,l);if(l===a.INDENTALIGN.CENTER){i=0}j.W=j.shift=j.scanW=i;j.penalty=e.nobreak}g.isLast=true;this.HTMLaddLine(n,h,[],g,c,k);if(m){n.style.width="100%";if(p.type==="math"){o.bbox.width="100%"}}this.HTMLhandleSpace(o);this.HTMLhandleColor(o);o.bbox.isMultiline=true;return o},HTMLbetterBreak:function(k,g,r){if(this.isToken){return false}if(this.isEmbellished()){k.embellished=this;return this.CoreMO().HTMLbetterBreak(k,g)}if(this.linebreakContainer){return false}var q=k.index.slice(0),o=k.index.shift(),n=this.data.length,l,s,j,p=(k.index.length>0),h=false;if(o==null){o=-1}if(!p){o++;k.W+=k.w;k.w=0}j=k.scanW=k.W;k.nest++;while(o<n&&(k.scanW<e.maxwidth*b.linebreakWidth||k.w===0)){if(this.data[o]){if(this.data[o].HTMLbetterBreak(k,g)){h=true;q=[o].concat(k.index);l=k.W;s=k.w;if(k.penalty===e.newline){k.index=q;if(k.nest){k.nest--}return true}}j=(p?k.scanW:this.HTMLaddWidth(o,k,j))}k.index=[];o++;p=false}if(r&&h){f.parent=this.parent;f.inherit=this.inherit;if(f.HTMLbetterBreak(k,g)){h=false;q=k.index}}if(k.nest){k.nest--}k.index=q;if(h){k.W=l;k.w=s}return h},HTMLaddWidth:function(g,k,j){if(this.data[g]){var h=this.data[g].HTMLspanElement();j+=h.bbox.w;if(h.style.paddingLeft){j+=b.unEm(h.style.paddingLeft)}if(h.style.paddingRight){j+=b.unEm(h.style.paddingRight)}k.W=k.scanW=j;k.w=0}return j},HTMLaddLine:function(o,h,k,g,p,m){line=b.createBox(o);line.bbox=this.HTMLemptyBBox({});g.first=m;g.last=true;this.HTMLmoveLine(h,k,line,g,p);this.HTMLcleanBBox(line.bbox);var n=this.HTMLgetAlign(g,p),i=this.HTMLgetShift(g,p,n);if(g.n>0){var l=b.FONTDATA.baselineskip*g.scale;var j=(g.values.lineleading==null?g.VALUES:g.values).lineleading*g.scale;g.Y-=Math.max(l,g.d+line.bbox.h+j)}b.alignBox(line,n,g.Y,i);g.d=line.bbox.d;g.values=p;g.n++},HTMLgetAlign:function(j,g){var k=g,h=j.values,i=j.VALUES,l;if(j.n===0){l=k.indentalignfirst||h.indentalignfirst||i.indentalignfirst}else{if(j.isLast){l=h.indentalignlast||i.indentalignlast}else{l=h.indentalign||i.indentalign}}if(l===a.INDENTALIGN.INDENTALIGN){l=h.indentalign||i.indentalign}if(l===a.INDENTALIGN.AUTO){l=(j.isTop?this.displayAlign:a.INDENTALIGN.LEFT)}return l},HTMLgetShift:function(l,i,n){var m=i,j=l.values,k=l.VALUES,h;if(l.n===0){h=m.indentshiftfirst||j.indentshiftfirst||k.indentshiftfirst}else{if(l.isLast){h=j.indentshiftlast||k.indentshiftlast}else{h=j.indentshift||k.indentshift}}if(h===a.INDENTSHIFT.INDENTSHIFT){h=j.indentshift||k.indentshift}if(h==="auto"||h===""){h="0"}h=b.length2em(h,1,b.cwidth);if(l.isTop&&this.displayIndent!=="0"){var g=b.length2em(this.displayIndent,1,b.cwidth);h+=(n===a.INDENTALIGN.RIGHT?-g:g)}