summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/duckuments/duckuments.sty
blob: 7cadc5ca753fdfe8b401078fa5ccb0b4e7123e48 (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
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
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
%%
%% This is file `duckuments.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% duckuments.dtx  (with options: `pkg')
%% 
%% --------------------------------------------------------------
%% duckuments -- minimal working duckuments
%% E-mail: jspratte@yahoo.de
%% Released under the LaTeX Project Public License v1.3c or later
%% See http://www.latex-project.org/lppl.txt
%% --------------------------------------------------------------
%% 
%% Copyright (C) 2018-2019 Jonathan P. Spratte
%% 
%% This  work may be  distributed and/or  modified under  the conditions  of the
%% LaTeX Project Public License (LPPL),  either version 1.3c  of this license or
%% (at your option) any later version.  The latest version of this license is in
%% the file:
%% 
%%   http://www.latex-project.org/lppl.txt
%% 
%% This work is "maintained" (as per LPPL maintenance status) by
%%   Jonathan P. Spratte.
%% 
%% This work consists of the file  duckuments.dtx
%% and the derived files           duckuments.pdf,
%%                                 duckuments.sty,
%%                                 example-image-duck.tex and
%%                                 example-image-duck-portrait.tex
%% 
\RequirePackage{xparse}[2019-05-03]
\RequirePackage{letltxmacro,l3keys2e}
\def\duckuments@version{0.4e}
\def\duckuments@date{2019-09-28}
\ProvidesExplPackage
  {duckuments}          {\duckuments@date}
  {\duckuments@version} {minimal working duckuments}
\bool_if:nF
  {
    \sys_if_engine_luatex_p:
    || \sys_if_engine_pdftex_p:
    || \sys_if_engine_xetex_p:
  }
  {%>>>
    \msg_new:nnnn { duckuments } { incompatible }
      {
        The~duckuments~package~is~currently~only~compatible~with~pdfTeX,~
        LuaTeX,~and~XeTeX!
      }
      {
        \ ~_____________________________\\
        \ (Quack!~Sorry~for~that.~Quack!)\\
        \ ~"""""""""""""""""""""""""""""\\
        \ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ \ ~\ ~\ ~\ ~\string\ \\
        \ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ \ ~\ ~\ ~\ ~\ ~>()_\\
        \ \ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ \ ~\ ~\ ~\ ~\ ~\ ~(__)__
      }
    \msg_error:nn { duckuments } { incompatible }
    \endinput
  }%<<<
\file_if_exist:nF { example-image-duck.pdf }
  {%>>>
    \str_if_eq:VnF \c_sys_jobname_str { example-image-duck }
      {
        \msg_new:nnnn { duckuments } { missing~file }
          {
            The~file~`#1`~can't~be~found.~Make~sure~to~create~it
            \tl_if_empty:nF{#2}{~#2}.
          }
          { Sorry~for~the~inconvenience.~#3 }
        \msg_error:nnnnn { duckuments } { missing~file }
          { example-image-duck.pdf }
          {
            by~compiling~example-image-duck.tex~at~least~once
          }
          {
            If~you~don't~find~the~file~on~your~machine~you~can~use~
            `\duckumentsCreateExampleFiles`~in~your~document~to~produce~a~copy~
            in~the~current~working~directory.
          }
      }
  }%<<<
\file_if_exist:nF { example-image-duck-portrait.pdf }
  {%>>>
    \str_if_eq:VnF \c_sys_jobname_str { example-image-duck-portrait }
      {
        \msg_if_exist:nnF { duckuments } { missing~file }
          {
            \msg_new:nnnn { duckuments } { missing~file }
              {
                The~file~`#1`~can't~be~found.~Make~sure~to~create~it
                \tl_if_empty:nF{#2}{~#2}.
              }
              { Sorry~for~the~inconvenience.~#3 }
          }
        \msg_error:nnnnn { duckuments } { missing~file }
          { example-image-duck-portrait.pdf }
          {
            by~compiling~example-image-duck-portrait.tex~at~least~once
          }
          {
            If~you~don't~find~the~file~on~your~machine~you~can~use~
            `\duckumentsCreateExampleFiles`~in~your~document~to~produce~a~copy~
            in~the~current~working~directory.
          }
      }
  }%<<<
\newcommand*\duckuments@randoms{128}
\bool_new:N \l_duckuments_immediate_bool
\bool_new:N \l_duckuments_toc_bool
\bool_new:N \l_duckuments_math_inline_bool
\bool_new:N \l_duckuments_math_display_bool
\bool_new:N \l_duckuments_blindduck_pars_bool
\seq_new:N \l_duckuments_range_seq
\int_new:N \g_duckuments_blindduck_start_int
\int_gset:Nn \g_duckuments_blindduck_start_int { \c_one_int }
\int_new:N \g_duckuments_blindduck_end_int
\regex_const:Nn \c_duckuments_example_regex
  {
    example-image-duck
    |example-image-duck.pdf
    |example-image-duck-portrait
    |example-image-duck-portrait.pdf
  }
\regex_const:Nn \c_duckuments_range_regex { (\d+|\d+-|-\d+|\d+-\d+|-) }
\int_const:Nn \c_duckuments_blindduck_pars_int { 5 }
\bool_if:nTF
  {
    \str_if_eq_p:Vn \c_sys_jobname_str { example-image-duck }
    || \str_if_eq_p:Vn \c_sys_jobname_str { example-image-duck-portrait }
  }
  { \int_const:Nn \c_duckuments_example_pages_int { \c_one_int } }
  {
    \group_begin:
      \sys_if_engine_pdftex:T
        {
          \pdfximage{example-image-duck.pdf}
          \int_set:Nn \l_tmpa_int { \the\pdflastximagepages }
          \pdfximage{example-image-duck-portrait.pdf}
          \int_set:Nn \l_tmpb_int { \the\pdflastximagepages }
        }
      \sys_if_engine_luatex:T
        {
          \saveimageresource{example-image-duck.pdf}
          \int_set:Nn \l_tmpa_int { \lastsavedimageresourcepages }
          \saveimageresource{example-image-duck-portrait.pdf}
          \int_set:Nn \l_tmpb_int { \lastsavedimageresourcepages }
        }
      \sys_if_engine_xetex:T
        {
          \int_set:Nn \l_tmpa_int
            { \XeTeXpdfpagecount "example-image-duck.pdf" }
          \int_set:Nn \l_tmpb_int
            { \XeTeXpdfpagecount "example-image-duck-portrait.pdf" }
        }
      \int_const:Nn \c_duckuments_example_pages_int
        { \int_min:nn { \l_tmpa_int } { \l_tmpb_int } }
    \group_end:
  }
\msg_new:nnnn { duckuments } { option~unknown }
  {
    Unknown~option~'#1'~for~package~duckuments.
  }
  {
    \ ~__________________________________\\
    \ (Quack!~Nothing~here,~sorry.~Quack!)\\
    \ ~""""""""""""""""""""""""""""""""""\\
    \ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\string\ \\
    \ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~>()_\\
    \ \ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~(__)__
  }
\msg_new:nnnn { duckuments } { non-boolean~toc }
  {
    A~non-boolean~value~`#1`~was~received~for~the~`toc`~option~during~package~
    load~time.~It~is~assumed~this~was~given~to~\string\documentclass\ and~
    therefore~ignored.
  }
  {
    \ ~__________________________________\\
    \ (Quack!~Nothing~here,~sorry.~Quack!)\\
    \ ~""""""""""""""""""""""""""""""""""\\
    \ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\string\ \\
    \ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~>()_\\
    \ \ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~(__)__
  }
\msg_new:nnnn { duckuments } { out~of~range }
  {
    You~requested~element~#3~out~of~the~range~#1~to~#2~of~array~'#4'.\\
    I'll~just~use~element~#1~for~you.
  }
  {
    \ ~__________________________________\\
    \ (Quack!~Nothing~here,~sorry.~Quack!)\\
    \ ~""""""""""""""""""""""""""""""""""\\
    \ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\string\ \\
    \ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~>()_\\
    \ \ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~\ ~(__)__
  }
\cs_new:Npn \duckuments_patch_see_duckumentation:
  {%>>>
    \cs_set:Nn \msg_see_documentation_text:n
      {
        \\\\
        See~the~\str_if_eq:nnTF { ##1 } { duckuments } { duckumentation }
          {
            \str_if_eq:nnTF { ##1 } { LaTeX } { LaTeX3~ } { ##1~ }
            documentation
          }~for~further~information.
      }
  }%<<<
\duckuments_patch_see_duckumentation:
\keys_define:nn { duckuments }
  {%>>>
    ,immediate .bool_set:N = \l_duckuments_immediate_bool
    ,immediate .default:n = true
    ,full  .code:n =
      \duckuments_blindduck_range_test:n { 1-\c_duckuments_blindduck_pars_int }
    ,all   .meta:n = { full }
    ,maths .choice:
    ,maths / both    .code:n =
      {
        \bool_set_true:N \l_duckuments_math_inline_bool
        \bool_set_true:N \l_duckuments_math_display_bool
      }
    ,maths / display .code:n = \bool_set_true:N \l_duckuments_math_display_bool
    ,maths / inline  .code:n = \bool_set_true:N \l_duckuments_math_inline_bool
    ,maths / none    .code:n =
      {
        \bool_set_false:N \l_duckuments_math_inline_bool
        \bool_set_false:N \l_duckuments_math_display_bool
      }
    ,maths .default:n = both
    ,toc   .code:n =
      {
        \str_case:nnF { #1 }
          {
            { true  } { \bool_set_true:N  \l_duckuments_toc_bool }
            { false } { \bool_set_false:N \l_duckuments_toc_bool }
          }
          {
            \msg_warning:nnn { duckuments } { non-boolean~toc } { #1 }
          }
      }
    ,toc     .default:n = true
    ,unknown .code:n =
      { \msg_error:nnx { duckuments } { option~unknown } { \l_keys_key_tl } }
  }%<<<
\ProcessKeysOptions { duckuments }
\keys_define:nn { duckuments }
  {%>>>
    ,toc     .undefine:
    ,toc     .bool_set:N = \l_duckuments_toc_bool
    ,toc     .default:n = true
    ,unknown .code:n = \duckuments_blindduck_range_test:V \l_keys_key_tl
  }%<<<
\bool_if:NTF \l_duckuments_immediate_bool
  { \AtEndOfPackage { \duckuments_patch_includegraphics: } }
  { \AtBeginDocument { \duckuments_patch_includegraphics: } }
\NewDocumentCommand \duckument { O{} }
  {%>>>
    \group_begin:
    \keys_set:nn { duckuments } { #1 }
    \bool_if:NT \l_duckuments_toc_bool { \tableofcontents }
    \cs_if_exist_use:NT \chapter
      { {\duckuments@headings@text{0}} \blindduck }
    \duckuments@headings{1} \blindduck
    \duckuments@headings{2} \blindduck
    \duckuments@headings{3} \blindduck
    \duckuments@headings{4} \blindduck
    \section {Lists}
    \duckuments_list_example:n { itemize }
    \duckuments_list_example:n { enumerate }
    \duckuments_list_example:n { description }
    \group_end:
  }%<<<
\NewDocumentCommand \blindduck { O{} }
  {%>>>
    \group_begin:
    \keys_set:nn { duckuments } { #1 }
    \duckuments@blindduck@text
    \bool_if:NT \l_duckuments_blindduck_pars_bool { \par }
    \group_end:
  }%<<<
\NewDocumentCommand \ducklist {s m}
  {%>>>
    \begin{#2}
      \IfBooleanTF { #1 }
        {\ducklists@content@starred}
        {
          \str_if_eq:nnTF { #2 } { description }
            \ducklists@content@starred
            \ducklists@content
        }
    \end{#2}
  }%<<<
\NewDocumentCommand \ducklistlist { s m }
  {%>>>
    \IfBooleanTF { #1 }
      { \duckuments@listlist@starred { #2 } }
      {
        \str_if_eq:nnTF { #2 } { description }
          { \duckuments@listlist@starred { description } }
          { \duckuments@listlist{#2} }
      }
  }%<<<
\newcommand*\duckenumerate{\ducklist{enumerate}}
\newcommand*\duckitemize{\ducklist{itemize}}
\newcommand*\duckdescription{\ducklist{description}}
\newcommand*\duckumentsCreateExampleFiles
  {%>>>
    \iow_new:N \duckuments_example_file_iow
    \iow_open:Nn \duckuments_example_file_iow { example-image-duck.tex }
    \iow_now:Nn \duckuments_example_file_iow
      { \documentclass[tikz,multi]{standalone} }
    \iow_now:Nn \duckuments_example_file_iow
      { \usepackage{tikzducks} }
    \iow_now:Nn \duckuments_example_file_iow
      { \usepackage{duckuments} }
    \iow_now:Nn \duckuments_example_file_iow
      { \begin{document} }
    \iow_now:Nn \duckuments_example_file_iow
      { \duckumentsDrawRandomDucks }
    \iow_now:Nn \duckuments_example_file_iow
      { \end{document} }
    \iow_close:N \duckuments_example_file_iow
    \iow_open:Nn \duckuments_example_file_iow
      { example-image-duck-portrait.tex }
    \iow_now:Nn \duckuments_example_file_iow
      { \documentclass[tikz,multi]{standalone} }
    \iow_now:Nn \duckuments_example_file_iow
      { \usepackage{tikzducks} }
    \iow_now:Nn \duckuments_example_file_iow
      { \usepackage{duckuments} }
    \iow_now:Nn \duckuments_example_file_iow
      { \begin{document} }
    \iow_now:Nn \duckuments_example_file_iow
      { \duckumentsDrawRandomDucks* }
    \iow_now:Nn \duckuments_example_file_iow
      { \end{document} }
    \iow_close:N \duckuments_example_file_iow
  }%<<<
\newcommand*\duckumentsDrawRandomDucks
  {%>>>
    \@ifstar
      {\duckumentsDrawRandomDucks@portrait}
      {\duckumentsDrawRandomDucks@landscape}%
  }%<<<
\newcommand*\duckuments@headings[1]
  {%>>>
    \ifcase#1\relax
      \expandafter\chapter
    \or \expandafter\section
    \or \expandafter\subsection
    \or \expandafter\subsubsection
    \or \expandafter\paragraph
    \else \expandafter\@gobble
    \fi
    {\duckuments@headings@text{#1}}
  }%<<<
\newcommand*\duckuments@headings@level[1]
  {%>>>
    (
    \ifcase#1
      chapter
    \or section
    \or subsection
    \or subsubsection
    \or paragraph
    \fi
    )
  }%<<<
\newcommand*\duckuments@ifinline[2][]
  { \bool_if:NTF \l_duckuments_math_inline_bool { #2 } { #1 } }
\newcommand*\duckuments@ifdisplay[2][]
  { \bool_if:NTF \l_duckuments_math_display_bool { #2 } { #1 } }
\cs_new_protected_nopar:Npn \duckuments_list_example:n #1
  {%>>>
    \subsection{Example\ for\ ducks\ (#1)}
    \ducklist { #1 }
    \subsubsection{Nested\ ducks}
    \ducklistlist { #1 }
  }%<<<
\NewDocumentCommand \duckuments@enquote { s +m }
  {%>>>
    \IfBooleanTF { #1 }
      {
        \cs_if_exist_use:NTF
          \enquote { * { #2 } }
          { `#2' }
      }
      {
        \cs_if_exist_use:NTF
          \enquote { { #2 } }
          {``#2''}
      }
  }%<<<
\newcommand*\duckumentsDrawRandomDucks@landscape[1][\duckuments@randoms]
  {%>>>
    \foreach\x in {1,2,...,#1}
      {\duckumentsDrawRandomDucks@draw{6.47214}{4}{3.23607}{2}}
  }%<<<
\newcommand*\duckumentsDrawRandomDucks@portrait[1][\duckuments@randoms]
  {%>>>
    \foreach\x in {1,2,...,#1}
      {\duckumentsDrawRandomDucks@draw{1.8541}{3}{.92705}{1.5}}
  }%<<<
\newcommand*\duckumentsDrawRandomDucks@draw[4]
  {%>>>
    \begin{tikzpicture}
      \draw[fill=gray!50,use~as~bounding~box] (0,0) rectangle (#1,#2);
      \draw[gray,thin] (0,0) -- (#1,#2);
      \draw[gray,thin] (0,#2) -- (#1,0);
      \draw[gray,thin] (#3,0) -- (#3,#2);
      \draw[gray,thin] (0,#4) -- (#1,#4);
      \node at (#3,#4) {\tikz\randuck;};
      \draw[black] (0,0) rectangle (#1,#2);
    \end{tikzpicture}
  }%<<<
\cs_new_protected_nopar:Npn \duckuments_patch_includegraphics:
  {%>>>
    \@ifpackageloaded { graphicx }
      {
        \LetLtxMacro\duckuments@includegraphicsBAK\includegraphics
        \RenewDocumentCommand \includegraphics
          { >{\duckuments_starred:n}s O{} o m }
          {
            \IfValueTF { ##3 }
              { \duckuments@includegraphicsBAK##1[{##2}][{##3}]{##4} }
              {
                \regex_match:NnTF \c_duckuments_example_regex { ##4 }
                  {
                    \duckuments@includegraphicsBAK##1
                      [{page=\duckuments_random_page:,##2}]
                      { ##4 }
                  }
                  {
                    \duckuments@includegraphicsBAK##1[{##2}]{##4}
                  }
              }
          }
      }
      {}
  }%<<<
\cs_new_protected:Npn \duckuments_blindduck_range_test:n #1
  {%>>>
    \regex_match:NnTF \c_duckuments_range_regex { #1 }
      {
        \seq_set_split:Nnn \l_duckuments_range_seq { - } { #1 }
        \int_compare:nNnTF
          { \c_one_int } = { \seq_count:N \l_duckuments_range_seq }
          {
            \cs_set:Npn \duckuments@blindduck@text
              {
                \duckuments_blindduck_single_par:n { #1 }
                \duckuments_blindduck_set_next_start:n { #1 }
              }
          }
          {
            \bool_set_true:N \l_duckuments_blindduck_pars_bool
            \exp_args:Nx
            \tl_if_empty:nF
              { \seq_item:Nn \l_duckuments_range_seq { \c_one_int } }
              {
                \int_gset:Nn \g_duckuments_blindduck_start_int
                  { \seq_item:Nn \l_duckuments_range_seq { \c_one_int } }
              }
            \exp_args:Nx
            \tl_if_empty:nTF { \seq_item:Nn \l_duckuments_range_seq { 2 } }
              {
                \int_gset_eq:NN
                  \g_duckuments_blindduck_end_int
                  \g_duckuments_blindduck_start_int
              }
              {
                \int_set:Nn \g_duckuments_blindduck_end_int
                  { \seq_item:Nn \l_duckuments_range_seq { 2 } }
              }
            \duckuments_blindduck_set_text:xx
              { \int_use:N \g_duckuments_blindduck_start_int }
              { \int_use:N \g_duckuments_blindduck_end_int }
          }
      }
      {
        \exp_args:NnnV
          \msg_error:nnn { duckuments } { option~unknown } \l_keys_key_tl
      }
  }%<<<
\cs_generate_variant:Nn \duckuments_blindduck_range_test:n { V }
\cs_new:Npn \duckuments_blindduck_set_text:nn #1 #2
  {%>>>
    \def \duckuments@blindduck@text
      {
        \int_step_function:nnnN { #1 } { \c_one_int } { #2 }
          \duckuments_blindduck_par_loop:n
        \duckuments_blindduck_set_next_start:n { #2 }
      }
  }%<<<
\cs_generate_variant:Nn \duckuments_blindduck_set_text:nn { xx }
\cs_new:Npn \duckuments_blindduck_set_next_start:n #1
  {%>>>
    \int_gset:Nn \g_duckuments_blindduck_start_int
      { \int_mod:nn { #1 } { \c_duckuments_blindduck_pars_int } + \c_one_int }
  }%<<<
\cs_new:Npn \duckuments_blindduck_single_par:n #1
  {%>>>
    \bool_if:nTF
      {
        \int_compare_p:nNn { #1 } > { \c_duckuments_blindduck_pars_int }
        || \int_compare_p:nNn { #1 } < { \c_one_int }
      }
      {
        \msg_error:nnxxxx { duckuments } { out~of~range }
          { 1 } { \int_use:N \c_duckuments_blindduck_pars_int } { #1 }
          { blindduck~paragraphs }
        \duckuments@blindduck@text@i
      }
      {
        \use:c { duckuments@blindduck@text@ \int_to_roman:n { #1 } }
      }
  }%<<<
\cs_new:Npn \duckuments_blindduck_par_loop:n #1
  {%>>>
    \duckuments_blindduck_single_par:n { #1 }
    \par
  }%<<<
\cs_new_protected:Npn \duckuments_starred:n #1
  {%>>>
    \IfBooleanTF { #1 }
      { \def\ProcessedArgument{*} }
      { \def\ProcessedArgument{} }
  }%<<<
\cs_new:Npn \duckuments_random_page:
  { \int_rand:n { \c_duckuments_example_pages_int } }
\ExplSyntaxOff
\newcommand*\duckuments@blindduck@text{\duckuments@blindduck@text@i}
\newcommand*\duckuments@blindduck@text@i
  {%>>>
    There once was a very smart but sadly blind duck. When it was still a small
    duckling it was renowned for its good vision. But sadly as the duck grew
    older it caught a sickness which caused its eyesight to worsen. It became so
    bad, that the duck couldn't read the notes it once took containing much of
    inline math\duckuments@ifinline{ just like its favoured equation: $d = u_c
    \cdot k$}. Only displayed equations remained legible%
    \duckuments@ifdisplay[.]{ so it could still read \begin{equation}d = r a^k
    e\hbox{.}\end{equation}} That annoyed the smart duck, as it wasn't able to
    do its research any longer. It called for its underduckling and said:
    \duckuments@enquote{Go, find me the best eye ducktor there is. He shall
    heal me from my disease!}%
  }%<<<
\newcommand*\duckuments@blindduck@text@ii
  {%>>>
    \duckuments@enquote{But my duck, how are you supposed to manage your daily
    routines without my visual guidance}, replied the underduckling. The smart
    duck's face turned grim in anger. \duckuments@enquote{You dare to talk
    back?} The underduckling blushed ashamed. How could he have objections
    after his duck gave strict orders? The underduckling was so embarrassed
    about his own behaviour he had to solve an equation.%
  }%<<<
\newcommand*\duckuments@blindduck@text@iii
  {%>>>
    After the equation was solved and the underduckling prepared his leave for
    the next day it fell asleep in a shaky mood. It did not know what the
    journey had prepared for him and if he was prepared enough for it. His sleep
    was restless. The dreams he had that night were not calm and bright as they
    used to be for an innocent underduckling.%
  }%<<<
\newcommand*\duckuments@blindduck@text@iv
  {%>>>
    Before dawn the underduckling woke. He didn't have the feeling of being well
    rested. But nonetheless he knew that this was the day he should leave.
    Except saying goodbye to his beloved ones there was nothing holding him
    back. His duck had sent him on the most important mission a five weeks old
    inexperienced underduckling was ever sent on. He bid farewell to his mother,
    all his brothers and sisters, and finally from his duck. The bag was
    shouldered, the boots were tied, the underduckling left.%
  }%<<<
\newcommand*\duckuments@blindduck@text@v
  {%>>>
    As the underduckling went along he saw a tree. It was so tall he couldn't
    even approximate its height. Oh, how small he felt. What should he, a small
    duckling whose plumage was still fluffy, achieve in this vast, gigantic
    world? He stuck his trembling wings under the straps of his backpack to calm
    his shaking limbs. Where should he start his search? How should he survive
    in the hostile nature surrounding the sheltered pond of his community?
  }%<<<
\newcommand*\duckuments@headings@text[1]
  {A friendly duck at level #1 \duckuments@headings@level{#1}}
\newcommand*\ducklists@content
  {%>>>
    \item First swims father drake
    \item Then floats mother duck
    \item After her paddles baby duckling
    \item And over there bathes uncle canard
  }%<<<
\newcommand*\ducklists@content@starred
  {%>>>
    \item[drake] is the swimming father
    \item[duck] is the floating mother
    \item[duckling] is the paddling baby
    \item[canard] is the bathing uncle
  }%<<<
\newcommand*\duckuments@listlist[1]
  {%>>>
    \begin{#1}
      \item swimming father drake
        \begin{#1}
          \item swimming father drake
            \begin{#1}
              \item swimming father drake
                \begin{#1}
                  \item swimming father drake
                  \item floating mother duck
                \end{#1}
              \item floating mother duck
            \end{#1}
          \item floating mother duck
        \end{#1}
      \item floating mother duck
    \end{#1}%
  }%<<<
\newcommand*\duckuments@listlist@starred[1]
  {%>>>
    \begin{#1}
      \item[drake] is the swimming father
        \begin{#1}
          \item[drake] is the swimming father
            \begin{#1}
              \item[drake] is the swimming father
                \begin{#1}
                  \item[drake] is the swimming father
                  \item[duck] is the floating mother
                \end{#1}
              \item[duck] is the floating mother
            \end{#1}
          \item[duck] is the floating mother
        \end{#1}
      \item[duck] is the floating mother
    \end{#1}%
  }%<<<
%% 
%%
%% End of file `duckuments.sty'.