@qtikit/mathml-to-latex
Version:
A JavaScript tool to convert mathml string to LaTeX string
38 lines (37 loc) • 1.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.MI = void 0;
var helpers_1 = require("../../../helpers");
var syntax_1 = require("../../../../syntax");
var MI = /** @class */ (function () {
function MI(mathElement) {
this._mathmlElement = mathElement;
}
MI.prototype.convert = function () {
var normalizedValue = (0, helpers_1.normalizeWhiteSpaces)(this._mathmlElement.value);
if (normalizedValue === ' ')
return Character.apply(normalizedValue);
var trimmedValue = normalizedValue.trim();
return Character.apply(trimmedValue);
};
return MI;
}());
exports.MI = MI;
var Character = /** @class */ (function () {
function Character(value) {
this._value = value;
}
Character.apply = function (value) {
return new Character(value)._apply();
};
Character.prototype._apply = function () {
return this._findByCharacter() || this._findByGlyph() || this._value;
};
Character.prototype._findByCharacter = function () {
return syntax_1.allMathSymbolsByChar[this._value];
};
Character.prototype._findByGlyph = function () {
return syntax_1.allMathSymbolsByGlyph[this._value];
};
return Character;
}());