@qtikit/mathml-to-latex
Version:
A JavaScript tool to convert mathml string to LaTeX string
52 lines (51 loc) • 2.56 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MEnclose = void 0;
var mathml_element_to_latex_converter_1 = require("../../../helpers/mathml-element-to-latex-converter");
var MEnclose = /** @class */ (function () {
function MEnclose(mathElement) {
this._mathmlElement = mathElement;
}
MEnclose.prototype.convert = function () {
var latexJoinedChildren = this._mathmlElement.children
.map(function (child) { return (0, mathml_element_to_latex_converter_1.mathMLElementToLaTeXConverter)(child); })
.map(function (converter) { return converter.convert(); })
.join(' ');
if (this._notation === 'actuarial')
return "\\overline{\\left.".concat(latexJoinedChildren, "\\right|}");
if (this._notation === 'radical')
return "\\sqrt{".concat(latexJoinedChildren, "}");
if (['box', 'roundedbox', 'circle'].includes(this._notation))
return "\\boxed{".concat(latexJoinedChildren, "}");
if (this._notation === 'left')
return "\\left|".concat(latexJoinedChildren);
if (this._notation === 'right')
return "".concat(latexJoinedChildren, "\\right|");
if (this._notation === 'top')
return "\\overline{".concat(latexJoinedChildren, "}");
if (this._notation === 'bottom')
return "\\underline{".concat(latexJoinedChildren, "}");
if (this._notation === 'updiagonalstrike')
return "\\cancel{".concat(latexJoinedChildren, "}");
if (this._notation === 'downdiagonalstrike')
return "\\bcancel{".concat(latexJoinedChildren, "}");
if (this._notation === 'updiagonalarrow')
return "\\cancelto{}{".concat(latexJoinedChildren, "}");
if (['verticalstrike', 'horizontalstrike'].includes(this._notation))
return "\\hcancel{".concat(latexJoinedChildren, "}");
if (this._notation === 'madruwb')
return "\\underline{".concat(latexJoinedChildren, "\\right|}");
if (this._notation === 'phasorangle')
return "{\\angle \\underline{".concat(latexJoinedChildren, "}}");
return "\\overline{\\left.\\right)".concat(latexJoinedChildren, "}");
};
Object.defineProperty(MEnclose.prototype, "_notation", {
get: function () {
return this._mathmlElement.attributes.notation || 'longdiv';
},
enumerable: false,
configurable: true
});
return MEnclose;
}());
exports.MEnclose = MEnclose;