# [luatex] luamplib and Paragraph ended before \mplibdoreplacenewlinebr was complete.

David Carlisle d.p.carlisle at gmail.com
Sat Nov 19 23:30:13 CET 2016

mplibcode needs to read the body of the environment with special
catcodes in force, if you tex.sprint
the body of the environment then by default the catcodes will be wrong.

You could work out exactly what catcodes are needed, set up a lua
catcode table and pass the number of that catcode table as the first
optional argument to tex.sprint, but it is easier to let the tex side
handle that and just concatenate the strings and pass them back as a
single tex.sprint call,

function testMP3()
tex.sprint("\\begin{mplibcode}beginfig(0);"
..
"draw(0,0)--(2cm,2cm);endfig;\\end{mplibcode}")
end

David