| 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/noUndefined.js |
| 7 |
* |
| 8 |
* This causes undefined control sequences to be shown as their macro |
| 9 |
* names rather than producing an error message. So $X_{\xxx}$ would |
| 10 |
* display as an X with a subscript consiting of the text "\xxx". |
| 11 |
* |
| 12 |
* To configure this extension, use for example |
| 13 |
* |
| 14 |
* MathJax.Hub.Config({ |
| 15 |
* TeX: { |
| 16 |
* noUndefined: { |
| 17 |
* attributes: { |
| 18 |
* mathcolor: "red", |
| 19 |
* mathbackground: "#FFEEEE", |
| 20 |
* mathsize: "90%" |
| 21 |
* } |
| 22 |
* } |
| 23 |
* } |
| 24 |
* }); |
| 25 |
* |
| 26 |
* --------------------------------------------------------------------- |
| 27 |
* |
| 28 |
* Copyright (c) 2010-2020 The MathJax Consortium |
| 29 |
* |
| 30 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 31 |
* you may not use this file except in compliance with the License. |
| 32 |
* You may obtain a copy of the License at |
| 33 |
* |
| 34 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 35 |
* |
| 36 |
* Unless required by applicable law or agreed to in writing, software |
| 37 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 38 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 39 |
* See the License for the specific language governing permissions and |
| 40 |
* limitations under the License. |
| 41 |
*/ |
| 42 |
|
| 43 |
// |
| 44 |
// The configuration defaults, augmented by the user settings |
| 45 |
// |
| 46 |
MathJax.Extension["TeX/noUndefined"] = { |
| 47 |
version: "2.7.9", |
| 48 |
config: MathJax.Hub.CombineConfig("TeX.noUndefined",{ |
| 49 |
disabled: false, // set to true to return to original error messages |
| 50 |
attributes: { |
| 51 |
mathcolor: "red" |
| 52 |
} |
| 53 |
}) |
| 54 |
}; |
| 55 |
|
| 56 |
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () { |
| 57 |
var CONFIG = MathJax.Extension["TeX/noUndefined"].config; |
| 58 |
var MML = MathJax.ElementJax.mml; |
| 59 |
var UNDEFINED = MathJax.InputJax.TeX.Parse.prototype.csUndefined; |
| 60 |
|
| 61 |
MathJax.InputJax.TeX.Parse.Augment({ |
| 62 |
csUndefined: function (name) { |
| 63 |
if (CONFIG.disabled) {return UNDEFINED.apply(this,arguments)} |
| 64 |
MathJax.Hub.signal.Post(["TeX Jax - undefined control sequence",name]); |
| 65 |
this.Push(MML.mtext(name).With(CONFIG.attributes)); |
| 66 |
} |
| 67 |
}); |
| 68 |
|
| 69 |
MathJax.Hub.Startup.signal.Post("TeX noUndefined Ready"); |
| 70 |
}); |
| 71 |
|
| 72 |
MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/noUndefined.js"); |