# Faster Metapost SVG Output with TeX?

I am generating some diagrams with METAPOST. I need the output in SVG format. My labels are generated by calls to LaTeX via Tex.mp and its TEX METAPOST definition (also called a macro).

My complaint: it is pretty slow to constantly write stuff to a file and fire off an instance of latex.

Is there a faster way to achieve the same result? (As I recall, I can use METAPOST inside a TeX document with the package luamplib, which is fast, but it generates PDF, not SVG.)

Minimal example:

prologues:=3;
input TEX;

outputformat := "svg";
outputtemplate:="%j.%{outputformat}";

string texpre;
% texpre = "%&latex" & char(10) &
texpre =
"\documentclass{article}" & char(10) &
"\begin{document}  " & char(10);

TEXPRE(texpre);
TEXPOST("\end{document}");

beginfig(1)
draw fullcircle scaled 1in;
string l;
l = "Foo";
dotlabel.bot(TEX("Label is " & l), origin);
endfig;
end

-
Could you make a small example where you use TEX.mp? – egreg Sep 23 '13 at 15:15
@egreg, better? – Colin Fraizer Sep 23 '13 at 15:30
Well, the output I get is completely mangled. – egreg Sep 23 '13 at 15:40
@egreg, I am using MetaPost 1.802 (TeX Live 2013/W32TeX) with command line: mpost --numbersystem=double --file-line-error --halt-on-error --tex=latex. – Colin Fraizer Sep 23 '13 at 15:44
I too, but the output gets mangled, at least when opened with Firefox or Safari. Oh, and the same if I use PS output and convert to PDF – egreg Sep 23 '13 at 15:51