/** * Convert the Expression to MathML. * * @return {string} */ toContentMathML() : string { if (this.subtype === 'assignment') { var str, i, ii; str = 'assignment' + this.content.map(MathLib.toContentMathML).join('assignment') + MathLib.toContentMathML(this.value); for (i = 0, ii = this.content.length; i < ii; i++) { str += ''; } return str; } if (this.subtype === 'binaryOperator') { var op = this.name === 'pow' ? 'power' : this.name; return '' + op + '' + this.content[0].toContentMathML() + this.content[1].toContentMathML() + ''; } if (this.subtype === 'brackets') { return this.content.toContentMathML(); } if (this.subtype === 'number') { return '' + this.value + ''; } if (this.subtype === 'variable') { return '' + this.value + ''; } if (this.subtype === 'naryOperator') { return '' + this.name + '' + this.content.map(expr => expr.toContentMathML()).join('') + ''; } if (this.subtype === 'unaryOperator') { if (this.value === '-') { return 'unary_minus' + this.content.toContentMathML() + ''; } return this.content.toContentMathML(); } if (this.subtype === 'functionCall') { // There are some functions which have different names in MathML var conversion = { arcosh: 'arccosh', arcoth: 'arccoth', arcsch: 'arccsch', arsech: 'arcsech', arsinh: 'arcsinh', artanh: 'arctanh', identity: 'ident' }, funcName; if (this.value in conversion) { funcName = conversion[this.value]; } else { funcName = this.value; } return '' + this.contentMathMLName + '' + this.content.map(expr => expr.toContentMathML()).join('') + ''; } if (this.subtype === 'functionDefinition') { return '' + this.args.join('') + '' + this.content.map(expr => expr.toContentMathML()) + ''; } }