AmsConfiguration.ts 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 AMS package.
  19. *
  20. * @author v.sorge@mathjax.org (Volker Sorge)
  21. */
  22. import {Configuration, ParserConfiguration} from '../Configuration.js';
  23. import {MultlineItem, FlalignItem} from './AmsItems.js';
  24. import {AbstractTags} from '../Tags.js';
  25. import {NEW_OPS} from './AmsMethods.js';
  26. import './AmsMappings.js';
  27. import {CommandMap} from '../SymbolMap.js';
  28. /**
  29. * Standard AMS style tagging.
  30. * @constructor
  31. * @extends {AbstractTags}
  32. */
  33. export class AmsTags extends AbstractTags { }
  34. /**
  35. * Init method for AMS package.
  36. * @param {ParserConfiguration} config The current configuration.
  37. */
  38. let init = function(config: ParserConfiguration) {
  39. new CommandMap(NEW_OPS, {}, {});
  40. config.append(Configuration.local({handler: {macro: [NEW_OPS]},
  41. priority: -1}));
  42. };
  43. export const AmsConfiguration = Configuration.create(
  44. 'ams', {
  45. handler: {
  46. character: ['AMSmath-operatorLetter'],
  47. delimiter: ['AMSsymbols-delimiter', 'AMSmath-delimiter'],
  48. macro: ['AMSsymbols-mathchar0mi', 'AMSsymbols-mathchar0mo',
  49. 'AMSsymbols-delimiter', 'AMSsymbols-macros',
  50. 'AMSmath-mathchar0mo', 'AMSmath-macros', 'AMSmath-delimiter'],
  51. environment: ['AMSmath-environment']
  52. },
  53. items: {
  54. [MultlineItem.prototype.kind]: MultlineItem,
  55. [FlalignItem.prototype.kind]: FlalignItem,
  56. },
  57. tags: {'ams': AmsTags},
  58. init: init,
  59. config: (_config: ParserConfiguration, jax: any) => {
  60. //
  61. // Move multlineWidth from old location to ams block (remove in next version)
  62. //
  63. if (jax.parseOptions.options.multlineWidth) {
  64. jax.parseOptions.options.ams.multlineWidth = jax.parseOptions.options.multlineWidth;
  65. }
  66. delete jax.parseOptions.options.multlineWidth;
  67. },
  68. options: {
  69. multlineWidth: '',
  70. ams: {
  71. multlineWidth: '100%', // The width to use for multline environments.
  72. multlineIndent: '1em', // The margin to use on both sides of multline environments.
  73. }
  74. }
  75. }
  76. );