summaryrefslogtreecommitdiff
path: root/doc/context/sources/general/leaflets/leaflet-mixing.tex
blob: 9f14525b3804208eeb52c77809bba010c2555066 (plain)
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
%D Please don't abuse this style for your own purpose as the look and feel
%D is reserved for our own purpose. Be creative instead.

\setupbodyfont
  [plex,7pt]

\setuppapersize
  [A3,landscape]

\setuplayout
  [width=middle,
   height=middle,
   header=0pt,
   footer=0pt,
   backspace=5mm,
   topspace=5mm]

\definelayer
  [page]
  [width=\textwidth,
   height=\textheight]

\setupbackgrounds
  [page]
  [background=color,
   backgroundcolor=middlegray]

\setuptyping
  [before=,after=]

\usemodule
  [abbreviations-logos]

\startbuffer[style]
  \setupbodyfont
    [plex]
  \setuplayout
    [width=middle,
     height=middle,
     margin=1cm]
  \setupcolors
    [textcolor=white]
  \usemodule
    [abbreviations-logos]
  \setupwhitespace
    [big]
  \setuphead
    [chapter]
    [style=\bfc]
\stopbuffer

\startbuffer[intro]

    \starttitle[title={Using \CONTEXT}]

    The \CONTEXT\ macro package is more than just a \TEX\ processor,
    various input is possible, some we show here. An example of a
    method not shown here is fetching data from a database. The
    various input methods can be combined, so depending on what you
    need you can mix \TEX\ (for typesetting text), \METAPOST\ (for
    producing graphics) or \LUA\ (as language for manipulating
    data.

    All these methods are quite efficient and always have access to
    the full power of the typesetting engine.

    When you use \CONTEXT\ with \LUAMETATEX, you get a reasonable
    small self contained component that can be used in workflows
    that need quality rendering. The ecosystem is rather future
    proof too.

    The \CONTEXT\ macro package has been around for decades and
    evolved from \MKII, to \MKIV\ and now \LMTX. The development
    team has always been involved in the development of engines
    like \PDFTEX, \LUATEX\ and \LUAMETATEX. There is an active
    mailing list and there are \CONTEXT\ meetings.

    \stoptitle

\stopbuffer

\startbuffer[tex]
\starttext

    \starttitle[title={Some \TEX}]

        Just an example.

        \starttabulate[|c|c|]
            \NC first 1 \NC last 1 \NC \NR
            \NC first 2 \NC last 2 \NC \NR
        \stoptabulate

    \stoptitle

\stoptext
\stopbuffer

\startbuffer[xml]
\startbuffer[demo]
<?xml version="1.0"?>
<document>
    <title>Some XML</title>
    <p>Just an example.</p>
    <table>
        <r> <c>first 1</c> <c>last 1</c> </r>
        <r> <c>first 2</c> <c>last 2</c> </r>
    </table>
</document>
\stopbuffer

\startxmlsetups xml:basics
    \xmlsetsetup{#1}{title|p|table}{xml:*}
\stopxmlsetups
\startxmlsetups xml:title
    \title{\xmltext{#1}{.}}
\stopxmlsetups
\startxmlsetups xml:p
    \xmlflush{#1}\par
\stopxmlsetups
\startxmlsetups xml:table
    \starttabulate[|c|c|]
        \xmlfilter{#1}{/r/command(xml:r)}
    \stoptabulate
\stopxmlsetups
\startxmlsetups xml:r
    \NC \xmlfilter{#1}{/c/command(xml:c)} \NR
\stopxmlsetups
\startxmlsetups xml:c
    \xmlflush{#1} \NC
\stopxmlsetups

\xmlregistersetup{xml:basics}

\starttext
    \xmlprocessbuffer{demo}{demo}{}
\stoptext
\stopbuffer

\startbuffer[lua]
\startluacode
    local tmp = {
        { a = "first 1", b = "last 1" },
        { b = "last 2", a = "first 2" },
    }

    -- local tmp = table.load("somefile.lua")

    context.starttext()

        context.starttitle { title = "Some Lua" }

            context("Just an example.") context.par()

            context.starttabulate { "|c|c|" }
                for i=1,#tmp do
                    local t = tmp[i]
                    context.NC()
                        context(t.a) context.NC()
                        context(t.b) context.NC()
                    context.NR()
                end
            context.stoptabulate()

        context.stoptitle()

    context.stoptext()
\stopluacode
\stopbuffer

\startbuffer[mp]
\startMPpage
    draw textext("\bf Some \MetaPost")
        xsized 4cm
        rotated(45)
        withcolor "white" ;

    draw textext("\bs\strut in \ConTeXt")
        xsized 5cm
        shifted (0,-40mm)
        withcolor "white" ;

    draw fullcircle
        scaled 6cm
        dashed evenly
        withcolor "gray" ;
\stopMPpage
\stopbuffer

\startbuffer[csv]
\startluacode
    local tmp = [[
        first,second
        first 1,last 1
        first 2,last 2
    ]]

    -- local tmp = io.loaddata("somefile.csv")

    local mycsvsplitter = utilities.parsers.rfc4180splitter()
    local list, names = mycsvsplitter(tmp,true)

    context.starttext()

        context.starttitle { title = "Some CSV" }

            context("Just an example.") context.par()

            context.starttabulate { "|c|c|" }
                for i=1,#list do
                    local l = list[i]
                    context.NC()
                        context(l[1]) context.NC()
                        context(l[2]) context.NC()
                    context.NR()
                end
            context.stoptabulate()

        context.stoptitle()

    context.stoptext()
\stopluacode
\stopbuffer

\startbuffer[json]
\startluacode
    require("util-jsn")

    -- local str = io.loaddata("somefile.json")

    local str = [[ {
        "title": "Some JSON",
        "text" : "Just an example.",
        "data" : [
            { "a" : "first 1", "b" : "last 1" },
            { "b" : "last 2", "a" : "first 2" }
        ]
    } ]]

    local tmp = utilities.json.tolua(str)

    context.starttext()

        context.starttitle { title = tmp.title }

            context(tmp.text) context.par()

            context.starttabulate { "|c|c|" }
                for i=1,#tmp.data do
                    local d = tmp.data[i]
                    context.NC()
                        context(d.a) context.NC()
                        context(d.b) context.NC()
                    context.NR()
                end
            context.stoptabulate()

        context.stoptitle()

    context.stoptext()
\stopluacode
\stopbuffer

\startbuffer[mkxi]
% normally there is already a file:

\startbuffer[demo]
\starttext
  \starttitle[title={Some template}]

  Just an example. \blank

  \startlinecorrection
    \bTABLE
      <?lua for i=1,20 do ?>
        \bTR
          <?lua for j=1,5 do ?>
            \bTD
              cell (<?lua inject(i) ?>,<?lua inject(j) ?>)
              is <?lua inject(variables.text or "unset") ?>
            \eTD
          <?lua end ?>
        \eTR
      <?lua end ?>
    \eTABLE
  \stoplinecorrection

  \stoptitle
\stoptext

\stopbuffer

\savebuffer[file=demo.mkxi,prefix=no,list=demo]

% the action:

\startluacode
    document.variables.text = "set"
\stopluacode

\input{demo.mkxi}
\stopbuffer

\definemeasure[blobwidth] [\textwidth/4-3mm]
\definemeasure[blobscale] [\textwidth/4-3mm-4mm]
\definemeasure[blobheight][\textheight/2-2mm]

\startbuffer[everything]

\setlayerframed
  [page]
  [preset=lefttop]
  [align=normal,
   offset=2mm,
   strut=no,
   frame=off,
   height=\measure{blobheight},
   width=\measure{blobwidth},
   background=color,
   backgroundcolor=darkgray,
   foregroundcolor=white]
  {\doifelsemode{verbose}{\typebuffer[intro]}{\typesetbuffer[style,intro][frame=on,width=\measure{blobscale}]}}

\setlayerframed
  [page]
  [preset=lefttop,
   hoffset=4mm,
   x=\measure{blobwidth}]
  [align=normal,
   offset=2mm,
   strut=no,
   frame=off,
   height=\measure{blobheight},
   width=\measure{blobwidth},
   background=color,
   backgroundcolor=darkred,
   foregroundcolor=white]
  {\doifelsemode{verbose}{\typebuffer[tex]}{\typesetbuffer[style,tex][frame=on,width=\measure{blobscale}]}}

\setlayerframed
  [page]
  [preset=righttop,
   hoffset=4mm,
   x=\measure{blobwidth}]
  [align=normal,
   offset=2mm,
   strut=no,
   frame=off,
   height=\measure{blobheight},
   width=\measure{blobwidth},
   background=color,
   backgroundcolor=darkblue,
   foregroundcolor=white]
  {\doifelsemode{verbose}{\typebuffer[xml]}{\typesetbuffer[style,xml][frame=on,width=\measure{blobscale}]}}

\setlayerframed
  [page]
  [preset=righttop]
  [align=normal,
   offset=2mm,
   strut=no,
   frame=off,
   height=\measure{blobheight},
   width=\measure{blobwidth},
   background=color,
   backgroundcolor=darkgreen,
   foregroundcolor=white]
  {\doifelsemode{verbose}{\typebuffer[lua]}{\typesetbuffer[style,lua][frame=on,width=\measure{blobscale}]}}

\setlayerframed
  [page]
  [preset=lefttop,
   voffset=4mm,
   y=\measure{blobheight}]
  [align=normal,
   offset=2mm,
   strut=no,
   frame=off,
   height=\measure{blobheight},
   width=\measure{blobwidth},
   background=color,
   backgroundcolor=darkcyan,
   foregroundcolor=white]
  {\doifelsemode{verbose}{\typebuffer[mp]}{\typesetbuffer[style,mp][frame=on,width=\measure{blobscale}]}}

\setlayerframed
  [page]
  [preset=lefttop,
   hoffset=4mm,
   x=\measure{blobwidth},
   voffset=4mm,
   y=\measure{blobheight}]
  [align=normal,
   offset=2mm,
   strut=no,
   frame=off,
   height=\measure{blobheight},
   width=\measure{blobwidth},
   background=color,
   backgroundcolor=darkmagenta,
   foregroundcolor=white]
  {\doifelsemode{verbose}{\typebuffer[csv]}{\typesetbuffer[style,csv][frame=on,width=\measure{blobscale}]}}

\setlayerframed
  [page]
  [preset=righttop,
   hoffset=4mm,
   x=\measure{blobwidth},
   voffset=4mm,
   y=\measure{blobheight}]
  [align=normal,
   offset=2mm,
   strut=no,
   frame=off,
   height=\measure{blobheight},
   width=\measure{blobwidth},
   background=color,
   backgroundcolor=darkyellow,
   foregroundcolor=white]
  {\doifelsemode{verbose}{\typebuffer[json]}{\typesetbuffer[style,json][frame=on,width=\measure{blobscale}]}}

\setlayerframed
  [page]
  [preset=righttop,
   voffset=4mm,
   y=\measure{blobheight}]
  [align=normal,
   offset=2mm,
   strut=no,
   frame=off,
   height=\measure{blobheight},
   width=\measure{blobwidth},
   background=color,
   backgroundcolor=darkorange,
   foregroundcolor=white]
  {\doifelsemode{verbose}{\typebuffer[mkxi]}{\typesetbuffer[style,mkxi][frame=on,width=\measure{blobscale}]}}

\startstandardmakeup
    \tightlayer[page]
\stopstandardmakeup

\stopbuffer

\starttext

{\enablemode[verbose] \getbuffer[everything]}
                      \getbuffer[everything]

\stoptext