MathtoolsConfiguration.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. "use strict";
  2. var __values = (this && this.__values) || function(o) {
  3. var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
  4. if (m) return m.call(o);
  5. if (o && typeof o.length === "number") return {
  6. next: function () {
  7. if (o && i >= o.length) o = void 0;
  8. return { value: o && o[i++], done: !o };
  9. }
  10. };
  11. throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
  12. };
  13. var __importDefault = (this && this.__importDefault) || function (mod) {
  14. return (mod && mod.__esModule) ? mod : { "default": mod };
  15. };
  16. var _a;
  17. Object.defineProperty(exports, "__esModule", { value: true });
  18. exports.MathtoolsConfiguration = exports.fixPrescripts = exports.PAIREDDELIMS = void 0;
  19. var Configuration_js_1 = require("../Configuration.js");
  20. var SymbolMap_js_1 = require("../SymbolMap.js");
  21. var NodeUtil_js_1 = __importDefault(require("../NodeUtil.js"));
  22. var Options_js_1 = require("../../../util/Options.js");
  23. require("./MathtoolsMappings.js");
  24. var MathtoolsUtil_js_1 = require("./MathtoolsUtil.js");
  25. var MathtoolsTags_js_1 = require("./MathtoolsTags.js");
  26. var MathtoolsItems_js_1 = require("./MathtoolsItems.js");
  27. exports.PAIREDDELIMS = 'mathtools-paired-delims';
  28. function initMathtools(config) {
  29. new SymbolMap_js_1.CommandMap(exports.PAIREDDELIMS, {}, {});
  30. config.append(Configuration_js_1.Configuration.local({ handler: { macro: [exports.PAIREDDELIMS] }, priority: -5 }));
  31. }
  32. function configMathtools(config, jax) {
  33. var e_1, _a;
  34. var parser = jax.parseOptions;
  35. var pairedDelims = parser.options.mathtools.pairedDelimiters;
  36. try {
  37. for (var _b = __values(Object.keys(pairedDelims)), _c = _b.next(); !_c.done; _c = _b.next()) {
  38. var cs = _c.value;
  39. MathtoolsUtil_js_1.MathtoolsUtil.addPairedDelims(parser, cs, pairedDelims[cs]);
  40. }
  41. }
  42. catch (e_1_1) { e_1 = { error: e_1_1 }; }
  43. finally {
  44. try {
  45. if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
  46. }
  47. finally { if (e_1) throw e_1.error; }
  48. }
  49. (0, MathtoolsTags_js_1.MathtoolsTagFormat)(config, jax);
  50. }
  51. function fixPrescripts(_a) {
  52. var e_2, _b, e_3, _c, e_4, _d;
  53. var data = _a.data;
  54. try {
  55. for (var _e = __values(data.getList('mmultiscripts')), _f = _e.next(); !_f.done; _f = _e.next()) {
  56. var node = _f.value;
  57. if (!node.getProperty('fixPrescript'))
  58. continue;
  59. var childNodes = NodeUtil_js_1.default.getChildren(node);
  60. var n = 0;
  61. try {
  62. for (var _g = (e_3 = void 0, __values([1, 2])), _h = _g.next(); !_h.done; _h = _g.next()) {
  63. var i = _h.value;
  64. if (!childNodes[i]) {
  65. NodeUtil_js_1.default.setChild(node, i, data.nodeFactory.create('node', 'none'));
  66. n++;
  67. }
  68. }
  69. }
  70. catch (e_3_1) { e_3 = { error: e_3_1 }; }
  71. finally {
  72. try {
  73. if (_h && !_h.done && (_c = _g.return)) _c.call(_g);
  74. }
  75. finally { if (e_3) throw e_3.error; }
  76. }
  77. try {
  78. for (var _j = (e_4 = void 0, __values([4, 5])), _k = _j.next(); !_k.done; _k = _j.next()) {
  79. var i = _k.value;
  80. if (NodeUtil_js_1.default.isType(childNodes[i], 'mrow') && NodeUtil_js_1.default.getChildren(childNodes[i]).length === 0) {
  81. NodeUtil_js_1.default.setChild(node, i, data.nodeFactory.create('node', 'none'));
  82. }
  83. }
  84. }
  85. catch (e_4_1) { e_4 = { error: e_4_1 }; }
  86. finally {
  87. try {
  88. if (_k && !_k.done && (_d = _j.return)) _d.call(_j);
  89. }
  90. finally { if (e_4) throw e_4.error; }
  91. }
  92. if (n === 2) {
  93. childNodes.splice(1, 2);
  94. }
  95. }
  96. }
  97. catch (e_2_1) { e_2 = { error: e_2_1 }; }
  98. finally {
  99. try {
  100. if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
  101. }
  102. finally { if (e_2) throw e_2.error; }
  103. }
  104. }
  105. exports.fixPrescripts = fixPrescripts;
  106. exports.MathtoolsConfiguration = Configuration_js_1.Configuration.create('mathtools', {
  107. handler: {
  108. macro: ['mathtools-macros', 'mathtools-delimiters'],
  109. environment: ['mathtools-environments'],
  110. delimiter: ['mathtools-delimiters'],
  111. character: ['mathtools-characters']
  112. },
  113. items: (_a = {},
  114. _a[MathtoolsItems_js_1.MultlinedItem.prototype.kind] = MathtoolsItems_js_1.MultlinedItem,
  115. _a),
  116. init: initMathtools,
  117. config: configMathtools,
  118. postprocessors: [[fixPrescripts, -6]],
  119. options: {
  120. mathtools: {
  121. 'multlinegap': '1em',
  122. 'multlined-pos': 'c',
  123. 'firstline-afterskip': '',
  124. 'lastline-preskip': '',
  125. 'smallmatrix-align': 'c',
  126. 'shortvdotsadjustabove': '.2em',
  127. 'shortvdotsadjustbelow': '.2em',
  128. 'centercolon': false,
  129. 'centercolon-offset': '.04em',
  130. 'thincolon-dx': '-.04em',
  131. 'thincolon-dw': '-.08em',
  132. 'use-unicode': false,
  133. 'prescript-sub-format': '',
  134. 'prescript-sup-format': '',
  135. 'prescript-arg-format': '',
  136. 'allow-mathtoolsset': true,
  137. pairedDelimiters: (0, Options_js_1.expandable)({}),
  138. tagforms: (0, Options_js_1.expandable)({}),
  139. }
  140. }
  141. });
  142. //# sourceMappingURL=MathtoolsConfiguration.js.map