enclose.js 2.1 KB

1234567891011121314151617181920212223242526272829303132
  1. /* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
  2. /* vim: set ts=2 et sw=2 tw=80: */
  3. /*************************************************************
  4. *
  5. * MathJax/extensions/TeX/enclose.js
  6. *
  7. * Implements the \enclose macros, which give access from TeX to the
  8. * <menclose> tag in the MathML that underlies MathJax's internal format.
  9. *
  10. * Usage:
  11. *
  12. * \enclose{notation}{math} % enclose math using given notation
  13. * \enclose{notation,notation,...}{math} % enclose with several notations
  14. * \enclose{notation}[attributes]{math} % enclose with attributes
  15. *
  16. * ---------------------------------------------------------------------
  17. *
  18. * Copyright (c) 2011-2013 The MathJax Consortium
  19. *
  20. * Licensed under the Apache License, Version 2.0 (the "License");
  21. * you may not use this file except in compliance with the License.
  22. * You may obtain a copy of the License at
  23. *
  24. * http://www.apache.org/licenses/LICENSE-2.0
  25. *
  26. * Unless required by applicable law or agreed to in writing, software
  27. * distributed under the License is distributed on an "AS IS" BASIS,
  28. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  29. * See the License for the specific language governing permissions and
  30. * limitations under the License.
  31. */MathJax.Extension["TeX/enclose"]={version:"2.2",ALLOWED:{arrow:1,color:1,mathcolor:1,background:1,mathbackground:1,padding:1,thickness:1}};MathJax.Hub.Register.StartupHook("TeX Jax Ready",function(){var d=MathJax.InputJax.TeX,g=MathJax.ElementJax.mml,h=MathJax.Extension["TeX/enclose"].ALLOWED;d.Definitions.Add({macros:{enclose:"Enclose"}},null,!0);d.Parse.Augment({Enclose:function(b){var e=this.GetArgument(b),c=this.GetBrackets(b);b=this.ParseArg(b);e={notation:e.replace(/,/g," ")};if(c)for(var c=c.replace(/ /g,"").split(/,/),f=0,d=c.length;f<d;f++){var a=c[f].split(/[:=]/);h[a[0]]&&(a[1]=a[1].replace(/^"(.*)"$/,"$1"),"true"===a[1]&&(a[1]=!0),"false"===a[1]&&(a[1]=!1),e[a[0]]=a[1])}this.Push(g.menclose(b).With(e))}});MathJax.Hub.Startup.signal.Post("TeX enclose Ready")});MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/enclose.js");