evolution-presentation-persian/impress/extras/mathjax/jax/output/CommonHTML/autoload/multiline.js

20 lines
13 KiB
JavaScript
Raw Normal View History

2018-04-25 21:30:45 +00:00
/*
* /MathJax/jax/output/CommonHTML/autoload/multiline.js
*
* Copyright (c) 2009-2017 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 e="2.7.1";var b=MathJax.ElementJax.mml,a=MathJax.Hub.config,c=MathJax.OutputJax.CommonHTML;var f={newline:0,nobreak:1000000,goodbreak:[-200],badbreak:[+200],auto:[0],toobig:800,nestfactor:400,spacefactor:-100,spaceoffset:2,spacelimit:1,fence:500,close:500};var d={linebreakstyle:"after"};b.mbase.Augment({CHTMLlinebreakPenalty:f,CHTMLmultiline:function(j){var p=this;while(p.inferred||(p.parent&&p.parent.type==="mrow"&&p.parent.isEmbellished())){p=p.parent}var n=((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===b.LINEBREAKSTYLE.INFIXLINEBREAKSTYLE){q.linebreakstyle=this.Get("infixlinebreakstyle")}q.lineleading=this.CHTMLlength2em(q.lineleading,0.5);c.BBOX.empty(this.CHTML);var o=c.addElement(j,"mjx-stack");var g={BBOX:this.CHTML,n:0,Y:0,scale:(this.CHTML.scale||1),isTop:n,values:{},VALUES:q},m=this.CHTMLgetAlign(g,{}),i=this.CHTMLgetShift(g,{},m),h=[],k={index:[],penalty:f.nobreak,w:0,W:i,shift:i,scanW:i,nest:0},l=false;while(this.CHTMLbetterBreak(k,g)&&(k.scanW>=c.linebreakWidth||k.penalty===f.newline)){this.CHTMLaddLine(o,h,k.index,g,k.values,l);h=k.index.slice(0);l=true;m=this.CHTMLgetAlign(g,k.values);i=this.CHTMLgetShift(g,k.values,m);k.W=k.shift=k.scanW=i;k.penalty=f.nobreak}g.isLast=true;this.CHTMLaddLine(o,h,[],g,d,l);j.style.width=o.style.width=this.CHTML.pwidth="100%";this.CHTML.mwidth=c.Em(this.CHTML.w);this.CHTML.isMultiline=p.CHTML.isMultiline=true;o.style.verticalAlign=c.Em(g.d-this.CHTML.d);return j},CHTMLbetterBreak:function(j,g){if(this.isToken){return false}if(this.isEmbellished()){j.embellished=this;return this.CoreMO().CHTMLbetterBreak(j,g)}if(this.linebreakContainer){return false}var q=j.index.slice(0),o=j.index.shift(),n=this.data.length,l,r,k,p=(j.index.length>0),h=false;if(o==null){o=-1}if(!p){o++;j.W+=j.w;j.w=0}k=j.scanW=j.W;j.nest++;while(o<n&&j.scanW<1.33*c.linebreakWidth){if(this.data[o]){if(this.data[o].CHTMLbetterBreak(j,g)){h=true;q=[o].concat(j.index);l=j.W;r=j.w;if(j.penalty===f.newline){j.index=q;if(j.nest){j.nest--}return true}}k=(p?j.scanW:this.CHTMLaddWidth(o,j,k))}j.index=[];o++;p=false}if(j.nest){j.nest--}j.index=q;if(h){j.W=l;j.w=r}return h},CHTMLaddWidth:function(g,j,h){if(this.data[g]){var k=this.data[g].CHTML;h+=k.w+(k.L||0)+(k.R||0);j.W=j.scanW=h;j.w=0}return h},CHTMLaddLine:function(r,i,n,g,s,p){var m=c.addElement(r,"mjx-block",{},[["mjx-box"]]),u=m.firstChild;var t=g.bbox=c.BBOX.empty();g.first=p;g.last=true;this.CHTMLmoveLine(i,n,u,g,s);t.clean();var q=this.CHTMLgetAlign(g,s),j=this.CHTMLgetShift(g,s,q,true);var l=0;if(g.n>0){var o=c.FONTDATA.baselineskip;var k=(g.values.lineleading==null?g.VALUES:g.values).lineleading*g.scale;var h=g.Y;g.Y-=Math.max(o,g.d+t.h+k);l=h-g.Y-g.d-t.h}if(j){u.style.margin="0 "+c.Em(-j)+" 0 "+c.Em(j)}if(q!==b.INDENTALIGN.LEFT){m.style.textAlign=q}if(l){m.style.paddingTop=c.Em(l)}g.BBOX.combine(t,j,g.Y);g.d=g.bbox.d;g.values=s;g.n++},CHTMLgetAlign: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===b.INDENTALIGN.INDENTALIGN){l=h.indentalign||i.indentalign}if(l===b.INDENTALIGN.AUTO){l=(j.isTop?a.displayAlign:b.INDENTALIGN.LEFT)}return l},CHTMLgetShift:function(g,o,m,k){var n=o,l=g.values,h=g.VALUES,i;if(g.n===0){i=n.indentshiftfirst||l.indentshiftfirst||h.indentshiftfirst}else{if(g.isLast){i=l.indentshiftlast||h.indentshiftlast}else{i=l.indentshift||h.indentshift}}if(i===b.INDENTSHIFT.INDENTSHIFT){i=l.indentshift||h.indentshift}if(i==="auto"||i===""){i="0"}i=this.CHTMLlength2em(i,c.cwidth);if(g.isTop&&a.displayIndent!=="0"){var j=this.CHTMLlength2em(a.displayIndent,c.cwidth);i+=(m===b.INDENTALIGN.RIGHT?-j:j)}return(m===b.INDENTALIGN.RIGHT&&!k?-i:i)},CHTMLmoveLine:function(p,g,n,o,