bbox.js 1.5 KB

12345678910111213
  1. /*
  2. * /MathJax/extensions/TeX/bbox.js
  3. *
  4. * Copyright (c) 2009-2013 The MathJax Consortium
  5. *
  6. * Part of the MathJax library.
  7. * See http://www.mathjax.org for details.
  8. *
  9. * Licensed under the Apache License, Version 2.0;
  10. * you may not use this file except in compliance with the License.
  11. *
  12. * http://www.apache.org/licenses/LICENSE-2.0
  13. */MathJax.Extension["TeX/bbox"]={version:"2.2"};MathJax.Hub.Register.StartupHook("TeX Jax Ready",function(){var d=MathJax.InputJax.TeX,l=MathJax.ElementJax.mml;d.Definitions.Add({macros:{bbox:"BBox"}},null,!0);d.Parse.Augment({BBox:function(b){var g=this.GetBrackets(b,""),e=this.ParseArg(b),g=g.split(/,/),a,h,k,m;for(m in g){var c=g[m].replace(/^\s+/,"").replace(/\s+$/,""),f=c.match(/^(\.\d+|\d+(\.\d*)?)(pt|em|ex|mu|px|in|cm|mm)$/);f?(a&&d.Error(["MultipleBBoxProperty","%1 specified twice in %2","Padding",b]),a=f[1]+f[3],a={height:"+"+a,depth:"+"+a,lspace:a,width:"+"+2*f[1]+f[3]}):c.match(/^([a-z0-9]+|\#[0-9a-f]{6}|\#[0-9a-f]{3})$/i)?(h&&d.Error(["MultipleBBoxProperty","%1 specified twice in %2","Background",b]),h=c):c.match(/^[-a-z]+:/i)?(k&&d.Error(["MultipleBBoxProperty","%1 specified twice in %2","Style",b]),k=this.BBoxStyle(c)):""!==c&&d.Error(["InvalidBBoxProperty","'%1' doesn't look like a color, a padding dimension, or a style",c])}a&&(e=l.mpadded(e).With(a));if(h||k)e=l.mstyle(e).With({mathbackground:h,style:k});this.Push(e)},BBoxStyle:function(b){return b}});MathJax.Hub.Startup.signal.Post("TeX bbox Ready")});MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/bbox.js");