UNPKG

mathjax

Version:

Beautiful and accessible math in all browsers. MathJax is an open-source JavaScript display engine for LaTeX, MathML, and AsciiMath notation that works in all browsers. This package includes the packaged components (install mathjax-full to get the source

1 lines 12.2 kB
(()=>{"use strict";var e={d:(t,o)=>{for(var n in o)e.o(o,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:o[n]})}};e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),e.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var t={};e.r(t),e.d(t,{balanceRules:()=>O,clearDocument:()=>$,getProperty:()=>q,makeBsprAttributes:()=>G,removeProperty:()=>D,saveDocument:()=>K,setProperty:()=>j});var o={};e.r(o),e.d(o,{ProofTreeItem:()=>H});var n={};e.r(n),e.d(n,{default:()=>Z});var r={};e.r(r),e.d(r,{BussproofsConfiguration:()=>re});const i=("undefined"!=typeof window?window:e.g).MathJax._.components.global,a=(i.GLOBAL,i.isObject,i.combineConfig,i.combineDefaults,i.combineWithMathJax),s=(i.MathJax,MathJax._.input.tex.HandlerTypes),c=s.ConfigurationType,l=s.HandlerType,f=MathJax._.input.tex.Configuration,d=f.Configuration,u=(f.ConfigurationHandler,f.ParserConfiguration,MathJax._.input.tex.TexError.default),p=MathJax._.input.tex.StackItem,h=(p.MmlStack,p.BaseItem),m=MathJax._.input.tex.Stack.default,g=MathJax._.input.tex.NodeUtil.default,y=MathJax._.input.tex.UnitUtil.UnitUtil;let P=null,w=null;const x=function(e){w.root=e;const{w:t}=P.outputJax.getBBox(w,P);return t},T=function(e){let t=0;for(;e&&!g.isType(e,"mtable");){if(g.isType(e,"text"))return null;g.isType(e,"mrow")?(e=e.childNodes[0],t=0):(e=e.parent.childNodes[t],t++)}return e},b=function(e,t){return e.childNodes["up"===t?1:0].childNodes[0].childNodes[0].childNodes[0].childNodes[0]},M=function(e,t){return e.childNodes[t].childNodes[0].childNodes[0]},N=function(e){return M(e,0)},I=function(e){return M(e,e.childNodes.length-1)},C=function(e,t){return e.childNodes["up"===t?0:1].childNodes[0].childNodes[0].childNodes[0]},L=function(e){for(;e&&!g.isType(e,"mtd");)e=e.parent;return e},S=function(e){return e.parent.childNodes[e.parent.childNodes.indexOf(e)+1]},k=function(e){for(;e&&null==q(e,"inference");)e=e.parent;return e},A=function(e,t,o=!1){let n=0;if(e===t)return n;if(e!==t.parent&&(n+=e.getProperty(o?"proof-right":"proof-left")||0,e=t.parent),e===t)return n;const r=e.childNodes,i=o?r.length-1:0;return r[i]!==t&&(n+=x(r[i])),n},R=function(e,t=!1){const o=T(e),n=C(o,q(o,"inferenceRule"));return A(e,o,t)+(x(o)-x(n))/2},v=function(e,t,o,n=!1){if(0===o)return;if(q(t,"inferenceRule")||q(t,"labelledRule")){const o=e.nodeFactory.create("node","mrow");t.parent.replaceChild(o,t),o.setChildren([t]),B(t,o),t=o}const r=n?"proof-right":"proof-left";t.setProperty(r,(t.getProperty(r)||0)+o);const i=[];for(const e of["left","right"]){const o=t.getProperty(`proof-${e}`);o&&i.push(`margin-${e}: ${y.em(o)}`)}t.attributes.set("style",i.join("; "))},B=function(e,t){["inference","proof","labelledRule"].forEach(o=>{const n=q(e,o);null!=n&&(j(t,o,n),D(e,o))})},J=function(e,t,o,n,r){const i=e.nodeFactory.create("node","mspace",[],{width:y.em(r)});if("left"===n){const e=t.childNodes[o].childNodes[0];i.parent=e,e.childNodes.unshift(i)}else t.childNodes[o].appendChild(i);j(t.parent,"sequentAdjust_"+n,r)},_=function(e,t){let o=t.pop();for(;t.length;){const n=t.pop(),[r,i]=E(o,n);q(o.parent,"axiom")&&(J(e,r<0?o:n,0,"left",Math.abs(r)),J(e,i<0?o:n,2,"right",Math.abs(i))),o=n}},E=function(e,t){const o=x(e.childNodes[2]),n=x(t.childNodes[2]);return[x(e.childNodes[0])-x(t.childNodes[0]),o-n]},O=function(e){w=new e.document.options.MathItem("",null,e.math.display);const t=e.data;!function(e){const t=e.nodeLists.sequent;if(t)for(let o,n=t.length-1;o=t[n];n--){if(q(o,"sequentProcessed")){D(o,"sequentProcessed");continue}const t=[];let n=k(o);if(1===q(n,"inference")){for(t.push(o);1===q(n,"inference");){n=T(n);const e=N(b(n,q(n,"inferenceRule"))),r=q(e,"inferenceRule")?C(e,q(e,"inferenceRule")):e;q(r,"sequent")&&(o=r.childNodes[0],t.push(o),j(o,"sequentProcessed",!0)),n=e}_(e,t)}}}(t);const o=t.nodeLists.inference||[];let n=0;for(const e of o){const o=q(e,"proof"),r=T(e),i=b(r,q(r,"inferenceRule")),a=N(i);let s=0;if(q(a,"inference")){const o=R(a);if(o){v(t,a,-o);const n=A(e,r,!1);v(t,e,o-n),s=o-n}}const c=I(i);if(null==q(c,"inference"))continue;const l=R(c,!0);v(t,c,-l,!0);const f=A(e,r,!0),d=(x(r)-x(i.parent))/2;let u;if(v(t,e,d<s?-d:-s),n=Math.max(0,Math.max(0,n+l-f)-d),o||!(u=L(e))){v(t,q(e,"proof")?e:e.parent,n,!0);continue}const p=S(u);if(p){const e=t.nodeFactory.create("node","mspace",[],{width:y.em(n)});p.appendChild(e),n=0;continue}k(u)}},F="bspr_",U=RegExp("^"+F),j=function(e,t,o){g.setProperty(e,F+t,o)},q=function(e,t){return g.getProperty(e,F+t)},D=function(e,t){e.removeProperty(F+t)},G=function(e){e.data.root.walkTree((e,t)=>{const o=[];e.getPropertyNames().forEach(t=>{t.match(U)&&o.push(t+":"+e.getProperty(t))}),o.length&&g.setAttribute(e,"semantics",o.join(";"))})},K=function(e){if(P=e.document,!("getBBox"in P.outputJax))throw Error("The bussproofs extension requires an output jax with a getBBox() method")},$=function(e){P=null};class H extends h{constructor(){super(...arguments),this.leftLabel=null,this.rigthLabel=null,this.innerStack=new m(this.factory,{},!0)}get kind(){return"proofTree"}checkItem(e){if(e.isKind("end")&&"prooftree"===e.getName()){const t=this.toMml();return j(t,"proof",!0),[[this.factory.create("mml",t),e],!0]}if(e.isKind("stop"))throw new u("EnvMissingEnd","Missing \\end{%1}",this.getName());return this.innerStack.Push(e),h.fail}toMml(){const e=super.toMml(),t=this.innerStack.Top();if(t.isKind("start")&&!t.Size())return e;this.innerStack.Push(this.factory.create("stop"));const o=this.innerStack.Top().toMml();return this.create("node","mrow",[o,e],{})}}const Q=MathJax._.input.tex.TexParser.default,V=MathJax._.input.tex.ParseUtil,z=(V.KeyValueDef,V.KeyValueTypes,V.ParseUtil);function W(e,t){const o=z.internalMath(e,y.trimSpaces(t),0);if(!o[0].childNodes[0].childNodes.length)return e.create("node","mrow",[]);const n=e.create("node","mspace",[],{width:".5ex"}),r=e.create("node","mspace",[],{width:".5ex"});return e.create("node","mrow",[n,...o,r])}function X(e,t,o,n,r,i,a){const s=e.create("node","mtr",[e.create("node","mtd",[t],{})],{}),c=e.create("node","mtr",[e.create("node","mtd",o,{})],{});let l,f,d,u,p=e.create("node","mtable",a?[c,s]:[s,c],{align:"top 2",rowlines:i,framespacing:"0 0"});if(j(p,"inferenceRule",a?"up":"down"),n&&(l=e.create("node","mpadded",[n],{height:".25em",depth:"+.25em",width:"+.5ex",voffset:"-.25em"}),j(l,"prooflabel","left")),r&&(f=e.create("node","mpadded",[r],{height:"-.25em",depth:"+.25em",width:"+.5ex",voffset:"-.25em",lspace:".5ex"}),j(f,"prooflabel","right")),n&&r)d=[l,p,f],u="both";else if(n)d=[l,p],u="left";else{if(!r)return p;d=[p,f],u="right"}return p=e.create("node","mrow",d),j(p,"labelledRule",u),p}function Y(e,t){if("$"!==e.GetNext())throw new u("IllegalUseOfCommand","Use of %1 does not match its definition.",t);e.i++;const o=e.GetUpTo(t,"$");if(!o.includes("\\fCenter"))throw new u("MissingProofCommand","Missing %1 in %2.","\\fCenter",t);const[n,r]=o.split("\\fCenter"),i=new Q(n,e.stack.env,e.configuration).mml(),a=new Q(r,e.stack.env,e.configuration).mml(),s=new Q("\\fCenter",e.stack.env,e.configuration).mml(),c=e.create("node","mtd",[i],{}),l=e.create("node","mtd",[s],{}),f=e.create("node","mtd",[a],{}),d=e.create("node","mtr",[c,l,f],{}),p=e.create("node","mtable",[d],{columnspacing:".5ex",columnalign:"center 2"});return j(p,"sequent",!0),e.configuration.addNode("sequent",d),p}const Z={Prooftree(e,t){e.Push(t);return e.itemFactory.create("proofTree").setProperties({name:t.getName(),line:"solid",currentLine:"solid",rootAtTop:!1})},Axiom(e,t){const o=e.stack.Top();if("proofTree"!==o.kind)throw new u("IllegalProofCommand","Proof commands only allowed in prooftree environment.");const n=W(e,e.GetArgument(t));j(n,"axiom",!0),o.Push(n)},Inference(e,t,o){const n=e.stack.Top();if("proofTree"!==n.kind)throw new u("IllegalProofCommand","Proof commands only allowed in prooftree environment.");if(n.Size()<o)throw new u("BadProofTree","Proof tree badly specified.");const r=n.getProperty("rootAtTop"),i=1!==o||n.Peek()[0].childNodes.length?o:0,a=[];do{a.length&&a.unshift(e.create("node","mtd",[],{})),a.unshift(e.create("node","mtd",[n.Pop()],{rowalign:r?"top":"bottom"})),o--}while(o>0);const s=e.create("node","mtr",a,{}),c=e.create("node","mtable",[s],{framespacing:"0 0"}),l=W(e,e.GetArgument(t)),f=n.getProperty("currentLine");f!==n.getProperty("line")&&n.setProperty("currentLine",n.getProperty("line"));const d=X(e,c,[l],n.getProperty("left"),n.getProperty("right"),f,r);n.setProperty("left",null),n.setProperty("right",null),j(d,"inference",i),e.configuration.addNode("inference",d),n.Push(d)},Label(e,t,o){const n=e.stack.Top();if("proofTree"!==n.kind)throw new u("IllegalProofCommand","Proof commands only allowed in prooftree environment.");const r=z.internalMath(e,e.GetArgument(t),0),i=r.length>1?e.create("node","mrow",r,{}):r[0];n.setProperty(o,i)},SetLine(e,t,o,n){const r=e.stack.Top();if("proofTree"!==r.kind)throw new u("IllegalProofCommand","Proof commands only allowed in prooftree environment.");r.setProperty("currentLine",o),n&&r.setProperty("line",o)},RootAtTop(e,t,o){const n=e.stack.Top();if("proofTree"!==n.kind)throw new u("IllegalProofCommand","Proof commands only allowed in prooftree environment.");n.setProperty("rootAtTop",o)},AxiomF(e,t){const o=e.stack.Top();if("proofTree"!==o.kind)throw new u("IllegalProofCommand","Proof commands only allowed in prooftree environment.");const n=Y(e,t);j(n,"axiom",!0),o.Push(n)},FCenter(e,t){},InferenceF(e,t,o){const n=e.stack.Top();if("proofTree"!==n.kind)throw new u("IllegalProofCommand","Proof commands only allowed in prooftree environment.");if(n.Size()<o)throw new u("BadProofTree","Proof tree badly specified.");const r=n.getProperty("rootAtTop"),i=1!==o||n.Peek()[0].childNodes.length?o:0,a=[];do{a.length&&a.unshift(e.create("node","mtd",[],{})),a.unshift(e.create("node","mtd",[n.Pop()],{rowalign:r?"top":"bottom"})),o--}while(o>0);const s=e.create("node","mtr",a,{}),c=e.create("node","mtable",[s],{framespacing:"0 0"}),l=Y(e,t),f=n.getProperty("currentLine");f!==n.getProperty("line")&&n.setProperty("currentLine",n.getProperty("line"));const d=X(e,c,[l],n.getProperty("left"),n.getProperty("right"),f,r);n.setProperty("left",null),n.setProperty("right",null),j(d,"inference",i),e.configuration.addNode("inference",d),n.Push(d)}},ee=MathJax._.input.tex.ParseMethods.default,te=MathJax._.input.tex.TokenMap,oe=(te.parseResult,te.AbstractTokenMap,te.RegExpMap,te.AbstractParseMap,te.CharacterMap,te.DelimiterMap,te.MacroMap,te.CommandMap),ne=te.EnvironmentMap;new oe("Bussproofs-macros",{AxiomC:Z.Axiom,UnaryInfC:[Z.Inference,1],BinaryInfC:[Z.Inference,2],TrinaryInfC:[Z.Inference,3],QuaternaryInfC:[Z.Inference,4],QuinaryInfC:[Z.Inference,5],RightLabel:[Z.Label,"right"],LeftLabel:[Z.Label,"left"],AXC:Z.Axiom,UIC:[Z.Inference,1],BIC:[Z.Inference,2],TIC:[Z.Inference,3],RL:[Z.Label,"right"],LL:[Z.Label,"left"],noLine:[Z.SetLine,"none",!1],singleLine:[Z.SetLine,"solid",!1],solidLine:[Z.SetLine,"solid",!1],dashedLine:[Z.SetLine,"dashed",!1],alwaysNoLine:[Z.SetLine,"none",!0],alwaysSingleLine:[Z.SetLine,"solid",!0],alwaysSolidLine:[Z.SetLine,"solid",!0],alwaysDashedLine:[Z.SetLine,"dashed",!0],rootAtTop:[Z.RootAtTop,!0],alwaysRootAtTop:[Z.RootAtTop,!0],rootAtBottom:[Z.RootAtTop,!1],alwaysRootAtBottom:[Z.RootAtTop,!1],fCenter:Z.FCenter,Axiom:Z.AxiomF,UnaryInf:[Z.InferenceF,1],BinaryInf:[Z.InferenceF,2],TrinaryInf:[Z.InferenceF,3],QuaternaryInf:[Z.InferenceF,4],QuinaryInf:[Z.InferenceF,5]}),new ne("Bussproofs-environments",ee.environment,{prooftree:[Z.Prooftree,null,!1]});const re=d.create("bussproofs",{[c.HANDLER]:{[l.MACRO]:["Bussproofs-macros"],[l.ENVIRONMENT]:["Bussproofs-environments"]},[c.ITEMS]:{[H.prototype.kind]:H},[c.PREPROCESSORS]:[[K,1]],[c.POSTPROCESSORS]:[[$,3],[G,2],[O,1]]});MathJax.loader&&MathJax.loader.checkVersion("[tex]/bussproofs","4.1.2","tex-extension"),a({_:{input:{tex:{bussproofs:{BussproofsConfiguration:r,BussproofsItems:o,BussproofsMethods:n,BussproofsUtil:t}}}}})})();