[Dev-luatex] Importing .tex files using \directlua to navigate files and folders

Taco Hoekwater taco at bittext.nl
Fri Aug 12 09:30:56 CEST 2022



> On 11 Aug 2022, at 14:08, paolo de luca <teugon at gmail.com> wrote:
> 
> Hi all,
> 
> I've been trying to import all tex files and inside a given folder, the issue I'm facing is that my lua call is not able to navigate folders: it only works for files.
> It's worth mentioning that compilation successfully completes as the document is created, but I have no errors explaining me why it's not working as intended.
> I've also opened a question on tex.stackexchange.
> 
> would you mind having a look at it ?
> 
> https://tex.stackexchange.com/questions/653499/understanding-implicit-error-on-a-recursive-function


See comment on SX. Don't 'return' the nested call, and it works just fine.

function inputAll(dir)
    for content in lfs.dir(dir) do
        if ("." ~= content) and (".." ~= content)  then
            fullpath = dir .."/".. content
                contentType = lfs.attributes(fullpath, "mode")
            if isTexFile(content, contentType) then
                    tex.sprint("
\\
input{" .. fullpath .. "}")
            elseif ("directory" == contentType) then
                -- return
                inputAll(fullpath)
            end
        end
    end
end

Best wishes,
Taco

— 
Taco Hoekwater              E: taco at bittext.nl
genderfluid (all pronouns)





More information about the dev-luatex mailing list