123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- MathJax.Extension["TeX/bbox"] = {
- version: "2.7.2"
- };
- MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
- var TEX = MathJax.InputJax.TeX,
- MML = MathJax.ElementJax.mml;
- TEX.Definitions.Add({macros: {bbox: "BBox"}},null,true);
-
- TEX.Parse.Augment({
- BBox: function (name) {
- var bbox = this.GetBrackets(name,""),
- math = this.ParseArg(name);
- var parts = bbox.split(/,/), def, background, style;
- for (var i = 0, m = parts.length; i < m; i++) {
- var part = parts[i].replace(/^\s+/,'').replace(/\s+$/,'');
- var match = part.match(/^(\.\d+|\d+(\.\d*)?)(pt|em|ex|mu|px|in|cm|mm)$/);
- if (match) {
- if (def)
- {TEX.Error(["MultipleBBoxProperty","%1 specified twice in %2","Padding",name])}
- var pad = this.BBoxPadding(match[1]+match[3]);
- if (pad) def = {height:"+"+pad, depth:"+"+pad, lspace:pad, width:"+"+(2*match[1])+match[3]};
- } else if (part.match(/^([a-z0-9]+|\#[0-9a-f]{6}|\#[0-9a-f]{3})$/i)) {
- if (background)
- {TEX.Error(["MultipleBBoxProperty","%1 specified twice in %2","Background",name])}
- background = part;
- } else if (part.match(/^[-a-z]+:/i)) {
- if (style)
- {TEX.Error(["MultipleBBoxProperty","%1 specified twice in %2", "Style",name])}
- style = this.BBoxStyle(part);
- } else if (part !== "") {
- TEX.Error(
- ["InvalidBBoxProperty",
- "'%1' doesn't look like a color, a padding dimension, or a style",
- part]
- );
- }
- }
- if (def) {math = MML.mpadded(math).With(def)}
- if (background || style) {
- math = MML.mstyle(math).With({mathbackground:background, style:style});
- }
- this.Push(math);
- },
- BBoxStyle: function (styles) {return styles},
- BBoxPadding: function (pad) {return pad}
- });
- MathJax.Hub.Startup.signal.Post("TeX bbox Ready");
- });
- MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/bbox.js");
|