/** * Converts the objectExpression into a MathML expression and writes the result to the given <code>Writer</code> * * @param objectExpression * @param out */ synchronized public void toMathML(final IExpr objectExpression, final Writer out) { toMathML(objectExpression, out, false); }
@Override public IExpr evaluate(final IAST ast, EvalEngine engine) { Validate.checkSize(ast, 2); MathMLUtilities mathMLUtil = new MathMLUtilities(engine, false, engine.isRelaxedSyntax()); IExpr arg1 = ast.arg1(); StringWriter stw = new StringWriter(); mathMLUtil.toMathML(arg1, stw); return F.stringx(stw.toString()); }
public MathMLUtilities(final EvalEngine evalEngine, final boolean msie) { fEvalEngine = evalEngine; // set the thread local instance startRequest(); if (msie) { fMathMLFactory = new MathMLFormFactory("m:"); } else { fMathMLFactory = new MathMLFormFactory(); } fParser = new Parser(); fMSIE = msie; }
/** * Constructor for an object which converts an expression into presentation MathML output * * @param evalEngine * @param mathMTagPrefix * if set to <code>true</code> use "m:" as tag prefix for the MathML output. * @param mathMLHeader * print MathML header in output * @param numberFormat * the number formatter (could be <code>null</code>) */ public MathMLUtilities(final EvalEngine evalEngine, final boolean mathMTagPrefix, final boolean mathMLHeader, NumberFormat numberFormat) { fEvalEngine = evalEngine; EvalEngine.set(fEvalEngine); // set the thread local instance startRequest(); if (mathMTagPrefix) { fMathMLFactory = new MathMLFormFactory("m:", numberFormat); } else { fMathMLFactory = new MathMLFormFactory("", numberFormat); } // fParser = new Parser(relaxedSyntax); fMSIE = mathMTagPrefix; fMathMLHeader = mathMLHeader; }
/** * Converts the inputExpression string into a MathML expression and writes the * result to the given <code>Writer</code> * * @param inputExpression * @param out */ synchronized public void toMathML(final String inputExpression, final Writer out) { IExpr parsedExpression = null; ASTNode node; if (inputExpression != null) { try { node = fParser.parse(inputExpression); parsedExpression = AST2Expr.CONST.convert(node); } catch (final Throwable e) { return; // parsedExpression == null ==> fError occured } } toMathML(parsedExpression, out); }
/** * Converts the inputExpression string into a MathML expression and writes the result to the given * <code>Writer</code> * * @param inputExpression * @param out */ synchronized public void toMathML(final String inputExpression, final Writer out) { IExpr parsedExpression = null; // ASTNode node; if (inputExpression != null) { try { ExprParser parser = new ExprParser(fEvalEngine); parsedExpression = parser.parse(inputExpression); // node = fEvalEngine.parseNode(inputExpression); // parsedExpression = AST2Expr.CONST.convert(node, fEvalEngine); } catch (final Throwable e) { return; // parsedExpression == null ==> fError occured } } toMathML(parsedExpression, out); }