cancel.js 2.5 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/cancel.js
  6. *
  7. * Implements the \cancel, \bcancel, \xcancel, and \cancelto macros.
  8. *
  9. * Usage:
  10. *
  11. * \cancel{math} % strikeout math from lower left to upper right
  12. * \bcancel{math} % strikeout from upper left to lower right
  13. * \xcancel{math} % strikeout with an X
  14. * \cancelto{value}{math} % strikeout with arrow going to value
  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/cancel"]={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 h=MathJax.InputJax.TeX,a=MathJax.ElementJax.mml,g=MathJax.Extension["TeX/cancel"];g.setAttributes=function(a,d){if(""!==d){d=d.replace(/ /g,"").split(/,/);for(var b=0,e=d.length;b<e;b++){var c=d[b].split(/[:=]/);g.ALLOWED[c[0]]&&("true"===c[1]&&(c[1]=!0),"false"===c[1]&&(c[1]=!1),a[c[0]]=c[1])}}return a};h.Definitions.Add({macros:{cancel:["Cancel",a.NOTATION.UPDIAGONALSTRIKE],bcancel:["Cancel",a.NOTATION.DOWNDIAGONALSTRIKE],xcancel:["Cancel",a.NOTATION.UPDIAGONALSTRIKE+" "+a.NOTATION.DOWNDIAGONALSTRIKE],cancelto:"CancelTo"}},null,!0);h.Parse.Augment({Cancel:function(f,d){var b=this.GetBrackets(f,""),e=this.ParseArg(f),b=g.setAttributes({notation:d},b);this.Push(a.menclose(e).With(b))},CancelTo:function(f,d){var b=this.ParseArg(f),e=this.GetBrackets(f,""),c=this.ParseArg(f),e=g.setAttributes({notation:a.NOTATION.UPDIAGONALSTRIKE,arrow:!0},e),b=a.mpadded(b).With({depth:"-.1em",height:"+.1em",voffset:".1em"});this.Push(a.msup(a.menclose(c).With(e),b))}});MathJax.Hub.Startup.signal.Post("TeX cancel Ready")});MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/cancel.js");