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