Files
ALC27/mathjax/input/tex/extensions/bbox.js
2025-12-22 12:20:15 +08:00

1 line
2.1 KiB
JavaScript

(()=>{"use strict";var e={d:(t,o)=>{for(var a in o)e.o(o,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:o[a]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{BboxConfiguration:()=>b});const o=("undefined"!=typeof window?window:global).MathJax._.components.global,a=(o.GLOBAL,o.isObject,o.combineConfig,o.combineDefaults,o.combineWithMathJax),n=(o.MathJax,MathJax._.input.tex.HandlerTypes),i=n.ConfigurationType,r=n.HandlerType,l=MathJax._.input.tex.Configuration,p=l.Configuration,c=(l.ConfigurationHandler,l.ParserConfiguration,MathJax._.input.tex.TokenMap),s=(c.parseResult,c.AbstractTokenMap,c.RegExpMap,c.AbstractParseMap,c.CharacterMap,c.DelimiterMap,c.MacroMap,c.CommandMap),d=(c.EnvironmentMap,MathJax._.input.tex.TexError.default),x={BBox(e,t){const o=e.GetBrackets(t,"");let a=e.ParseArg(t);const n=o.split(/,/);let i,r,l;for(let e=0,o=n.length;e<o;e++){const o=n[e].trim(),a=o.match(/^(\.\d+|\d+(\.\d*)?)(pt|em|ex|mu|px|in|cm|mm)$/);if(a){if(i)throw new d("MultipleBBoxProperty","%1 specified twice in %2","Padding",t);const e=a[1]+a[3];e&&(i={height:"+"+e,depth:"+"+e,lspace:e,width:"+"+2*parseInt(a[1],10)+a[3]})}else if(o.match(/^([a-z0-9]+|#[0-9a-f]{6}|#[0-9a-f]{3})$/i)){if(r)throw new d("MultipleBBoxProperty","%1 specified twice in %2","Background",t);r=o}else if(o.match(/^[-a-z]+:/i)){if(l)throw new d("MultipleBBoxProperty","%1 specified twice in %2","Style",t);l=o}else if(""!==o)throw new d("InvalidBBoxProperty",'"%1" doesn\'t look like a color, a padding dimension, or a style',o)}i&&(a=e.create("node","mpadded",[a],i)),(r||l)&&(i={},r&&Object.assign(i,{mathbackground:r}),l&&Object.assign(i,{style:l}),a=e.create("node","mstyle",[a],i)),e.Push(a)}};new s("bbox",{bbox:x.BBox});const b=p.create("bbox",{[i.HANDLER]:{[r.MACRO]:["bbox"]}});MathJax.loader&&MathJax.loader.checkVersion("[tex]/bbox","4.0.0","tex-extension"),a({_:{input:{tex:{bbox:{BboxConfiguration:t}}}}})})();