PageRenderTime 40ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/talk2/mathjax/unpacked/extensions/TeX/verb.js

https://github.com/williamstein/mazur-explicit-formula
JavaScript | 58 lines | 22 code | 10 blank | 26 comment | 7 complexity | d6cfca9780f80abea58f0004171e988b MD5 | raw file
Possible License(s): Apache-2.0, GPL-2.0, MIT
  1. /*************************************************************
  2. *
  3. * MathJax/extensions/TeX/verb.js
  4. *
  5. * Implements the \verb|...| command for including text verbatim
  6. * (with no processing of macros or special characters).
  7. *
  8. * ---------------------------------------------------------------------
  9. *
  10. * Copyright (c) 2009-2012 Design Science, Inc.
  11. *
  12. * Licensed under the Apache License, Version 2.0 (the "License");
  13. * you may not use this file except in compliance with the License.
  14. * You may obtain a copy of the License at
  15. *
  16. * http://www.apache.org/licenses/LICENSE-2.0
  17. *
  18. * Unless required by applicable law or agreed to in writing, software
  19. * distributed under the License is distributed on an "AS IS" BASIS,
  20. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  21. * See the License for the specific language governing permissions and
  22. * limitations under the License.
  23. */
  24. MathJax.Extension["TeX/verb"] = {
  25. version: "2.1"
  26. };
  27. MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
  28. var MML = MathJax.ElementJax.mml;
  29. var TEX = MathJax.InputJax.TeX;
  30. var TEXDEF = TEX.Definitions;
  31. TEXDEF.Add({macros: {verb: 'Verb'}},null,true);
  32. TEX.Parse.Augment({
  33. /*
  34. * Implement \verb|...|
  35. */
  36. Verb: function (name) {
  37. var c = this.GetNext(); var start = ++this.i;
  38. if (c == "" ) {TEX.Error(name+" requires an argument")}
  39. while (this.i < this.string.length && this.string.charAt(this.i) != c) {this.i++}
  40. if (this.i == this.string.length)
  41. {TEX.Error("Can't find closing delimiter for "+name)}
  42. var text = this.string.slice(start,this.i); this.i++;
  43. this.Push(MML.mtext(text).With({mathvariant:MML.VARIANT.MONOSPACE}));
  44. }
  45. });
  46. MathJax.Hub.Startup.signal.Post("TeX verb Ready");
  47. });
  48. MathJax.Ajax.loadComplete("[MathJax]/extensions/TeX/verb.js");