2 lines
32 KiB
JavaScript
2 lines
32 KiB
JavaScript
|
MathJax.Extension["TeX/siunitx"]={version:"0.1.0"},MathJax.Hub.Register.StartupHook("TeX Jax Ready",function(){!function(){var a,b,c,d,e,f,g,h;a=function(){var a={},b=MathJax.InputJax.TeX,c=a.ValidationError=MathJax.Object.Subclass({Init:function(a,b,c,d){this._errormsg='ValidationError: Error validating "'+b+'" of "'+a.constructor+'" (a "'+c+'") to "'+d+'": ';for(var e=4;e<arguments.length;++e)this._errormsg+=arguments[e].toString();console.log(this._errormsg)},toString:function(){return this._errormsg}}),d=a.ValidationBase=MathJax.Object.Subclass({PropertyDescriptor:function(a,b){var c=this;return{get:function(){return c.Get(this,b)},set:function(a){c.Set(this,b,a)}}},Get:function(a,b){var c=a._values[b];return void 0!==c?c:this._default},Set:function(a,b,c){a._values[b]=this.Validate(a,b,c)},Validate:function(a,b,c){return c}}),e=a.Choice=d.Subclass({Init:function(){this._default=arguments[0];for(var a={},b=0;b<arguments.length;b++)a[arguments[b]]=!0;this._choices=a},Validate:function(a,b,d){if(!this._choices.hasOwnProperty(d))throw c(a,b,this,d,'must be one of ["'+Object.getOwnPropertyNames(this._choices).join('", "')+'"]');return d}}),f=(a.SwitchChoice=e.Subclass({Init:function(){this._switchchoice=arguments[1],e.prototype.Init.apply(this,arguments)},Validate:function(a,b,c){return void 0===c&&(c=this._switchchoice),e.prototype.Validate.call(this,a,b,c)}}),a.Integer=d.Subclass({Init:function(a){void 0===a&&(a=0),this._default=a},Validate:function(a,b,d){if(d=parseInt(d),!Number.isInteger(d))throw c(a,b,this,d,"must be an integer");return d}}),a.Literal=d.Subclass({Init:function(a){this._default=a},Validate:function(a,b,c){return c}}));a.TeXParsedLiteral=f.Subclass({Init:function(a){this._default=a},Get:function(a,c){return val=arguments.callee.SUPER.Get.call(this,a,c),b.Parse("\\text{"+val+"}").mml()}}),a.Math=f.Subclass({}),a.Length=d.Subclass({Init:function(a){this._default=a},Validate:function(a,b,c){return c}}),a.Macro=d.Subclass({Init:function(a){this._default=a},Validate:function(a,b,c){return c}}),a.Switch=d.Subclass({Init:function(a){void 0===a&&(a=!1),this._default=a},Validate:function(a,b,d){if(void 0===d&&(d=!0),("string"==typeof d||d instanceof String)&&(d=d.toLowerCase(),"true"==d?d=!0:"false"==d&&(d=!1)),d!==!0&&d!==!1)throw c(a,b,this,d,"must be a boolean");return d}}),a.ConfigData=MathJax.Object.Subclass({Init:function(a){this._values={},void 0!=a&&this.SetMany(a)},Set:function(a,b){if(void 0===this._options[a])throw TypeError(this.constructor+' has no attribute named "'+a+'"');this[a]=b},SetMany:function(a){for(var b in a)this.Set(b,a[b])},Derived:function(a){var b=this.constructor();return b._values.__proto__=this._values.__proto__,void 0!=a&&b.SetMany(a),b},listSettings:function(a,b){void 0===b&&(b=",\n");var c=[];for(var d in this._options)a&&!this._values.hasOwnProperty(d)||c.push(d+" = "+this[d]);return c.join(b)}},{Define:function(a){var b=this.Subclass({_options:a});b.ParseOptions=this.ParseOptions;for(var c in a)Object.defineProperty(b.prototype,c,a[c].PropertyDescriptor(b,c));return b},ParseOptions:function(a){var c={};if(a=a.trim(),!a)return this(c);for(var d=a.split(","),e=0,f=d.length;e<f;++e){var g=d[e].split("="),h=g[0].trim();if(h||b.Error('Empty key in "'+a+'"'),g.length<2)c[h]=void 0;else{for(var i=g.slice(1).join("="),j=0,k=-1;;){for(;;){var l=k+1,m=i.indexOf("{",l),n=i.indexOf("}",l);if(k=n>=0&&(n<m||m==-1)?n:m,k<0)break;k>0&&"\\"==i[k-1]||("}"==i[k]?(j--,j<0&&b.Error('Too many closing braces in "'+a+'"')):j++)}if(!j)break;k=i.length,e++,e>=f&&b.Error('Not enough closing braces in "'+a+'"'),i+=","+d[e]}i=i.trim(),"{"==i[0]&&"}"==i[i.length-1]&&(i=i.slice(1,-1)),c[h]=i}}return this(c)}});return a}(),b=function(a){var b=a.ConfigData,c=a.Switch,d=a.SwitchChoice,e=a.Choice,f=a.Literal,g=a.Macro,h=a.Integer,i=a.Math,j=a.TeXParsedLiteral,k=b.Define({"detect-display-math":c(),"detect-family":c(),"detect-inline-family":e("text","math"),"detect-inline-weight":e("text","math"),"detect-mode":c(),"detect-shape":c(),"detect-weight":c(),color:f(""),"math-rm":g("\\mathrm"),"math-sf":g("\\mathsf
|
||
|
this.Push(h(e,c,this.stack.env).mml())}};return e.Definitions.Add({macros:{sisetup:"SIunitx",si:"SIunitx",SI:"SIunitx",SIlist:"SIunitx",SIrange:"SIunitx",num:"SIunitx",ang:"SIunitx",numlist:"SIunitx",numrange:"SIunitx"}},null,!0),e.Parse.Augment({SIunitx:function(a){j[a.slice(1)].call(this,a)}}),MathJax.Hub.Startup.signal.Post("TeX siunitx Ready"),j}(b,c,d,g)}()}),MathJax.Ajax.loadComplete("[Contrib]/siunitx/siunitx.js");
|