use of us.parr.bookish.model.Latex in project bookish by parrt.
the class Translator method visitLatex.
@Override
public OutputModelObject visitLatex(BookishParser.LatexContext ctx) {
String text = ctx.getText().trim();
// \latex{{...}}
List<String> stuff = extract(latexPattern, text);
text = stuff.get(0);
if (target == Tool.Target.LATEX || target == Tool.Target.LATEX_BOOK) {
return new Latex(this, null, text, text);
}
String relativePath = "images/latex-" + md5hash(text) + ".svg";
String src = outputDir + "/" + relativePath;
Path outpath = Paths.get(src);
if (!Files.exists(outpath)) {
Triple<String, Float, Float> results = texConverter.tex2svg(text, LATEX, BLOCK_EQN_FONT_SIZE);
String svg = results.a;
try {
System.out.println(outpath);
Files.write(outpath, svg.getBytes());
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
return new Latex(this, relativePath, text, text);
}
Aggregations