NewcommandConfiguration.ts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*************************************************************
  2. *
  3. * Copyright (c) 2018-2022 The MathJax Consortium
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /**
  18. * @fileoverview Configuration file for the Newcommand package.
  19. *
  20. * @author v.sorge@mathjax.org (Volker Sorge)
  21. */
  22. import {Configuration, ParserConfiguration} from '../Configuration.js';
  23. import {BeginEnvItem} from './NewcommandItems.js';
  24. import NewcommandUtil from './NewcommandUtil.js';
  25. import './NewcommandMappings.js';
  26. import ParseMethods from '../ParseMethods.js';
  27. import * as sm from '../SymbolMap.js';
  28. /**
  29. * Init method for Newcommand package.
  30. * @param {Configuration} config The current configuration.
  31. */
  32. let init = function(config: ParserConfiguration) {
  33. new sm.DelimiterMap(NewcommandUtil.NEW_DELIMITER,
  34. ParseMethods.delimiter, {});
  35. new sm.CommandMap(NewcommandUtil.NEW_COMMAND, {}, {});
  36. new sm.EnvironmentMap(NewcommandUtil.NEW_ENVIRONMENT,
  37. ParseMethods.environment, {}, {});
  38. config.append(Configuration.local(
  39. {handler: {character: [],
  40. delimiter: [NewcommandUtil.NEW_DELIMITER],
  41. macro: [NewcommandUtil.NEW_DELIMITER,
  42. NewcommandUtil.NEW_COMMAND],
  43. environment: [NewcommandUtil.NEW_ENVIRONMENT]
  44. },
  45. priority: -1}));
  46. };
  47. export const NewcommandConfiguration = Configuration.create(
  48. 'newcommand', {
  49. handler: {
  50. macro: ['Newcommand-macros']
  51. },
  52. items: {
  53. [BeginEnvItem.prototype.kind]: BeginEnvItem,
  54. },
  55. options: {maxMacros: 1000},
  56. init: init
  57. }
  58. );