Debian Codegraph @

texmf-dist/tex/latex/tex-ini-files/lualatexquotejobname.lua

raw
1 -- tex-ini-files 2026-03-25: lualatexquotejobname.tex
2
3 -- Manuel Pegourie-Gonnard, originally written 2010. WTFPL v2.
4 --
5 -- Goal: see lualatexquotejobname.tex
6 --
7 -- Cache the results of previous calls, not so much for the speed gain which
8 -- probably doesn't matter, but to avoid repeated error messages.
9 local jobname_cache = {}
10 callback.register('process_jobname', function(jobname)
11 -- use a cached version if available
12 local cached = jobname_cache[jobname]
13 if cached ~= nil then return cached end
14 -- remove the quotes in jobname
15 local clean, n_quotes = jobname:gsub([["]], [[]])
16 -- complain if they wasn't an even number of quotes (aka unbalanced)
17 if n_quotes % 2 ~= 0 then
18 texio.write_nl('! Unbalanced quotes in jobname: ' .. jobname )
19 end
20 -- add quotes around the cleaned up jobname if necessary
21 if jobname:find(' ') then
22 clean = '"' .. clean .. '"'
23 end
24 -- remember the result before returning
25 jobname_cache[jobname] = clean
26 return clean
27 end)