[Dev-luatex] \input does not look at open_read_file callback?

Hans Hagen pragma at wxs.nl
Tue Apr 24 13:27:06 CEST 2007


David Kastrup wrote:
> Hi,
>
> in the following code, the callback is never reached when called with
> luatex -ini bug
>
>   
> ------------------------------------------------------------------------
>
> \catcode`{=1 \catcode`}=2
> \directlua0{callback.register("open_read_file",function(filename)
>   print "opening file name";return end)}
> \input plain.tex
>   
hm, works ok here

opening file name
! I can't find file `plain.tex'.
l.13 \input plain.tex

you return nothing, while you need to return a table with at least a 
reader function that luatex can call for each line it wants

    callback.register('open_read_file', function(filename)
        print("opening file name " .. filename)
        local f = io.open(filename)
        if f then
            return { reader = function() return f:read() end, close = 
function() f:close() end }
        else
            return nil
        end
    end)

readers can read from file and do with the input what they want before 
they pass it onto tex

(btw, the return format is mentioned in the manual)

Hans


-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------



More information about the dev-luatex mailing list