blob: 627bd7fd8790abab4805c3616edb6ff6cce998ff (
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
|
[article Template 1.6
[quickbook 1.6]
]
[section Templates]
[/-------------------------------- nullary arg ]
[template foo0 nullary_arg]
[foo0]
[/-------------------------------- unary arg, phrase syle ]
[template foo1[bar] foo [bar]]
[foo1 baz]
[/-------------------------------- unary arg, block syle ]
[template foo2[bar]
foo [bar]
]
[foo2 baz]
[template foo3[bar]
This is a complete paragraph. [bar] [bar] [bar] [bar] [bar]
[bar] [bar] [bar] [bar].... blah blah blah......
]
[foo3 kalamazoo]
[/-------------------------------- unary arg, using punctuation ]
[template ![bar] '''<hey>'''[bar]'''</hey>''']
[!baz]
[/-------------------------------- recursive templates ]
[template foo4[bar]
[foo3 [bar]]
]
[foo3 madagascar]
[template foo5[x] zoom [x]]
[template foo6[x] [x] zoom]
[foo6[foo5 peanut]]
[template kinda_weird[x y] [x] [y]]
[kinda_weird exactly..xanadu]
[/-------------------------------- space delimitted args ]
[template simple1[a b] [a][b]]
[simple1 w x]
[template simple2[a b c d] [a][b][c][d]]
[simple2 w x y z][simple2 w x y z trail]
[/-------------------------------- John's templates ]
[template code[x]
int main()
{
std::cout << ``[x]`` << std::endl;
}
]
[code "Hello\, World"]
[template alpha '''α''']
[template pow[a b] [a]'''<superscript>'''[b]'''</superscript>''' ]
[template super[text]'''<superscript>'''[text]'''</superscript>''' ]
[pow x 2]
[pow [alpha] 2]
x[super 2]
[/-------------------------------- Some more ]
[template banana got a banana?]
[template plantation[bananarama] [bananarama]]
[plantation [banana]]
[/-------------------------------- Not a bug (there was a syntax error here) ]
[template join1[a b] [b][a]]
[template join2[a b] [a][b]]
[template test[x] [join1 [join2 0 [x]]...0]]
[test 0]
[/-------------------------------- Mismatched template ]
[template foo 1]
[fool]
[template blah 10]
[endsect]
[section Empty Templates]
[template empty1]
[template empty2 ]
[template empty3 [/comment]]
[template empty4 [/comment]
]
[template empty5
]
[template empty6
]
[template empty7
[/comment]
]
[template empty8
[/comment]
]
[template empty_arg1[x]]
[template empty_arg2[x y]]
[empty1]
[empty2]
[empty3]
[empty4]
[empty5]
[empty6]
[empty7]
[empty8]
[empty_arg1 1]
[empty_arg2 1 2]
[endsect]
[/----------------------------------- Nested templates ]
[section Nested Templates]
[template block_foo[content]
Start block template.
[content]
End block template.
]
[template phrase_foo[content] Start phrase template. [content] End phrase template.]
Pre [block_foo [block_foo Hello!]] Post
Pre [block_foo [phrase_foo Hello!]] Post
Pre [phrase_foo [block_foo Hello!]] Post
Pre [phrase_foo [phrase_foo Hello!]] Post
[endsect]
[/----------------------------------- Block Markup ]
[section Block Markup]
[template list
* a
* b]
[template horizontal
----]
[template codeblock
int main() {}]
[template paragraphs
Paragraphs 1
Paragraphs 2
]
[list][horizontal][codeblock][paragraphs]
* [list]
* [horizontal]
* [codeblock]
* [paragraphs]
[endsect]
[/----------------------------------- 1.5+ use static scoping ]
[section Static Scoping]
[template x static scoping]
[template static_test1[] [x]]
[template static_test2[x] [static_test1]]
[static_test2 dynamic scoping]
[/ This should be '[a]' because [a] isn't matched. ]
[template test1[] [a]]
[template test2[a] [test1]]
[test2 1]
[/ In 1.5 template arguments are scoped at the point they are defined]
[template y new]
[template static_test3[a y] [a]]
[static_test3 [y] old]
[/ From https://svn.boost.org/trac/boost/ticket/2034 ]
[template same[x] [x]]
[template echo[a b] [a] [b]]
[template echo_twice[x] [echo [same [x]]..[same [x]]]]
[echo_twice foo]
[endsect]
[/----------------------------------- 1.5+ template arguments ]
[section Template Arguments]
[template binary[x y] {[x]-[y]}]
[binary 1..2] [/ {1-2} ]
[binary 1 2] [/ {1-2} ]
[binary 1..2 3 4] [/ {1-2 3 4} ]
[binary 1 2..3 4] [/ {1 2-3 4} ]
[binary 1 2 3..4] [/ {1 2 3-4} ]
[binary 1.\.2..3] [/ {1..2-3} ]
[binary 1.\.2 3] [/ {1..2-3} ]
[binary [binary 1 2..3]..4] [/ { {1 2-3}-4} ]
[binary [binary 1 2..3] 4] [/ { {1 2-3}-4} ]
[binary [binary 1 2 3]..4] [/ { {1-2 3}-4} ]
[binary \[1 2\] 3] [/ {[1-2] 3} ]
[binary \[1..2\] 3] [/ {[1-2] 3} ]
[binary \[1 2] [/ {(1-2} ]
[template ternary[x y z] {[x]-[y]-[z]}]
[ternary 1..2..3] [/ {1-2-3} ]
[ternary 1 2 3] [/ {1-2-3} ]
[endsect]
[/----------------------------------- Block and phrases ]
[section Block and phrase templates]
[template phrase_template[] Some *text*]
[template block_template[]
A <emphasis>paragraph</emphasis>.
]
[phrase_template]
[block_template]
[`phrase_template]
[`block_template]
[/ Trailing newline shouldn't be included]
[template named_index[type title]
'''<index type="'''[type]'''"><title>'''[title]'''</title></index>'''
]
[named_index things Things]
[endsect]
[/-------------------------------- Skipping template body ]
[section:template_body Skipping the template body correctly]
[template args1[x] [`x]]
[template args2[]
[ordered_list [``code``]]
]
[/ Due to a bug in the template parser need to stop the parser
thinking that the code is an escaped template. ]
[template args3[]
[ordered_list [\ `code`]]
]
[args1 <emphasis>Argument</emphasis>]
[args2]
[args3]
[endsect]
[/----------------------------------- Escaped templates ]
[section Escaped templates]
[template raw_markup <thingbob>Not real boostbook</thingbob>]
[template escaped1 [x] [`x]]
[`raw_markup]
[escaped1 <thingbob>More fake boostbook</thingbob>]
[endsect]
|