1\enableexperiments[fonts.compact]
2\enableexperiments[fonts.accurate]
3
4\startenvironment luametatexstyle
5
6\usemodule[systemsyntax]
7\usemodule[systemunits]
8\usemodule[abbreviationslogos]
9\usemodule[scite]
10
11\definemeasure [document:margin] [\paperheight20]
12
13\setuplayout
14 [topspace=\measure{document:margin},
15 bottomspace=\measure{document:margin},
16 backspace=\measure{document:margin},
17 header=\measure{document:margin},
18 footer=0pt,
19 width=middle,
20 height=middle]
21
22\setupbodyfont
23 [dejavu,10pt]
24
25\setupwhitespace
26 [big]
27
28\setuplist
29 [interaction=all]
30
31\setupalign
32 [tolerant,stretch]
33
34\setupdocument
35 [title=No Title,
36 subtitle={in luametatex},
37 author=No Author,
38 coauthor=,
39 color=NoColor]
40
41\definecolor[maincolor][darkblue]
42\definecolor[primcolor][darkblue]
43\definecolor[nonecolor][darkgray]
44
45\startMPdefinitions
46 vardef MyText (expr txt) =
47 image (
48 picture p ; p := lmt_outline [
49 text = txt,
50 kind = "path",
51 anchor = "lft",
52 ] ;
53 for i within p :
54 draw pathpart i
55 withpen pencircle scaled 25
56 withcolor "white" ;
57 draw pathpart i
58 withpen pencircle scaled 13
59 withcolor "darkgray" ;
60 drawcontrollines pathpart i
61 withpen pencircle scaled 13
62 withcolor "middlegray" ;
63 drawcontrolpoints pathpart i
64 withpen pencircle scaled 13
65 withcolor "white" ;
66 drawpoints pathpart i
67 withpen pencircle scaled 13
68 withcolor "darkyellow" ;
69 endfor ;
70 )
71 enddef ;
72\stopMPdefinitions
73
74\startsetups document:contents
75
76 \page
77
78 \determinelistcharacteristics[chapter,section] [criterium=previous]
79
80 \ifcase\listlength\else
81 \startsubjectlevel[title=Contents]
82 \placelist[chapter,section] [criterium=previous]
83 \stopsubjectlevel
84 \fi
85
86\stopsetups
87
88\startrawsetups document:start
89
90
91
92 \doifelse {\documentvariable{alternative}} {manual} {
93
94
95 \setuppagenumbering
96 [alternative=doublesided]
97
98 \doifelse {\documentvariable{title}} {luametatex} {
99
100 \startMPpage
101 StartPage;
102 picture p[] ;
103 p[1] := image (
104
105 draw MyText("luametatex") xsized (0.8PaperWidth) ;
106 ) ;
107 draw p[1] shifted (.1PaperWidth,.8PaperHeight) ;
108 p[2] := image (
109 draw MyText("the manual") ysized 15mm ;
110 ) ;
111 draw p[2] shifted urcorner Page shifted (bbwidth p[2] .1PaperWidth, bbheight(p[1]) bbheight(p[2]) .2PaperHeight);
112 p[3] := image (
113 draw MyText("version \luametatexverboseversion") ysized 10mm ;
114 ) ;
115
116 draw p[3] shifted lrcorner Page shifted (bbwidth p[3] .1PaperWidth, 25mm);
117 p[4] := image (
118 draw MyText("dev id \luametatexfunctionality") ysized 5mm ;
119 ) ;
120
121 draw p[4] shifted lrcorner Page shifted (bbwidth p[4] .1PaperWidth, 15mm);
122 addbackground withcolor "darkblue" ;
123 StopPage;
124 \stopMPpage
125
126 \page[right]
127
128 \setups[document:contents]
129
130 } {
131
132 \startMPpage
133 StartPage;
134 picture p[] ;
135 p[3] := image (
136 draw MyText("\word{\documentvariable{title}}") scaled 6 ;
137 ) ;
138 draw p[3] shifted lrcorner Page shifted (bbwidth p[3] .1PaperWidth, 15mm);
139 addbackground withcolor "darkblue" ;
140 StopPage;
141 \stopMPpage
142
143 \page[right]
144
145 \normalexpanded{\startchapter[title={\documentvariable{title}}]}
146 }
147
148 } {
149
150 \startMPpage
151 fill Page
152 withcolor "darkgray" ;
153
154 draw textext("\sstf\enspace\doifelsedocumentvariable{xtitle}{\documentvariable{xtitle}}{\word{\documentvariable{title}}}")
155 xysized (.9bbwidth(Page),bbheight(Page)-2cm)
156 xsized (.9bbwidth(Page))
157 shifted center Page
158 withcolor "maincolor" ;
159 draw textext.ulft("\word{\sstf \documentvariable{subtitle}}")
160 xysized (.9bbwidth(Page)3,(bbheight(Page)-2cm)6)
161 shifted center lrcorner Page
162 shifted (-.1bbwidth(Page),.05bbwidth(Page))
163 withcolor "white" ;
164 setbounds currentpicture to Page ;
165 \stopMPpage
166
167 \page[right]
168
169 \setups[document:contents]
170
171 }
172
173 \setupdocument
174 [title=No Title,
175 subtitle={in luametatex}]
176
177\stoprawsetups
178
179\startrawsetups document:stop
180
181 \doif {\documentvariable{alternative}} {manual} {
182
183 \doifnot {\documentvariable{title}} {luametatex} {
184
185 \stopchapter
186
187 }
188
189 }
190
191\stoprawsetups
192
193\definehead
194 [newprimitive]
195 [subsubsubsection]
196
197\definehead
198 [oldprimitive]
199 [subsubsubsection]
200
201\setuphead
202 [chapter,title]
203 [style=\bfc,
204 color=maincolor,
205 headerstate=high,
206 interaction=all]
207
208\setuphead
209 [section]
210 [style=\bfb,
211 color=maincolor]
212
213\setuphead
214 [subsection]
215 [style=\bfa,
216 color=maincolor]
217
218\setuphead
219 [subsubsection]
220 [style=\bf,
221 color=maincolor,
222 after=]
223
224\setuphead
225 [Syntax]
226 [numberwidth=fit,
227 style=\tta\bf]
228
229\pushoverloadmode
230
231 \definehead
232 [Syntax]
233 [subsection]
234 [style=\ttbfb,
235 numberwidth=0pt,
236 after=\blank\startpacked,
237 aftersection=\stoppacked]
238
239\popoverloadmode
240
241\setupexternalfigures
242 [location={default,global}]
243
244\setupinteraction
245 [state=start,
246 color=,
247 contrastcolor=,
248 style=,
249 contraststyle=]
250
251
252
253
254
255
256
257
258
259
260
261\setuptabulate
262 [
263 headstyle=normal,
264 headcolor=maincolor,
265 rulecolor=maincolor,
266 rulethickness=1pt]
267
268
269
270\setuptyping
271 [option=tex]
272
273\setuptype
274 [option=tex]
275
276\setuphead
277 [newprimitive]
278 [color=maincolor]
279
280\setuphead
281 [oldprimitive]
282 [
283 color=\ifcstok{\structureuservariable{obsolete}}{yes}darkred\else nonecolor\fi]
284
285\setuplist
286 [newprimitive]
287 [textcolor=maincolor]
288
289\setuplist
290 [oldprimitive]
291 [textcolor=nonecolor]
292
293\setuplist
294 [chapter]
295 [color=maincolor,
296 style=bold,
297 before={\testpage[3]\blank}]
298
299
300
301
302\protected\def\prm#1
303
304
305 {
306 \ifmode{*bodypart}\index{\tex{#1}}\fi\tex{#1}}
307
308\protected\def\stx#1
309 {\ctxlua{moduledata.engine.specification("#1")}}
310
311
312
313
314
315\definehead
316 [enginesubject]
317 [subsubsubject]
318 [before=\testpage[4]\blank,
319 after=\blank,
320 style=bold]
321
322\startluacode
323
324
325
326
327
328
329 local getusage = node.direct.getusage
330 local hasusage = node.direct.hasusage
331 local nodecodes = nodes.nodecodes
332 function moduledata.showrepertoire(name, target)
333 local t = getusage(name, target)
334 if t == true then
335 context("all nodes")
336 elseif t and #t > 0 then
337 for i=1,#t do
338 t[i] = nodecodes[t[i]]
339 end
340 context("% t",t)
341 else
342 context("(yet) unknown")
343 end
344 end
345 function moduledata.showusagepernode(name, target)
346 local t = getusage(nodecodes[name], target)
347 if t and #t > 0 then
348 table.sort(t)
349 context("% t",t)
350 else
351 context("nothing (yet)")
352 end
353 end
354
355 local report = logs.reporter("manual","todo")
356
357 for name, value in table.sortedhash(node.direct, target) do
358 if type(value) == "function" and not hasusage(name, target) then
359 report("helper %s",name)
360 end
361 end
362
363 local ignore = { id = true }
364
365 function moduledata.showfieldsupport(name,what)
366 local id = tonumber(name) or nodes.nodecodes[name]
367 if id then
368 node.setfielderror(1)
369 local fields = node.fields(id)
370 local n = node.new(id )
371 local t = { }
372 for k, v in table.sortedhash(fields) do
373 if not ignore[v] then
374 node[what](n,v)
375 if node.getfielderror() ~= 0 then
376 t[#t+1] = v
377 end
378 end
379 end
380 node.free(n)
381 if next(t) then
382 report("")
383 report("%s %s : % t",name,what,t)
384 report("")
385 context("% t",t)
386 else
387 context("-")
388 end
389 node.setfielderror(0)
390 end
391 end
392\stopluacode
393
394\tolerant\protected\def\showenginerepertoire[#1]#*#:#2
395 {\startenginesubject[title={targets}]
396 \ctxlua{moduledata.showrepertoire("#2")}
397 \stopenginesubject}
398
399\tolerant\protected\def\showenginesetget[#1]#*#:#2
400 {\startenginesubject[title={#2}]
401 no get: \start \tttf \veryraggedright \ctxlua{moduledata.showfieldsupport("#2","getfield")} \stop \par
402 no set: \start \tttf \veryraggedright \ctxlua{moduledata.showfieldsupport("#2","setfield")} \stop \par
403 \stopenginesubject}
404
405\enablemode[checkfield]
406
407\tolerant\protected\def\showengineusagepernode[#1]#*#:#2
408 {\startenginesubject[title={direct helpers}]
409 \start \tttf \veryraggedright
410 \ctxlua{moduledata.showusagepernode("#2", 1)}
411 \stop
412 \stopenginesubject
413 \startenginesubject[title={userdata helpers}]
414 \start \tttf \veryraggedright
415 \ctxlua{moduledata.showusagepernode("#2", 2)}
416 \stop
417 \stopenginesubject
418 \startmode[checkfield]
419 \startenginesubject[title={userdata helpers}]
420 \startlines
421 no get: \start \tttf \veryraggedright \ctxlua{moduledata.showfieldsupport("#2","getfield")} \stop \par
422 no set: \start \tttf \veryraggedright \ctxlua{moduledata.showfieldsupport("#2","setfield")} \stop \par
423 \stoplines
424 \stopenginesubject
425 \stopmode}
426
427\tolerant\protected\def\showenginevalues[#1]#*#:#2
428 {\startenginesubject[title={#2}]
429 \startrows[n=\ifparameter#1\or#1\else2\fi,before=\blank,after=\blank]
430 \ctxlua{moduledata.engine.codes("get#2", 1)}
431 \stoprows
432 \stopenginesubject}
433
434\tolerant\protected\def\showenginefields[#1]#*#:#2
435 {\startenginesubject[title=fields]
436 \startrows[n=\ifparameter#1\or#1\else3\fi,before=\blank,after=\blank]
437 \ctxlua{moduledata.node.codes("fields","#2",true)}
438 \stoprows
439 \stopenginesubject}
440
441\tolerant\protected\def\showenginesubtypes[#1]#*#:#2
442 {\startenginesubject[title=subtypes]
443 \startrows[n=\ifparameter#1\or#1\else3\fi,before=\blank,after=\blank]
444 \ctxlua{moduledata.node.codes("subtypes","#2",true)}
445 \stoprows
446 \stopenginesubject}
447
448\tolerant\protected\def\showengineprimitives[#1]
449 {
450 \startrows[n=\ifparameter#1\or#1\else2\fi,before=\blank,after=\blank]
451 \startluacode
452 local p = token.getprimitives()
453 table.sort(p,function(a,b)
454 if a[1] == b[1] then
455 return a[2] < b[2]
456 else
457 return a[1] < b[1]
458 end
459 end)
460 local skiplist = { [106] = true }
461 local skipping = false
462 context.starttabulate { "|r|r|l|" }
463 for i=1,\letterhash p do
464 local pi = p[i]
465 local pc = pi[1]
466 if skiplist[pc] then
467 if not skipping then
468 context.NC() context(pc)
469 context.NC()
470 context.NC() context.tex("Umath...")
471 context.NC() context.NR()
472 skipping = true
473 end
474 else
475 context.NC() context(pc)
476 context.NC() context(pi[2])
477 context.NC() context.tex(pi[3])
478 context.NC() context.NR()
479 skipping = false
480 end
481 end
482 context.stoptabulate()
483 \stopluacode
484 \stoprows
485 }
486
487\tolerant\protected\def\showenginekeylist#1
488 {\startluacode
489 local t = #1
490 table.sort(t)
491 context.typ(t[1])
492 for i=2,\letterhash t do
493 context(", ")
494 context.typ(t[i])
495 end
496 \stopluacode}
497
498
499
500
501
502
503
504\definerows[two] [n=2,before=\blank,after=\blank]
505\definerows[three][n=3,before=\blank,after=\blank]
506\definerows[four] [n=4,before=\blank,after=\blank]
507
508\definerows[tworows] [define=yes,n=2,before=\blank,after=\blank]
509\definerows[threerows][define=yes,n=3,before=\blank,after=\blank]
510\definerows[fourrows] [define=yes,n=4,before=\blank,after=\blank]
511
512\setuplinenumbering
513 [margin=0em,
514 style=\ttx,
515 width=\margindistance,
516 distance=\margindistance]
517
518\stopenvironment
519 |