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\setupbodyfont
35 [dejavu,11pt,tt,\getdocumentargument{bodyfont}]
36
37\setuptyping
38 [lines=yes]
39
40\setuplayout
41 [header=0cm,
42 footer=1.5cm,
43 topspace=\getdocumentargumentdefault{topspace}{1.5cm},
44 backspace=\getdocumentargumentdefault{backspace}{1.5cm},
45 width=middle,
46 height=middle]
47
48\setuppapersize
49 [\getdocumentargument{paperformatpaper}]
50 [\getdocumentargument{paperformatprint}]
51
52\usemodule[xmlanalyzers]
53
54\starttext
55
56\startluacode
57 local files = document.files
58 local pattern = document.arguments.pattern or (#files == 1 and files[1])
59 local analyze = document.arguments.analyze
60 local template = document.arguments.template
61
62 if pattern then
63 files = dir.glob(pattern)
64 context.setupfootertexts( { pattern }, { "pagenumber" })
65 else
66 context.setupfootertexts( { table.concat(files," ") }, { "pagenumber" })
67 end
68
69 if #files > 0 then
70 if analyze then
71 moduledata.xml.analyzers.structure(files)
72 context.page()
73 moduledata.xml.analyzers.characters(files)
74 context.page()
75 moduledata.xml.analyzers.entities(files)
76 if template then
77 moduledata.xml.analyzers.allsetups(files,type(template) == "string" and template or nil)
78 end
79 context.page()
80 for i=1,#files do
81 context.type(files[i])
82 context.par()
83 end
84 else
85 context("no action given")
86 end
87 else
88 context("no files given")
89 end
90\stopluacode
91
92\stoptext
93 |