UNPKG

react-native-mathjax-html-to-svg

Version:

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

62 lines (61 loc) 2.48 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.ProofTreeItem = void 0; var TexError_js_1 = require("../TexError.js"); var StackItem_js_1 = require("../StackItem.js"); var Stack_js_1 = require("../Stack.js"); var BussproofsUtil = require("./BussproofsUtil.js"); var ProofTreeItem = (function (_super) { __extends(ProofTreeItem, _super); function ProofTreeItem() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.leftLabel = null; _this.rigthLabel = null; _this.innerStack = new Stack_js_1.default(_this.factory, {}, true); return _this; } Object.defineProperty(ProofTreeItem.prototype, "kind", { get: function () { return 'proofTree'; }, enumerable: false, configurable: true }); ProofTreeItem.prototype.checkItem = function (item) { if (item.isKind('end') && item.getName() === 'prooftree') { var node = this.toMml(); BussproofsUtil.setProperty(node, 'proof', true); return [[this.factory.create('mml', node), item], true]; } if (item.isKind('stop')) { throw new TexError_js_1.default('EnvMissingEnd', 'Missing \\end{%1}', this.getName()); } this.innerStack.Push(item); return StackItem_js_1.BaseItem.fail; }; ProofTreeItem.prototype.toMml = function () { var tree = _super.prototype.toMml.call(this); var start = this.innerStack.Top(); if (start.isKind('start') && !start.Size()) { return tree; } this.innerStack.Push(this.factory.create('stop')); var prefix = this.innerStack.Top().toMml(); return this.create('node', 'mrow', [prefix, tree], {}); }; return ProofTreeItem; }(StackItem_js_1.BaseItem)); exports.ProofTreeItem = ProofTreeItem;