-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.qmd
More file actions
422 lines (289 loc) · 9.5 KB
/
Copy pathtest.qmd
File metadata and controls
422 lines (289 loc) · 9.5 KB
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
---
title: "Test"
subtitle: "Testing the accordion shortcode"
author: "Roy Francis"
date: last-modified
date-format: DD-MMM-YYYY
number-sections: true
accordion:
- yaml-simple:
- header: Click here to view contents
body: This content is defined in the document yaml
- yaml-empty:
- yaml-missing-header:
- body: This item has no header
- yaml-missing-body:
- header: This item has no body
- yaml-missing-both:
- header: ""
body: ""
- yaml-many-items:
- header: Item 1
body: This is the body content for item 1
- header: Item 2
body: This is the body content for item 2
- header: Item 3
- header: Item 4
body: This is the body content for item 4
- yaml-collapsed:
- header: This is collapsed (default)
body: Collapsed body content
- header: This is expanded
body: Expanded body content
collapsed: false
- yaml-custom-id:
- header: Item with custom id
body: Custom id body
id: my-custom-id
- yaml-id-conflict:
- header: Duplicate
body: duplicate
- header: Duplicate
body: duplicate
- yaml-markdown:
- header: "**Bold header**"
body: "This is **bold** and *italic*"
- yaml-multiline-markdown:
- header: "**Multiline markdown header**"
body: |
This is multiline content.
This is **bold** and *italic*.
- List item 1
- List item 2
| Col1 | Col2 |
|------|------|
| A | B |
- yaml-html:
- header: "<b>HTML bold header</b>"
body: "This is <b>bold</b> and <i>italic</i>"
- yaml-multiline-html:
- header: "<b>Multiline HTML header</b>"
body: |
<p>This is a paragraph.</p>
<ul>
<li>HTML list item 1</li>
<li>HTML list item 2</li>
</ul>
format:
html:
title-block-banner: true
pdf:
output-file: test-latex.pdf
toc: true
title-block-banner: true
code-overflow: wrap
typst:
output-file: test-typst.pdf
toc: true
title-block-banner: true
code-overflow: wrap
docx:
output-file: test.docx
toc: true
gfm:
output-file: test.md
epub:
output-file: test.epub
toc: true
---
# Error tests
These tests should each produce an error message.
## No arguments
Expected error: No arguments provided.
```lua
{{{< accordion >}}}
```
{{< accordion >}}
## Both positional and label kwargs
Expected error: Use either a positional argument or named arguments (label), not both.
```lua
{{{< accordion yaml-simple label="mixed" header="This is a header" body="This is body content" >}}}
```
{{< accordion yaml-simple label="mixed" header="This is a header" body="This is body content" >}}
## Invalid label - space
Expected error: Label contains invalid characters.
```lua
{{{< accordion label="inline simple" header="Header" body="Body" >}}}
```
{{< accordion label="inline simple" header="Header" body="Body" >}}
## Invalid label - special characters
Expected error: Label contains invalid characters.
```lua
{{{< accordion label="inline?simple" header="Header" body="Body" >}}}
```
{{< accordion label="inline?simple" header="Header" body="Body" >}}
## YAML label not found in metadata
Expected error: Accordion entry not found in yaml metadata.
```lua
{{{< accordion nonexistent >}}}
```
{{< accordion nonexistent >}}
## YAML empty metadata for label
Expected error: Missing 'header' and 'body'.
```lua
{{{< accordion yaml-empty >}}}
```
{{< accordion yaml-empty >}}
## YAML item missing header
Expected error: Item 1 is missing 'header'.
```lua
{{{< accordion yaml-missing-header >}}}
```
{{< accordion yaml-missing-header >}}
## YAML item missing body
Expected error: Item 1 is missing 'body'.
```lua
{{{< accordion yaml-missing-body >}}}
```
{{< accordion yaml-missing-body >}}
## YAML item missing both header and body
Expected error: Item 1 is missing 'header' and 'body'.
```lua
{{{< accordion yaml-missing-both >}}}
```
{{< accordion yaml-missing-both >}}
## YAML multiple items with partial missing
Expected error: Item 3 is missing 'body' (items 1, 2, 4 should render).
```lua
{{{< accordion yaml-many-items >}}}
```
{{< accordion yaml-many-items >}}
## Inline label with no metadata entry
Expected error: Accordion entry not found in yaml metadata.
```lua
{{{< accordion label="inline-empty" >}}}
```
{{< accordion label="inline-empty" >}}
## Inline missing body
Expected error: 'body' kwarg is missing.
```lua
{{{< accordion header="Click here to view contents" >}}}
```
{{< accordion header="Click here to view contents" >}}
## Inline missing header
Expected error: 'header' kwarg is missing.
```lua
{{{< accordion body="This content is defined inline" >}}}
```
{{< accordion body="This content is defined inline" >}}
## Inline header/body mixed with items
Expected error: Use either 'header'/'body' or 'items', not both.
```lua
{{{< accordion header="Header" body="Body" items='[{"header":"H","body":"B"}]' >}}}
```
{{< accordion header="Header" body="Body" items='[{"header":"H","body":"B"}]' >}}
## Inline bad JSON in items
Expected error: Missing 'header' and 'body'.
```lua
{{{< accordion items='not valid json' >}}}
```
{{< accordion items='not valid json' >}}
## Inline JSON item missing header
Expected error: Item 2 is missing 'header'.
```lua
{{{< accordion items='[{"header":"Item 1","body":"Body 1"},{"body":"Body 2"}]' >}}}
```
{{< accordion items='[{"header":"Item 1","body":"Body 1"},{"body":"Body 2"}]' >}}
## Inline JSON item missing body
Expected error: Item 1 is missing 'body'.
```lua
{{{< accordion items='[{"header":"Item 1"},{"header":"Item 2","body":"Body 2"}]' >}}}
```
{{< accordion items='[{"header":"Item 1"},{"header":"Item 2","body":"Body 2"}]' >}}
# Success tests
These tests should each render a working accordion.
## YAML simple single item
```lua
{{{< accordion yaml-simple >}}}
```
{{< accordion yaml-simple >}}
## YAML same label reused
```lua
{{{< accordion yaml-simple >}}}
```
{{< accordion yaml-simple >}}
## YAML collapsed state
```lua
{{{< accordion yaml-collapsed >}}}
```
{{< accordion yaml-collapsed >}}
## YAML custom id
```lua
{{{< accordion yaml-custom-id >}}}
```
{{< accordion yaml-custom-id >}}
## YAML id conflict
```lua
{{{< accordion yaml-id-conflict >}}}
```
{{< accordion yaml-id-conflict >}}
## YAML markdown formatting
```lua
{{{< accordion yaml-markdown >}}}
```
{{< accordion yaml-markdown >}}
## YAML multiline markdown
```lua
{{{< accordion yaml-multiline-markdown >}}}
```
{{< accordion yaml-multiline-markdown >}}
## YAML HTML formatting
```lua
{{{< accordion yaml-html >}}}
```
{{< accordion yaml-html >}}
## YAML multiline HTML
```lua
{{{< accordion yaml-multiline-html >}}}
```
{{< accordion yaml-multiline-html >}}
## Inline simple
```lua
{{{< accordion header="Click here to view contents" body="This content is defined inline" >}}}
```
{{< accordion header="Click here to view contents" body="This content is defined inline" >}}
## Inline double quoted hyphenated label
```lua
{{{< accordion label="\"my-accordion\"" header="Click to expand" body="This is the content of the accordion." >}}}
```
{{< accordion label="my-accordion" header="Click to expand" body="This is the content of the accordion." >}}
## Inline collapsed false
```lua
{{{< accordion header="This starts expanded" body="Expanded content by default." collapsed="false" >}}}
```
{{< accordion header="This starts expanded" body="Expanded content by default." collapsed="false" >}}
## Inline with custom id
```lua
{{{< accordion header="Custom item id" body="Custom ids are useful when you need anchor links." id="custom-item-1" >}}}
```
{{< accordion header="Custom item id" body="Custom ids are useful when you need anchor links." id="custom-item-1" >}}
## Inline multi items via JSON
```lua
{{{< accordion items='[{"header":"Inline Item 1","body":"Content for item 1."},{"header":"Inline Item 2","body":"Content for item 2.","collapsed":false}]' >}}}
```
{{< accordion items='[{"header":"Inline Item 1","body":"Content for item 1."},{"header":"Inline Item 2","body":"Content for item 2.","collapsed":false}]' >}}
## Inline multi with custom id via JSON
```lua
{{{< accordion items='[{"header":"Item A","body":"Body A","id":"item-a"},{"header":"Item B","body":"Body B"}]' >}}}
```
{{< accordion items='[{"header":"Item A","body":"Body A","id":"item-a"},{"header":"Item B","body":"Body B"}]' >}}
## Inline markdown formatting
```lua
{{{< accordion header="**Bold header**" body="This is **bold** and *italic*" >}}}
```
{{< accordion header="**Bold header**" body="This is **bold** and *italic*" >}}
## Inline HTML formatting
```lua
{{{< accordion header="<b>HTML bold header</b>" body="This is <b>bold</b> and <i>italic</i>" >}}}
```
{{< accordion header="<b>HTML bold header</b>" body="This is <b>bold</b> and <i>italic</i>" >}}
## Inline JSON items with markdown
```lua
{{{< accordion items='[{"header":"**Bold JSON header**","body":"This is **bold** and *italic*."},{"header":"Second item","body":"- List item 1\n- List item 2"}]' >}}}
```
{{< accordion items='[{"header":"**Bold JSON header**","body":"This is **bold** and *italic*."},{"header":"Second item","body":"- List item 1\n- List item 2"}]' >}}
## Inline JSON items with HTML
```lua
{{{< accordion items='[{"header":"<b>HTML JSON header</b>","body":"This is <b>bold</b> and <i>italic</i>."},{"header":"Second item","body":"<ul><li>Item 1</li><li>Item 2</li></ul>"}]' >}}}
```
{{< accordion items='[{"header":"<b>HTML JSON header</b>","body":"This is <b>bold</b> and <i>italic</i>."},{"header":"Second item","body":"<ul><li>Item 1</li><li>Item 2</li></ul>"}]' >}}