summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/latexconfig/lualatexquotejobname.tex
blob: 79b8b4bdba9070f5055961ed918f3d0d30ea1042 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
% $Id$
% Manuel Pegourie-Gonnard, originally written 2010. WTFPL v2.
%
% Quote \jobname if it contains spaces, similarly to what pdfTeX does.
%
% Recent versions of luatex kindly provide a process_jobname callback for
% this. Detect if it is available and use a fallback in pure TeX otherwise.
% If using the callback, register it at \everyjob time since callbacks are not
% dumped in formats currently.
%
% The TeX version fails with "luatex '\input foo'" invocations, but it can
% either support that or spaces in filenames, not both. This one is kept for
% historical reasons.
%
% This file is inputed after latex.ltx.
%
\everyjob\expandafter{\the\everyjob
  \ifcase\directlua{
    tex.sprint(callback.list().process_jobname == nil and 0 or 1)}\relax
  % no callback, do what we can in TeX
  \begingroup
  \def\testsp#1 #2\relax{%
    \ifx\relax#2\relax
      \let\fixjobname\empty
    \else
      \edef\fixjobname{\def\noexpand\jobname{"\jobname"}}%
    \fi}%
  \edef\dotest{\noexpand\testsp\jobname\space\relax}\dotest
  \expandafter\endgroup\fixjobname
  \or % callback available, use it
  % put the function in a separate file for convenience (uses %, ~, etc)
  \directlua{dofile(assert(kpse.find_file("lualatexquotejobname.lua")))}
  \fi}
\endinput