Hello, take the following PlainTeX file: %&luatex \pdfoutput=1 \directlua0{\unexpanded{ callback.register("process_input_buffer", function(line) callback.register("process_input_buffer", nil) tex.sprint(" world!") return line end) }} Hello \bye Using the svn trunk as of friday afternoon, this results in a PDF file containing the world "Hello". " world!" is missing for some reason. There is no warning in the log file. Does tex.sprint not work in a callback (or at least in the "process_input_buffer" callback)? Is this the same limitation as noted in the manual: tex.print() and tex.sprint() do not work if \directlua is used in an otp file (in the output of an expression rule) (Above example is actually slightly less contrived than it seems, because when using tex.sprint, it is possible to specify a catcode table, whereas the callback cannot influence the catcodes of the returned line in any way.) Jonathan
Jonathan Sauer wrote:
Using the svn trunk as of friday afternoon, this results in a PDF file containing the world "Hello". " world!" is missing for some reason. There is no warning in the log file.
In general, tex.[s]print do not work in callbacks at the moment, and that may be the wisest thing, because the state of the interpreter can be a bit unpredictable at times. An exception could be made for process_input_buffer because as you say, it is very useful there. But I cannot do that right now because the C code behind tex.print does not support nesting yet. I'll add a tracker item. Best wishes, Taco
participants (2)
-
Jonathan Sauer
-
Taco Hoekwater