summaryrefslogtreecommitdiff
path: root/doc/context/sources/general/manuals/workflows/workflows-injectors.tex
blob: 5bd9bf057a1e72201e8646df8b0161738341e593 (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
% language=uk

\environment workflows-style

\startcomponent workflows-injectors

\startchapter[title={Injectors}]

When you have no control over the source but need to manually tweak some aspects
of the typesetting, like an occasional page break of column switch, you can use
the injector mechanism. This mechanism is part of list and register building but
can also be used elsewhere.

\startbuffer[one]
\startmixedcolumns[balance=yes]
  \dotestinjector{test}line 1 \par
  \dotestinjector{test}line 2 \par
  \dotestinjector{test}line 3 \par
  \dotestinjector{test}line 4 \par
  \dotestinjector{test}line 5
\stopmixedcolumns
\stopbuffer

\startbuffer[two]
\startmixedcolumns[balance=yes]
  \dotestinjector{test}line 1 \par
  \dotestinjector{test}line 2 \par
  \dotestinjector{test}line 3 \par
  \dotestinjector{test}line 4 \par
  \dotestinjector{test}line 5
\stopmixedcolumns
\stopbuffer

We have two buffers:

\typebuffer[one]

and

\typebuffer[two]

When typeset these come out as:

\blank \startpacked \bf \getbuffer[one] \stoppacked \blank

and

\blank \startpacked \bf \getbuffer[two] \stoppacked \blank

We can enable (and show) the injectors with:

\startbuffer
\doactivateinjector{test} \showinjector
\stopbuffer

\typebuffer \getbuffer

Now we get:

\blank \startpacked \bf \getbuffer[one] \stoppacked \blank

and

\blank \startpacked \bf \getbuffer[two] \stoppacked \blank

The small numbers are injector points. These will of course change when we add
more in|-|between. Let's add actions to some of the injection points:

\startbuffer
\setinjector[test][13][{\column}]
\setinjector[test][17][{\column}]
\stopbuffer

\typebuffer \getbuffer

As expected we now get column breaks:

\blank \startpacked \bf \getbuffer[one] \stoppacked \blank

and

\blank \startpacked \bf \getbuffer[two] \stoppacked \blank

The next example is one you can run for your own. The \type {\showinjector}
command is of course only enabled when the right injection points are to be
identified. Normally setting injectors happens as last resort. We use it in
automated \XML\ workflows where last minute control is needed.

\starttyping
\showinjector

\setinjector[register][3][\column]
\setinjector[list]    [2][{\blank[3*big]}]

\starttext
    \placelist[section][criterium=text]
    \blank[3*big]
    \placeregister[index][criterium=text]
    \page
    \startsection[title=Alpha] first  \index{first}  \stopsection
    \startsection[title=Beta]  second \index{second} \stopsection
    \startsection[title=Gamma] third  \index{third}  \stopsection
    \startsection[title=Delta] fourth \index{fourth} \stopsection
\stoptext
\stoptyping

\stopchapter

\stopcomponent

% some day to be described:
%
% \showinjector
%
% \xmlmapvalue{xml:injector}{column}{\setinjector[\AskedInjectorGroup][\AskedInjectorNumber][\column]}
% \xmlmapvalue{xml:injector}{page}  {\setinjector[\AskedInjectorGroup][\AskedInjectorNumber][\page]}
%
% \startxmlsetups xml:injector
%     \edef\AskedInjectorGroup {\xmlatt{#1}{group}}
%     \edef\AskedInjectorNumber{\xmlatt{#1}{number}}
%     \xmlvalue{xml:injector}{\xmlatt{#1}{type}}{}
% \stopxmlsetups
%
% \xmlfilter {#1} {/metadata/injectors/injector/command(xml:injector)}
%
% \xmlsetinjectors[\xmlattribute{#1}{/metadata/state}{version}]
%
% <?context-directive injector list 123 page ?>