/
MinimalExample.java
40 lines (34 loc) · 1.29 KB
/
MinimalExample.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/* Copyright (c) 2008-2011, The University of Edinburgh.
* All Rights Reserved
*/
package uk.ac.ed.ph.snuggletex.samples;
import uk.ac.ed.ph.snuggletex.SnuggleInput;
import uk.ac.ed.ph.snuggletex.SnuggleEngine;
import uk.ac.ed.ph.snuggletex.SnuggleSession;
import java.io.IOException;
/**
* Example demonstrating a minimal example use of SnuggleTeX.
* <p>
* This simply converts a fixed input String of LaTeX to XML.
* (In this case, the result is a fragment of MathML.)
*
* @see XMLStringOutputExample
* @see WebPageExample
*
* @author David McKain
*/
public final class MinimalExample {
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);
}
}