boldsymbol.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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/boldsymbol.js
  6. *
  7. * Implements the \boldsymbol{...} command to make bold
  8. * versions of all math characters (not just variables).
  9. *
  10. * ---------------------------------------------------------------------
  11. *
  12. * Copyright (c) 2009-2017 The MathJax Consortium
  13. *
  14. * Licensed under the Apache License, Version 2.0 (the "License");
  15. * you may not use this file except in compliance with the License.
  16. * You may obtain a copy of the License at
  17. *
  18. * http://www.apache.org/licenses/LICENSE-2.0
  19. *
  20. * Unless required by applicable law or agreed to in writing, software
  21. * distributed under the License is distributed on an "AS IS" BASIS,
  22. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  23. * See the License for the specific language governing permissions and
  24. * limitations under the License.
  25. */
  26. MathJax.Extension["TeX/boldsymbol"] = {
  27. version: "2.7.2"
  28. };
  29. MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
  30. var MML = MathJax.ElementJax.mml;
  31. var TEX = MathJax.InputJax.TeX;
  32. var TEXDEF = TEX.Definitions;
  33. var BOLDVARIANT = {};
  34. BOLDVARIANT[MML.VARIANT.NORMAL] = MML.VARIANT.BOLD;
  35. BOLDVARIANT[MML.VARIANT.ITALIC] = MML.VARIANT.BOLDITALIC;
  36. BOLDVARIANT[MML.VARIANT.FRAKTUR] = MML.VARIANT.BOLDFRAKTUR;
  37. BOLDVARIANT[MML.VARIANT.SCRIPT] = MML.VARIANT.BOLDSCRIPT;
  38. BOLDVARIANT[MML.VARIANT.SANSSERIF] = MML.VARIANT.BOLDSANSSERIF;
  39. BOLDVARIANT["-tex-caligraphic"] = "-tex-caligraphic-bold";
  40. BOLDVARIANT["-tex-oldstyle"] = "-tex-oldstyle-bold";
  41. TEXDEF.Add({macros: {boldsymbol: 'Boldsymbol'}},null,true);
  42. TEX.Parse.Augment({
  43. mmlToken: function (token) {
  44. if (this.stack.env.boldsymbol) {
  45. var variant = token.Get("mathvariant");
  46. if (variant == null) {token.mathvariant = MML.VARIANT.BOLD}
  47. else {token.mathvariant = (BOLDVARIANT[variant]||variant)}
  48. }
  49. return token;
  50. },
  51. Boldsymbol: function (name) {
  52. var boldsymbol = this.stack.env.boldsymbol,
  53. font = this.stack.env.font;
  54. this.stack.env.boldsymbol = true;
  55. this.stack.env.font = null;
  56. var mml = this.ParseArg(name);
  57. this.stack.env.font = font;
  58. this.stack.env.boldsymbol = boldsymbol;
  59. this.Push(mml);
  60. }
  61. });
  62. MathJax.Hub.Startup.signal.Post("TeX boldsymbol Ready");
  63. });
  64. MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/boldsymbol.js");