private SnuggleEngine createSnuggleEngine() { return new SnuggleEngine(getStylesheetManager()); } }
private Node latexToNode(String latex){ SnuggleEngine engine = new SnuggleEngine(); try { SnuggleSession createSession = engine.createSession(); createSession.parseInput(new SnuggleInput(latex)); NodeList dst = createSession.buildDOMSubtree(); return dst.item(0); } catch (IOException e) { throw new RuntimeException(e); } }
private Node latexToNode(String latex){ SnuggleEngine engine = new SnuggleEngine(); try { SnuggleSession createSession = engine.createSession(); createSession.parseInput(new SnuggleInput(latex)); NodeList dst = createSession.buildDOMSubtree(); return dst.item(0); } catch (IOException e) { throw new RuntimeException(e); } }
public static void main(String[] args) throws IOException { /* Create vanilla SnuggleEngine and new SnuggleSession */ SnuggleEngine engine = new SnuggleEngine(); SnuggleSession session = engine.createSession(); /* Parse some very basic Math Mode input */ SnuggleInput input = new SnuggleInput("$$ x+2=3 $$"); session.parseInput(input); /* Convert the results to an XML String, which in this case will * be a single MathML <math>...</math> element. */ String xmlString = session.buildXMLString(); System.out.println("Input " + input.getString() + " was converted to:\n" + xmlString); } }
public static void main(String[] args) throws IOException { /* Create vanilla SnuggleEngine and new SnuggleSession */ SnuggleEngine engine = new SnuggleEngine(); SnuggleSession session = engine.createSession(); /* Parse some very basic Math Mode input */ SnuggleInput input = new SnuggleInput("$$ x+2=3 $$"); session.parseInput(input); /* Convert the results to an XML String, which in this case will * be a single MathML <math>...</math> element. */ String xmlString = session.buildXMLString(); System.out.println("Input " + input.getString() + " was converted to:\n" + xmlString); } }
public static void main(String[] args) throws IOException { /* Create vanilla SnuggleEngine and new SnuggleSession */ SnuggleEngine engine = new SnuggleEngine(); SnuggleSession session = engine.createSession(); /* Parse some very basic Math Mode input */ SnuggleInput input = new SnuggleInput("$$ x+2=3 $$"); session.parseInput(input); /* Convert the results to an XML String, which in this case will * be a single MathML <math>...</math> element. */ String xmlString = session.buildXMLString(); System.out.println("Input " + input.getString() + " was converted to:\n" + xmlString); } }
SnuggleEngine engine = new SnuggleEngine(); SnuggleSession session = engine.createSession(); try {
SnuggleEngine engine = new SnuggleEngine(); SnuggleSession session = engine.createSession(); try {
SnuggleEngine engine = new SnuggleEngine(); SnuggleSession session = engine.createSession(); try {
/** * 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; }
public static void main(String[] args) throws IOException { /* Create vanilla SnuggleEngine and new SnuggleSession */ SnuggleEngine engine = new SnuggleEngine(); SnuggleSession session = engine.createSession(); /* Parse some LaTeX input */ SnuggleInput input = new SnuggleInput("\\section*{The quadratic formula}" + "$$ \\frac{-b \\pm \\sqrt{b^2-4ac}}{2a} $$"); session.parseInput(input); /* Specify how we want the resulting XML */ XMLStringOutputOptions options = new XMLStringOutputOptions(); options.setSerializationMethod(SerializationMethod.XHTML); options.setIndenting(true); options.setEncoding("UTF-8"); options.setAddingMathSourceAnnotations(true); options.setUsingNamedEntities(true); /* (Only used if caller has an XSLT 2.0 processor) */ /* Convert the results to an XML String, which in this case will * be a single MathML <math>...</math> element. */ System.out.println(session.buildXMLString(options)); } }
public static void main(String[] args) throws IOException { /* Create vanilla SnuggleEngine and new SnuggleSession */ SnuggleEngine engine = new SnuggleEngine(); SnuggleSession session = engine.createSession(); /* Parse some LaTeX input */ SnuggleInput input = new SnuggleInput("\\section*{The quadratic formula}" + "$$ \\frac{-b \\pm \\sqrt{b^2-4ac}}{2a} $$"); session.parseInput(input); /* Specify how we want the resulting XML */ XMLStringOutputOptions options = new XMLStringOutputOptions(); options.setSerializationMethod(SerializationMethod.XHTML); options.setIndenting(true); options.setEncoding("UTF-8"); options.setAddingMathSourceAnnotations(true); if (engine.getStylesheetManager().supportsXSLT20()) { /* Caller has an XSLT 2.0 processor, so let's output named entities for readability */ options.setUsingNamedEntities(true); } /* Convert the results to an XML String, which in this case will * be a single MathML <math>...</math> element. */ System.out.println(session.buildXMLString(options)); } }
public static void main(String[] args) throws IOException { /* Create vanilla SnuggleEngine and new SnuggleSession */ SnuggleEngine engine = new SnuggleEngine(); SnuggleSession session = engine.createSession(); /* Parse some LaTeX input */ SnuggleInput input = new SnuggleInput("\\section*{The quadratic formula}" + "$$ \\frac{-b \\pm \\sqrt{b^2-4ac}}{2a} $$"); session.parseInput(input); /* Specify how we want the resulting XML */ XMLStringOutputOptions options = new XMLStringOutputOptions(); options.setSerializationMethod(SerializationMethod.XHTML); options.setIndenting(true); options.setEncoding("UTF-8"); options.setAddingMathSourceAnnotations(true); if (engine.getStylesheetManager().supportsXSLT20()) { /* Caller has an XSLT 2.0 processor, so let's output named entities for readability */ options.setUsingNamedEntities(true); } /* Convert the results to an XML String, which in this case will * be a single MathML <math>...</math> element. */ System.out.println(session.buildXMLString(options)); } }
public static void main(String[] args) throws IOException { /* Create vanilla SnuggleEngine and new SnuggleSession */ SnuggleEngine engine = new SnuggleEngine(); SnuggleSession session = engine.createSession(); /* Parse some very basic Math Mode input */ SnuggleInput input = new SnuggleInput("$$ e^{i\\pi} = -1 $$"); session.parseInput(input); /* Create "options" Object to SnuggleTeX what kind of web page we want. We're going * to generate one that will work fine with MOZILLA and tweak a few options, just for * fun! */ WebPageOutputOptions options = WebPageOutputOptionsTemplates.createWebPageOptions(WebPageType.MOZILLA); options.setTitle("My Web Page"); options.setAddingTitleHeading(true); options.setIndenting(true); options.setAddingMathSourceAnnotations(true); options.setIncludingStyleElement(false); /* Now ask SnuggleTeX to write the resulting output to the console. * (You would normally send the output somewhere more interesting, though!) */ session.writeWebPage(options, System.out); } }
public static void main(String[] args) throws IOException { /* Create vanilla SnuggleEngine and new SnuggleSession */ SnuggleEngine engine = new SnuggleEngine(); SnuggleSession session = engine.createSession(); /* Parse some very basic Math Mode input */ SnuggleInput input = new SnuggleInput("$$ a^2 = b^2 + c^2 $$"); session.parseInput(input); /* Create "options" Object to SnuggleTeX what kind of web page we want. We're going * to generate one that will work fine with MOZILLA and tweak a few options, just for * fun! */ WebPageOutputOptions options = WebPageOutputOptionsBuilder.createHTML5MathJaxOptions(); options.setTitle("My Web Page"); options.setAddingTitleHeading(true); options.setIndenting(true); options.setAddingMathSourceAnnotations(true); options.setIncludingStyleElement(false); /* Now ask SnuggleTeX to write the resulting output to the console. * (You would normally send the output somewhere more interesting, though!) */ session.writeWebPage(options, System.out); } }
public static void main(String[] args) throws IOException { /* Create vanilla SnuggleEngine and new SnuggleSession */ SnuggleEngine engine = new SnuggleEngine(); SnuggleSession session = engine.createSession(); /* Parse some very basic Math Mode input */ SnuggleInput input = new SnuggleInput("$$ e^{i\\pi} = -1 $$"); session.parseInput(input); /* Create "options" Object to SnuggleTeX what kind of web page we want. We're going * to generate one that will work fine with MOZILLA and tweak a few options, just for * fun! */ WebPageOutputOptions options = WebPageOutputOptionsTemplates.createWebPageOptions(WebPageType.MOZILLA); options.setTitle("My Web Page"); options.setAddingTitleHeading(true); options.setIndenting(true); options.setAddingMathSourceAnnotations(true); options.setIncludingStyleElement(false); /* Now ask SnuggleTeX to write the resulting output to the console. * (You would normally send the output somewhere more interesting, though!) */ session.writeWebPage(options, System.out); } }