BraketItems.js 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. "use strict";
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = function (d, b) {
  4. extendStatics = Object.setPrototypeOf ||
  5. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  7. return extendStatics(d, b);
  8. };
  9. return function (d, b) {
  10. if (typeof b !== "function" && b !== null)
  11. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  12. extendStatics(d, b);
  13. function __() { this.constructor = d; }
  14. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15. };
  16. })();
  17. var __importDefault = (this && this.__importDefault) || function (mod) {
  18. return (mod && mod.__esModule) ? mod : { "default": mod };
  19. };
  20. Object.defineProperty(exports, "__esModule", { value: true });
  21. exports.BraketItem = void 0;
  22. var StackItem_js_1 = require("../StackItem.js");
  23. var MmlNode_js_1 = require("../../../core/MmlTree/MmlNode.js");
  24. var ParseUtil_js_1 = __importDefault(require("../ParseUtil.js"));
  25. var BraketItem = (function (_super) {
  26. __extends(BraketItem, _super);
  27. function BraketItem() {
  28. return _super !== null && _super.apply(this, arguments) || this;
  29. }
  30. Object.defineProperty(BraketItem.prototype, "kind", {
  31. get: function () {
  32. return 'braket';
  33. },
  34. enumerable: false,
  35. configurable: true
  36. });
  37. Object.defineProperty(BraketItem.prototype, "isOpen", {
  38. get: function () {
  39. return true;
  40. },
  41. enumerable: false,
  42. configurable: true
  43. });
  44. BraketItem.prototype.checkItem = function (item) {
  45. if (item.isKind('close')) {
  46. return [[this.factory.create('mml', this.toMml())], true];
  47. }
  48. if (item.isKind('mml')) {
  49. this.Push(item.toMml());
  50. if (this.getProperty('single')) {
  51. return [[this.toMml()], true];
  52. }
  53. return StackItem_js_1.BaseItem.fail;
  54. }
  55. return _super.prototype.checkItem.call(this, item);
  56. };
  57. BraketItem.prototype.toMml = function () {
  58. var inner = _super.prototype.toMml.call(this);
  59. var open = this.getProperty('open');
  60. var close = this.getProperty('close');
  61. if (this.getProperty('stretchy')) {
  62. return ParseUtil_js_1.default.fenced(this.factory.configuration, open, inner, close);
  63. }
  64. var attrs = { fence: true, stretchy: false, symmetric: true, texClass: MmlNode_js_1.TEXCLASS.OPEN };
  65. var openNode = this.create('token', 'mo', attrs, open);
  66. attrs.texClass = MmlNode_js_1.TEXCLASS.CLOSE;
  67. var closeNode = this.create('token', 'mo', attrs, close);
  68. var mrow = this.create('node', 'mrow', [openNode, inner, closeNode], { open: open, close: close, texClass: MmlNode_js_1.TEXCLASS.INNER });
  69. return mrow;
  70. };
  71. return BraketItem;
  72. }(StackItem_js_1.BaseItem));
  73. exports.BraketItem = BraketItem;
  74. //# sourceMappingURL=BraketItems.js.map