/** * Convert a tex math formula into a Symja expression. The SnuggleTeX engine first converts the TeX expression in a * MathML expression. This MathML expression is then converted to Symja. * * @param texStr * the tex math formula * @return */ public IExpr toExpression(String texStr) { SnuggleEngine engine = new SnuggleEngine(); SnuggleSession session = engine.createSession(); session.getConfiguration().setFailingFast(true); SnuggleInput input = new SnuggleInput("$$ " + texStr + " $$"); try { if (session.parseInput(input)) { NodeList nodes = session.buildDOMSubtree(); int[] position = new int[] { 0 }; return convert(nodes, position, null, 0); } List<InputError> errors = session.getErrors(); for (int i = 0; i < errors.size(); i++) { fEngine.printMessage(errors.get(i).toString()); } } catch (Exception e) { if (Config.SHOW_STACKTRACE) { e.printStackTrace(); } } return F.$Aborted; }