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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
% engine=luatex
%D \module
%D [ file=mtx-context-listing,
%D version=2008.11.10, % about that time i started playing with this
%D title=\CONTEXT\ Extra Trickry,
%D subtitle=Listing Files,
%D author=Hans Hagen,
%D date=\currentdate,
%D copyright=\PRAGMA]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
%D This is a \TEXEXEC\ features that has been moved to \MKIV.
% begin help
%
% usage: context --extra=listing [options] list-of-files
%
% --sort : sort filenames first
% --topspace=dimension : distance above first line
% --backspace=dimension : distance before left margin
% --pretty : pretty print comform suffix (temporarily disabled)
%
% end help
\setupbodyfont
[11pt,tt]
\setuplayout
[header=0cm,
footer=1.5cm,
width=middle,
height=middle]
% todo: use \arguments{topspace}
\startluacode
local topspace = document.arguments["topspace"] or 0
if dimen(topspace) > dimen(0) then
tex.sprint(string.format("\\setuplayout[topspace=%s]",dimen(topspace)))
end
local backspace = document.arguments["backspace"] or 0
if dimen(topspace) > dimen(0) then
tex.sprint(string.format("\\setuplayout[backspace=%s]",dimen(backspace)))
end
\stopluacode
\setuptyping
[lines=yes]
\setuptyping
[option=color]
\starttext
\startluacode
if #document.files > 0 then
if document.arguments["sort"] then
table.sort(document.files)
end
for _, filename in ipairs(document.files) do
if not string.find(filename,"^mtx%-context%-") then
tex.sprint("\\page\n")
tex.sprint(string.format("\\setupfootertexts[\\detokenize{%s}][\\pagenumber]\n",file.basename(filename)))
tex.sprint(string.format("\\typefile{%s}",filename))
end
end
else
tex.sprint(tex.ctxcatcodes,"no files given")
end
\stopluacode
\stoptext
|