x-ldx.mkiv /size: 4241 b    last modification: 2020-07-01 14:35
1%D \module
2%D   [       file=x-ldx,
3%D        version=2008.06.03,
4%D          title=\CONTEXT\ Modules,
5%D       subtitle=Lua Source Pretty Printing,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14% this will become an extra
15
16\setupxml[default=hidden]
17
18\usemodule[x][mathml]
19\usemodule[abr-02]
20
21\xmlregistersetup{xml:mml:define}
22\xmlregistersetup{xml:ldx:define}
23
24\xmlregisterns{ldx}{ldx}
25
26\startxmlsetups xml:ldx:define
27    \xmlsetsetup {#1} {ldx:*} {ldx:*}
28\stopxmlsetups
29
30% % %
31
32\startxmlsetups ldx:p
33    \xmlflush{#1}\par
34\stopxmlsetups
35
36\startxmlsetups ldx:source
37    \source{\xmlflush{#1}}
38\stopxmlsetups
39
40\startxmlsetups ldx:key
41    \dontleavehmode{\bf\xmlflush{#1}}
42\stopxmlsetups
43
44\startxmlsetups ldx:variable
45    \xmlflush{#1}
46%     \expanded{\variable{\xmlflush{#1}}}
47\stopxmlsetups
48
49\startxmlsetups ldx:function
50    \dontleavehmode{\bf function}\space\xmlflush{#1}
51%     \expanded{\function{\xmlflush{#1}}}
52\stopxmlsetups
53
54\startxmlsetups ldx:com
55    \dontleavehmode{\tt--\xmlflush{#1}}
56\stopxmlsetups
57
58\startxmlsetups ldx:document
59    \page
60    \xmlflush{#1}
61    \determineregistercharacteristics[function]
62    \startmode[*register]
63        \testpage[4]
64        \extra{Functions}
65        \placeregister[function]
66    \stopmode
67    \determineregistercharacteristics[variable]
68    \startmode[*register]
69        \testpage[4]
70        \extra{Variables}
71        \placeregister[variable]
72    \stopmode
73\stopxmlsetups
74
75\newcounter\CommentCounter
76
77\startxmlsetups ldx:comment
78    \blank
79    \doglobal\increment\CommentCounter
80    \margintitle{\bf\CommentCounter}
81    \xmlflush{#1}
82    \blank
83\stopxmlsetups
84
85\startxmlsetups ldx:dqs
86    \dontleavehmode\bgroup\tt"\xmlflush{#1}"\egroup
87\stopxmlsetups
88
89\startxmlsetups ldx:sqs
90    \dontleavehmode\bgroup\tt'\xmlflush{#1}'\egroup
91\stopxmlsetups
92
93\startxmlsetups ldx:code
94    \startpacked
95    \xmlflush{#1}\relax
96    \stoppacked
97\stopxmlsetups
98
99\startluacode
100    function xml.finalizers.tex.cdatatobuffer(c,name)
101        buffers.assign(name,xml.cdata(c[1]))
102    end
103\stopluacode
104
105\startxmlsetups ldx:luacode
106    \blank
107    \begingroup
108    \switchtobodyfont[dejavu-condensed]
109    \xmlfilter{#1}{./cdatatobuffer('name')}
110    \scitebuffer[lua][name]
111    \endgroup
112    \blank
113\stopxmlsetups
114
115\startxmlsetups ldx:lines
116    \startpacked
117    \xmlflush{#1}
118    \stoppacked
119\stopxmlsetups
120
121\startxmlsetups ldx:line
122    \doifelsenothing {\xmlflush{#1}} {
123        \xmlflush{#1}\crlf
124    } {
125        \dontleavehmode \hbox to \hsize \bgroup
126            \strut
127            \hskip.25\dimexpr\xmlattdef{#1}{n}{0}em\relax\relax % extra relax needed !
128            \doif {\xmlatt{#1}{comment}} {yes} {\tt}
129            \xmlflush{#1}
130            \hss
131       \egroup
132       \endgraf
133    }
134\stopxmlsetups
135
136\startxmlsetups ldx:logo
137    \uppercasestring\xmlatt{#1}{label}\xmlatt{#1}{name}\to\ascii
138    \ifx\ascii\empty\else\getvalue{\ascii}\fi
139\stopxmlsetups
140
141\startxmlsetups ldx:l
142    \uppercasestring\xmlatt{#1}{l}\xmlatt{#1}{n}\to\ascii
143    \ifx\ascii\empty\else\getvalue{\ascii}\fi
144\stopxmlsetups
145
146\startxmlsetups ldx:typing
147    \blank
148    \startpacked \tt
149    \xmlverbatim{#1}
150    \stoppacked
151    \blank
152\stopxmlsetups
153
154\startxmlsetups ldx:type
155    \dontleavehmode{\tt\xmlflush{#1}}
156\stopxmlsetups
157
158\startxmlsetups ldx:t
159    \dontleavehmode{\tt\xmlflush{#1}}
160\stopxmlsetups
161
162% key     -> kw
163% dqs     -> dq
164% sqs     -> sq
165% line    -> ln
166% code    -> cd
167% comment -> tx (text)
168
169\usemodule[scite]
170
171\switchtobodyfont
172  [dejavu-condensed,10pt] % preload
173
174\setupbodyfont
175  [dejavu,10pt] % main font
176
177\mainlanguage
178  [en]
179
180\setupwhitespace
181  [big]
182
183\defineregister[function]
184\defineregister[variable]
185
186\definehead[source][subject]
187\definehead[extra] [subsubject]
188\definehead[topic] [subsubsubject]
189
190\setuphead
191  [source]
192  [style=\bfb]
193
194\setuphead
195  [extra]
196  [style=\bfa]
197
198\setuphead
199  [topic]
200  [style=\bf]
201
202\setuplayout
203  [width=middle,
204   height=middle,
205   footer=0pt,
206   header=1.5cm,
207   backspace=1.5cm,
208   topspace=1.5cm]
209
210\doifmode {nocolor} {
211
212  \setupcolors
213    [conversion=always]
214
215}
216\endinput
217