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\input mtxcontextcommon.tex
33
34\doifdocumentargument {compact} {
35 \setdocumentargument{topspace} {5mm}
36 \setdocumentargument{backspace}{5mm}
37 \setdocumentargument{bodyfont} {8pt}
38}
39
40\doifdocumentargument {verycompact} {
41 \setdocumentargument{topspace} {5mm}
42 \setdocumentargument{backspace}{5mm}
43 \setdocumentargument{bodyfont} {7pt}
44}
45
46\setupbodyfont
47 [dejavu,9pt,tt,\getdocumentargument{bodyfont}]
48
49\setuptyping
50 [lines=yes]
51
52\setuplayout
53 [header=0cm,
54 footer=1.5cm,
55 topspace=\getdocumentargumentdefault{topspace}{1.5cm},
56 backspace=\getdocumentargumentdefault{backspace}{1.5cm},
57 width=middle,
58 height=middle]
59
60\setuppapersize
61 [\getdocumentargument{paperformatpaper}]
62 [\getdocumentargument{paperformatprint}]
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77\starttext
78
79\startluacode
80 local types = {
81 mkiv = "tex",
82 mkii = "tex",
83 cld = "lua",
84 lfg = "lua",
85 mpiv = "mp",
86 mpii = "mp",
87 }
88
89 local pattern = document.arguments.pattern
90 local scite = document.arguments.scite
91
92 if pattern then
93 document.files = dir.glob(pattern)
94 end
95
96 if scite then
97 context.usemodule { "scite" }
98 end
99
100 local done = false
101 local files = document.files
102
103 if #files > 0 then
104 if document.arguments.sort then
105 table.sort(files)
106 end
107 for i=1,#files do
108 local filename = files[i]
109 if not string.find(filename,"^mtx%-context%-") then
110 local pretty = document.arguments.pretty
111 if pretty == true then
112 pretty = file.extname(filename) or ""
113 elseif pretty == false then
114 pretty = ""
115 else
116
117 end
118 context.page()
119 context.setupfootertexts(
120 { function() context.detokenize(pattern and filename or file.basename(filename)) return true end },
121 { function() context.pagenumber() return true end }
122 )
123 if scite then
124 context.scitefile { filename }
125 elseif pretty then
126 if type(pretty) ~= "string" or pretty == "" then
127 context.setuptyping { option = "color" }
128 else
129 context.setuptyping { option = types[pretty] or pretty }
130 end
131 context.typefile(filename)
132 else
133 context.typefile(filename)
134 end
135 done = true
136 end
137 end
138 end
139
140 if not done then
141 context("no files given")
142 end
143
144\stopluacode
145
146\stoptext
147 |