workflows-injectors.tex /size: 3356 b    last modification: 2021-10-28 13:50
1% language=us runpath=texruns:manuals/workflows
2
3\environment workflows-style
4
5\startcomponent workflows-injectors
6
7\startchapter[title={Injectors}]
8
9When you have no control over the source but need to manually tweak some aspects
10of the typesetting, like an occasional page break of column switch, you can use
11the injector mechanism. This mechanism is part of list and register building but
12can also be used elsewhere.
13
14\startbuffer[one]
15\startmixedcolumns[balance=yes]
16  \dotestinjector{test}line 1 \par
17  \dotestinjector{test}line 2 \par
18  \dotestinjector{test}line 3 \par
19  \dotestinjector{test}line 4 \par
20  \dotestinjector{test}line 5
21\stopmixedcolumns
22\stopbuffer
23
24\startbuffer[two]
25\startmixedcolumns[balance=yes]
26  \dotestinjector{test}line 1 \par
27  \dotestinjector{test}line 2 \par
28  \dotestinjector{test}line 3 \par
29  \dotestinjector{test}line 4 \par
30  \dotestinjector{test}line 5
31\stopmixedcolumns
32\stopbuffer
33
34We have two buffers:
35
36\typebuffer[one]
37
38and
39
40\typebuffer[two]
41
42When typeset these come out as:
43
44\blank \startpacked \bf \getbuffer[one] \stoppacked \blank
45
46and
47
48\blank \startpacked \bf \getbuffer[two] \stoppacked \blank
49
50We can enable (and show) the injectors with:
51
52\startbuffer
53\doactivateinjector{test} \showinjector
54\stopbuffer
55
56\typebuffer \getbuffer
57
58Now we get:
59
60\blank \startpacked \bf \getbuffer[one] \stoppacked \blank
61
62and
63
64\blank \startpacked \bf \getbuffer[two] \stoppacked \blank
65
66The small numbers are injector points. These will of course change when we add
67more in|-|between. Let's add actions to some of the injection points:
68
69\startbuffer
70\setinjector[test][13][{\column}]
71\setinjector[test][17][{\column}]
72\stopbuffer
73
74\typebuffer \getbuffer
75
76As expected we now get column breaks:
77
78\blank \startpacked \bf \getbuffer[one] \stoppacked \blank
79
80and
81
82\blank \startpacked \bf \getbuffer[two] \stoppacked \blank
83
84The next example is one you can run for your own. The \type {\showinjector}
85command is of course only enabled when the right injection points are to be
86identified. Normally setting injectors happens as last resort. We use it in
87automated \XML\ workflows where last minute control is needed.
88
89\starttyping
90\showinjector
91
92\setinjector[register][3][\column]
93\setinjector[list]    [2][{\blank[3*big]}]
94
95\starttext
96    \placelist[section][criterium=text]
97    \blank[3*big]
98    \placeregister[index][criterium=text]
99    \page
100    \startsection[title=Alpha] first  \index{first}  \stopsection
101    \startsection[title=Beta]  second \index{second} \stopsection
102    \startsection[title=Gamma] third  \index{third}  \stopsection
103    \startsection[title=Delta] fourth \index{fourth} \stopsection
104\stoptext
105\stoptyping
106
107\stopchapter
108
109\stopcomponent
110
111% Some day to be described (check Willis tests):
112%
113% \showinjector
114%
115% \xmlmapvalue{xml:injector}{column}{\setinjector[\AskedInjectorGroup][\AskedInjectorNumber][\column]}
116% \xmlmapvalue{xml:injector}{page}  {\setinjector[\AskedInjectorGroup][\AskedInjectorNumber][\page]}
117%
118% \startxmlsetups xml:injector
119%     \edef\AskedInjectorGroup {\xmlatt{#1}{group}}
120%     \edef\AskedInjectorNumber{\xmlatt{#1}{number}}
121%     \xmlvalue{xml:injector}{\xmlatt{#1}{type}}{}
122% \stopxmlsetups
123%
124% \xmlfilter {#1} {/metadata/injectors/injector/command(xml:injector)}
125%
126% \xmlsetinjectors[\xmlattribute{#1}{/metadata/state}{version}]
127%
128% <?context-directive injector list 123 page ?>
129
130