react-native-mathjax-html-to-svg
Version:
React Native component to display mathematics in html using MathJax. Uses [MathJax](https://github.com/mathjax/)
172 lines (171 loc) • 6.46 kB
JavaScript
"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 __());
};
})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __values = (this && this.__values) || function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m) return m.call(o);
if (o && typeof o.length === "number") return {
next: function () {
if (o && i >= o.length) o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MmlMlabeledtr = exports.MmlMtr = void 0;
var MmlNode_js_1 = require("../MmlNode.js");
var Attributes_js_1 = require("../Attributes.js");
var string_js_1 = require("../../../util/string.js");
var MmlMtr = (function (_super) {
__extends(MmlMtr, _super);
function MmlMtr() {
return _super !== null && _super.apply(this, arguments) || this;
}
Object.defineProperty(MmlMtr.prototype, "kind", {
get: function () {
return 'mtr';
},
enumerable: false,
configurable: true
});
Object.defineProperty(MmlMtr.prototype, "linebreakContainer", {
get: function () {
return true;
},
enumerable: false,
configurable: true
});
MmlMtr.prototype.setChildInheritedAttributes = function (attributes, display, level, prime) {
var e_1, _a, e_2, _b;
try {
for (var _c = __values(this.childNodes), _d = _c.next(); !_d.done; _d = _c.next()) {
var child = _d.value;
if (!child.isKind('mtd')) {
this.replaceChild(this.factory.create('mtd'), child)
.appendChild(child);
}
}
}
catch (e_1_1) { e_1 = { error: e_1_1 }; }
finally {
try {
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
}
finally { if (e_1) throw e_1.error; }
}
var calign = string_js_1.split(this.attributes.get('columnalign'));
if (this.arity === 1) {
calign.unshift(this.parent.attributes.get('side'));
}
attributes = this.addInheritedAttributes(attributes, {
rowalign: this.attributes.get('rowalign'),
columnalign: 'center'
});
try {
for (var _e = __values(this.childNodes), _f = _e.next(); !_f.done; _f = _e.next()) {
var child = _f.value;
attributes.columnalign[1] = calign.shift() || attributes.columnalign[1];
child.setInheritedAttributes(attributes, display, level, prime);
}
}
catch (e_2_1) { e_2 = { error: e_2_1 }; }
finally {
try {
if (_f && !_f.done && (_b = _e.return)) _b.call(_e);
}
finally { if (e_2) throw e_2.error; }
}
};
MmlMtr.prototype.verifyChildren = function (options) {
var e_3, _a;
if (this.parent && !this.parent.isKind('mtable')) {
this.mError(this.kind + ' can only be a child of an mtable', options, true);
return;
}
if (!options['fixMtables']) {
try {
for (var _b = __values(this.childNodes), _c = _b.next(); !_c.done; _c = _b.next()) {
var child = _c.value;
if (!child.isKind('mtd')) {
var mtr = this.replaceChild(this.factory.create('mtr'), child);
mtr.mError('Children of ' + this.kind + ' must be mtd', options, true);
}
}
}
catch (e_3_1) { e_3 = { error: e_3_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_3) throw e_3.error; }
}
}
_super.prototype.verifyChildren.call(this, options);
};
MmlMtr.prototype.setTeXclass = function (prev) {
var e_4, _a;
this.getPrevClass(prev);
try {
for (var _b = __values(this.childNodes), _c = _b.next(); !_c.done; _c = _b.next()) {
var child = _c.value;
child.setTeXclass(null);
}
}
catch (e_4_1) { e_4 = { error: e_4_1 }; }
finally {
try {
if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
}
finally { if (e_4) throw e_4.error; }
}
return this;
};
MmlMtr.defaults = __assign(__assign({}, MmlNode_js_1.AbstractMmlNode.defaults), { rowalign: Attributes_js_1.INHERIT, columnalign: Attributes_js_1.INHERIT, groupalign: Attributes_js_1.INHERIT });
return MmlMtr;
}(MmlNode_js_1.AbstractMmlNode));
exports.MmlMtr = MmlMtr;
var MmlMlabeledtr = (function (_super) {
__extends(MmlMlabeledtr, _super);
function MmlMlabeledtr() {
return _super !== null && _super.apply(this, arguments) || this;
}
Object.defineProperty(MmlMlabeledtr.prototype, "kind", {
get: function () {
return 'mlabeledtr';
},
enumerable: false,
configurable: true
});
Object.defineProperty(MmlMlabeledtr.prototype, "arity", {
get: function () {
return 1;
},
enumerable: false,
configurable: true
});
return MmlMlabeledtr;
}(MmlMtr));
exports.MmlMlabeledtr = MmlMlabeledtr;