UNPKG

react-native-mathjax-html-to-svg

Version:

React Native component to display mathematics in html using MathJax. Uses [MathJax](https://github.com/mathjax/)

69 lines (68 loc) 2.78 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.BraketItem = void 0; var StackItem_js_1 = require("../StackItem.js"); var MmlNode_js_1 = require("../../../core/MmlTree/MmlNode.js"); var ParseUtil_js_1 = require("../ParseUtil.js"); var BraketItem = (function (_super) { __extends(BraketItem, _super); function BraketItem() { return _super !== null && _super.apply(this, arguments) || this; } Object.defineProperty(BraketItem.prototype, "kind", { get: function () { return 'braket'; }, enumerable: false, configurable: true }); Object.defineProperty(BraketItem.prototype, "isOpen", { get: function () { return true; }, enumerable: false, configurable: true }); BraketItem.prototype.checkItem = function (item) { if (item.isKind('close')) { return [[this.factory.create('mml', this.toMml())], true]; } if (item.isKind('mml')) { this.Push(item.toMml()); if (this.getProperty('single')) { return [[this.toMml()], true]; } return StackItem_js_1.BaseItem.fail; } return _super.prototype.checkItem.call(this, item); }; BraketItem.prototype.toMml = function () { var inner = _super.prototype.toMml.call(this); var open = this.getProperty('open'); var close = this.getProperty('close'); if (this.getProperty('stretchy')) { return ParseUtil_js_1.default.fenced(this.factory.configuration, open, inner, close); } var attrs = { fence: true, stretchy: false, symmetric: true, texClass: MmlNode_js_1.TEXCLASS.OPEN }; var openNode = this.create('token', 'mo', attrs, open); attrs.texClass = MmlNode_js_1.TEXCLASS.CLOSE; var closeNode = this.create('token', 'mo', attrs, close); var mrow = this.create('node', 'mrow', [openNode, inner, closeNode], { open: open, close: close, texClass: MmlNode_js_1.TEXCLASS.INNER }); return mrow; }; return BraketItem; }(StackItem_js_1.BaseItem)); exports.BraketItem = BraketItem;