http://svgkit.svn.sourceforge.net/viewvc/svgkit/trunk/cgi-bin/latex2svg.py?view=markup
http://en.wikipedia.org/wiki/Texvc
- The program texvc (TeX validator and converter) validates (AMS) LaTeX mathematical expressions and converts them to HTML, MathML, or PNG graphics.
http://stackoverflow.com/questions/9588261/converting-a-latex-code-to-mathml-or-svg-code-in-python
from subprocess import call
import sys, re
if not len(sys.argv) == 2:
print "usage: tex2svg input_file.tex"
exit(1)
tex_name = sys.argv[1]
svg_name = tex_name[:-4] + ".svg"
ps_name = tex_name[:-4] + ".ps"
dvi_name = tex_name[:-4] + ".dvi"
if call(["latex", tex_name]): exit(1)
if call(["dvips", "-q", "-f", "-e", "0", "-E", "-D", "10000", "-x", "1000", "-o", ps_name, dvi_name]): exit(1)
if call(["pstoedit", "-f", "plot-svg", "-dt", "-ssp", ps_name, svg_name]): exit(1)