03_test_environment.md 7.44 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22


Test of parser: "block_environment"
===================================


Match-test "1"
--------------

### Test-code:
    \begin{generic}
    A generic block element is a block element
    that is unknown to DHParser.
    
    Unknown begin-end-structures are always
    considered as block elements and not
    as inline elements.
    \end{generic}
    

### AST
    (generic_block
eckhart's avatar
eckhart committed
23
24
        (begin_environment
            "generic"
25
        )
eckhart's avatar
eckhart committed
26
27
28
29
        (paragraph
            (text
                "A generic block element is a block element"
                "that is unknown to DHParser."
30
            )
eckhart's avatar
eckhart committed
31
32
33
            (:Whitespace
                " "
            )
34
        )
eckhart's avatar
eckhart committed
35
36
37
38
39
        (paragraph
            (text
                "Unknown begin-end-structures are always"
                "considered as block elements and not"
                "as inline elements."
40
            )
eckhart's avatar
eckhart committed
41
            (:Whitespace
42
43
44
45
                ""
                ""
            )
        )
eckhart's avatar
eckhart committed
46
47
48
        (end_environment
            "generic"
        )
49
50
51
52
53
54
55
56
57
58
59
60
61
62
    )

Match-test "2"
--------------

### Test-code:
    \begin{generic}
    a single block paragraph
    \end{generic} % ending with
    % a comment
    

### AST
    (generic_block
eckhart's avatar
eckhart committed
63
64
65
66
67
68
        (begin_environment
            "generic"
        )
        (paragraph
            (text
                "a single block paragraph"
69
            )
eckhart's avatar
eckhart committed
70
            (:Whitespace
71
72
73
74
                ""
                ""
            )
        )
eckhart's avatar
eckhart committed
75
76
        (end_environment
            "generic"
77
78
79
80
81
82
83
84
85
86
87
88
89
        )
    )

Match-test "3"
--------------

### Test-code:
    \begin{quote}
    a known block element
    \end{quote}

### AST
    (quotation
eckhart's avatar
eckhart committed
90
91
92
93
94
95
96
        (paragraph
            (text
                "a known block element"
            )
            (:Whitespace
                ""
                ""
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
            )
        )
    )

Fail-test "10"
--------------

### Test-code:
    \begin{generic}inline environment\end{generic}
    

Fail-test "11"
--------------

### Test-code:
    \begin{generic}inline environment
    \end{generic}
    

Fail-test "12"
--------------

### Test-code:
    \begin{generic}
    invalid enivronment \end{generic}
    


Test of parser: "inline_environment"
====================================


Match-test "1"
--------------

### Test-code:
    \begin{generic}inline environment\end{generic}

### AST
    (generic_inline_env
        (begin_environment
            "generic"
        )
eckhart's avatar
eckhart committed
140
141
142
        (:Whitespace
            " "
        )
143
        (paragraph
144
145
            (text
                "inline environment"
146
            )
eckhart's avatar
eckhart committed
147
148
149
            (:Whitespace
                " "
            )
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
        )
        (end_environment
            "generic"
        )
    )

Match-test "2"
--------------

### Test-code:
    \begin{generic}inline environment
    \end{generic}

### AST
    (generic_inline_env
        (begin_environment
            "generic"
        )
eckhart's avatar
eckhart committed
168
169
170
        (:Whitespace
            " "
        )
171
        (paragraph
172
173
            (text
                "inline environment"
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
            )
            (:Whitespace
                ""
                ""
            )
        )
        (end_environment
            "generic"
        )
    )

Match-test "3"
--------------

### Test-code:
    $ inline math $

### AST
    (inline_math
        " inline math "
    )

Fail-test "10"
--------------

### Test-code:
    \begin{generic}
    invalid enivronment \end{generic}
    


Test of parser: "itemize"
=========================


Match-test "1"
--------------

### Test-code:
    \begin{itemize}
    \item Items doe not need to be
    \item separated by empty lines.
    \end{itemize}

### AST
eckhart's avatar
eckhart committed
219
    (itemize)
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239

Match-test "2"
--------------

### Test-code:
    \begin{itemize}
    
    \item But items may be
    
    \item separated by blank lines.
    
    \item
    
    Empty lines at the beginning of an item will be ignored.
    
    \end{itemize}

### AST
    (itemize
        (item
eckhart's avatar
eckhart committed
240
241
242
            (paragraph
                (text
                    "separated by blank lines."
243
                )
eckhart's avatar
eckhart committed
244
245
246
                (:Whitespace
                    " "
                )
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
            )
        )
    )

Match-test "3"
--------------

### Test-code:
    \begin{itemize}
    \item Items can consist of
    
    several paragraphs.
    \item Or of one paragraph
    \end{itemize}

### AST
eckhart's avatar
eckhart committed
263
    (itemize)
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278

Match-test "4"
--------------

### Test-code:
    \begin{itemize}
    \item
    \begin{itemize}
    \item Item-lists can be nested!
    \end{itemize}
    \end{itemize}

### AST
    (itemize
        (item
eckhart's avatar
eckhart committed
279
280
281
282
283
284
285
286
287
            (itemize
                (item
                    (paragraph
                        (text
                            "Item-lists can be nested!"
                        )
                        (:Whitespace
                            ""
                            ""
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
                        )
                    )
                )
            )
        )
    )

Match-test "5"
--------------

### Test-code:
    \begin{itemize}
    \item Item-lists may consist of just one item.
    \end{itemize}

### AST
    (itemize
        (item
eckhart's avatar
eckhart committed
306
307
308
309
310
311
312
            (paragraph
                (text
                    "Item-lists may consist of just one item."
                )
                (:Whitespace
                    ""
                    ""
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
                )
            )
        )
    )

Fail-test "11"
--------------

### Test-code:
    \begin{itemize}
    Free text is not allowed within an itemized environment!
    \end{itemize}


Test of parser: "enumerate"
===========================


Match-test "1"
--------------

### Test-code:
    \begin{enumerate}
    \item Enumerations work just like item-lists.
    \item Only that the bullets are numbers.
    \end{enumerate}

### AST
eckhart's avatar
eckhart committed
341
    (enumerate)
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360

Match-test "2"
--------------

### Test-code:
    \begin{enumerate}
    \item \begin{itemize}
    \item Item-lists and
    \item Enumeration-lists
    \begin{enumerate}
    \item can be nested
    \item arbitrarily
    \end{enumerate}
    \item Another item
    \end{itemize}
    \item Plain numerated item.
    \end{enumerate}

### AST
eckhart's avatar
eckhart committed
361
    (enumerate)
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385

Match-test "3"
--------------

### Test-code:
    \begin{enumerate} % comment
    
    
    % more comments and paragraph separators
    % yet some more
    
    
    \item %another comment
    finally, the first item
    
    
    % comment
    
    
    \end{enumerate}

### AST
    (enumerate
        (item
eckhart's avatar
eckhart committed
386
387
388
            (paragraph
                (text
                    "finally, the first item"
389
                )
eckhart's avatar
eckhart committed
390
391
392
                (:Whitespace
                    " "
                )
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
            )
        )
    )

Match-test "4"
--------------

### Test-code:
    \begin{enumerate}
    \item An item
    
    \begin{itemize}
    \item with an enumeration
    \end{itemize}
    as a separate paragraph
    \end{enumerate}

### AST
    (enumerate
        (item
eckhart's avatar
eckhart committed
413
414
415
            (paragraph
                (text
                    "An item"
416
                )
eckhart's avatar
eckhart committed
417
418
419
                (:Whitespace
                    " "
                )
eckhart's avatar
eckhart committed
420
421
422
423
424
425
426
427
428
429
            )
            (itemize
                (item
                    (paragraph
                        (text
                            "with an enumeration"
                        )
                        (:Whitespace
                            ""
                            ""
430
431
432
                        )
                    )
                )
eckhart's avatar
eckhart committed
433
434
435
436
437
438
439
440
            )
            (paragraph
                (text
                    "as a separate paragraph"
                )
                (:Whitespace
                    ""
                    ""
441
442
443
444
                )
            )
        )
    )