UNPKG

react-native-mathjax-html-to-svg

Version:

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

82 lines (81 loc) 3.76 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.MultlineItem = void 0; var BaseItems_js_1 = require("../base/BaseItems.js"); var ParseUtil_js_1 = require("../ParseUtil.js"); var NodeUtil_js_1 = require("../NodeUtil.js"); var TexError_js_1 = require("../TexError.js"); var TexConstants_js_1 = require("../TexConstants.js"); var MultlineItem = (function (_super) { __extends(MultlineItem, _super); function MultlineItem(factory) { var args = []; for (var _i = 1; _i < arguments.length; _i++) { args[_i - 1] = arguments[_i]; } var _this = _super.call(this, factory) || this; _this.factory.configuration.tags.start('multline', true, args[0]); return _this; } Object.defineProperty(MultlineItem.prototype, "kind", { get: function () { return 'multline'; }, enumerable: false, configurable: true }); MultlineItem.prototype.EndEntry = function () { if (this.table.length) { ParseUtil_js_1.default.fixInitialMO(this.factory.configuration, this.nodes); } var shove = this.getProperty('shove'); var mtd = this.create('node', 'mtd', this.nodes, shove ? { columnalign: shove } : {}); this.setProperty('shove', null); this.row.push(mtd); this.Clear(); }; MultlineItem.prototype.EndRow = function () { if (this.row.length !== 1) { throw new TexError_js_1.default('MultlineRowsOneCol', 'The rows within the %1 environment must have exactly one column', 'multline'); } var row = this.create('node', 'mtr', this.row); this.table.push(row); this.row = []; }; MultlineItem.prototype.EndTable = function () { _super.prototype.EndTable.call(this); if (this.table.length) { var m = this.table.length - 1, label = -1; if (!NodeUtil_js_1.default.getAttribute(NodeUtil_js_1.default.getChildren(this.table[0])[0], 'columnalign')) { NodeUtil_js_1.default.setAttribute(NodeUtil_js_1.default.getChildren(this.table[0])[0], 'columnalign', TexConstants_js_1.TexConstant.Align.LEFT); } if (!NodeUtil_js_1.default.getAttribute(NodeUtil_js_1.default.getChildren(this.table[m])[0], 'columnalign')) { NodeUtil_js_1.default.setAttribute(NodeUtil_js_1.default.getChildren(this.table[m])[0], 'columnalign', TexConstants_js_1.TexConstant.Align.RIGHT); } var tag = this.factory.configuration.tags.getTag(); if (tag) { label = (this.arraydef.side === TexConstants_js_1.TexConstant.Align.LEFT ? 0 : this.table.length - 1); var mtr = this.table[label]; var mlabel = this.create('node', 'mlabeledtr', [tag].concat(NodeUtil_js_1.default.getChildren(mtr))); NodeUtil_js_1.default.copyAttributes(mtr, mlabel); this.table[label] = mlabel; } } this.factory.configuration.tags.end(); }; return MultlineItem; }(BaseItems_js_1.ArrayItem)); exports.MultlineItem = MultlineItem;