az-mathml-to-latex
Version:
A JavaScript tool to convert mathml string to LaTeX string
52 lines (51 loc) • 2.48 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 mathml_element_to_latex_converter_1.mathMLElementToLaTeXConverter(child); })
.map(function (converter) { return converter.convert(); })
.join(' ');
if (this._notation === 'actuarial')
return "\\overline{\\left." + latexJoinedChildren + "\\right|}";
if (this._notation === 'radical')
return "\\sqrt{" + latexJoinedChildren + "}";
if (['box', 'roundedbox', 'circle'].includes(this._notation))
return "\\boxed{" + latexJoinedChildren + "}";
if (this._notation === 'left')
return "\\left|" + latexJoinedChildren;
if (this._notation === 'right')
return latexJoinedChildren + "\\right|";
if (this._notation === 'top')
return "\\overline{" + latexJoinedChildren + "}";
if (this._notation === 'bottom')
return "\\underline{" + latexJoinedChildren + "}";
if (this._notation === 'updiagonalstrike')
return "\\cancel{" + latexJoinedChildren + "}";
if (this._notation === 'downdiagonalstrike')
return "\\bcancel{" + latexJoinedChildren + "}";
if (this._notation === 'updiagonalarrow')
return "\\cancelto{}{" + latexJoinedChildren + "}";
if (['verticalstrike', 'horizontalstrike'].includes(this._notation))
return "\\hcancel{" + latexJoinedChildren + "}";
if (this._notation === 'madruwb')
return "\\underline{" + latexJoinedChildren + "\\right|}";
if (this._notation === 'phasorangle')
return "{\\angle \\underline{" + latexJoinedChildren + "}}";
return "\\overline{\\left.\\right)" + latexJoinedChildren + "}";
};
Object.defineProperty(MEnclose.prototype, "_notation", {
get: function () {
return this._mathmlElement.attributes.notation || 'longdiv';
},
enumerable: false,
configurable: true
});
return MEnclose;
}());
exports.MEnclose = MEnclose;