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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
#include "parser.h"
#include "printer.h"
#include "parser.h"
#include "gfanapplication.h"
class ToLatexApplication : public GFanApplication
{
SimpleOption optionAddHeader;
SimpleOption optionPolynomialSet;
SimpleOption optionPolynomialSetList;
public:
const char *helpText()
{
return "This program converts ASCII math to TeX math. The data-type is specified by the options.\n";
}
ToLatexApplication():
optionPolynomialSet("--polynomialset_","The data to be converted is a list of polynomials."),
optionPolynomialSetList("--polynomialsetlist_","The data to be converted is a list of lists of polynomials."),
optionAddHeader("-h","Add a header to the output. Using this option the output will be LaTeXable right away.")
{
registerOptions();
}
char *name()
{
return "_tolatex";
}
int main()
{
LatexPrinter out(Stdout);
FileParser in(Stdin);
if(optionAddHeader.getValue())
fprintf(Stdout,"\\documentclass{article}\n"
"\\usepackage[english]{babel}\n"
"\\begin{document}\n");
if(optionPolynomialSet.getValue())
{
out.printPolynomialSet(in.parsePolynomialSetWithRing());
}
else if(optionPolynomialSetList.getValue())
{
out.printPolynomialSetList(in.parsePolynomialSetListWithRing());
}
else
{
fprintf(Stderr,"No type specified\n");
assert(0);
}
if(optionAddHeader.getValue())
fprintf(Stdout,"\\end{document}\n");
return 0;
}
};
static ToLatexApplication theApplication;
|