summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/lipsum/lipsum.dtx
blob: fb81e62771d9593f4a53c69df3749a506ed77a25 (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
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
% \iffalse meta-comment
%
% This file is part of the package lipsum for use with LaTeX2e.
%
% Function: Access to 150 paragraphs of the well known Lorem Ipsum dummy text.
%
% This program may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either version 1.3
% of this license or (at your option) any later version.
% The latest version of this license is in
%   http://www.latex-project.org/lppl.txt
% and version 1.3 or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% Please send error reports and suggestions for improvements to
%    https://github.com/PhelypeOleinik/lipsum
%
\def\lipsumversion{2.7}
\def\lipsumdate{2021-09-20}
%<*driver>
\ProvidesFile{lipsum.dtx}%
  [\lipsumdate\space v\lipsumversion\space
   Access to 150 of Lorem Ipsum dummy text]
\documentclass{l3doc}
\usepackage{xcolor}
\usepackage{booktabs}
\usepackage{tabularx}
\usepackage{enumitem}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage[a4paper,
  top=2cm, left=8.8cm, right=2cm, bottom=3cm,
  marginparwidth=6.3cm, marginparsep=.5cm,
]{geometry}
\newlength\fullmargin
\setlength\fullmargin\marginparwidth
\addtolength\fullmargin\marginparsep
\usepackage{mdframed}
\mdfdefinestyle{expl}{%
  backgroundcolor=black!5!white,
  linewidth=0pt,
  middlelinewidth=0pt
}
\newmdenv[style=expl]{explbox}

\usepackage{lipsum,multicol}
\usepackage{multirow}
\usepackage[latin, english]{babel}
\makeatletter
\newcommand\@subtitle{}
\newcommand\subtitle[1]{%
  \renewcommand\@subtitle{#1}}
  \renewcommand\maketitle[1]{%
  \noindent
  \hspace{-\fullmargin}%
  \begin{minipage}{\textwidth+\fullmargin}
    \renewcommand\thefootnote{\fnsymbol{footnote}}
    \let\thanks\footnote
    {
      \centering
      {\LARGE \@title}\\[.8\baselineskip]
      {\LARGE \@subtitle}\\[2\baselineskip]
      {\Large \@author}\\[\baselineskip]
      {\Large \@date}\\[\baselineskip]
    }
    \ifx\\#1\\\else
      \begin{multicols}{2}[%
        \subsection*{\hfill\abstractname\hfill\null}]
        \setlength{\columnsep}{.5cm}%
        #1
      \end{multicols}
    \fi
  \end{minipage}}
\makeatother
\newenvironment{wide}
  {\hspace{-.75\fullmargin}%
   \begin{minipage}{\textwidth+.75\fullmargin}}
  {\end{minipage}}
\newcommand\opt[1]{\textsf{#1}} % l3doc does not have some markup for package options...
\newcommand\lips{\emph{Lorem ipsum\ldots}}
\renewcommand\topfraction{.85}
\renewcommand\textfraction{.15}
\renewcommand\floatpagefraction{.85}
\emergencystretch 2em
\newcommand\secref[1]{(see section~\ref{#1})}
\usepackage{hyperref}
\def\ghissue#1{%
  \texttt{\##1}\footnote{%
    \url{https://github.com/PhelypeOleinik/lipsum/issues/#1}}}
\begin{document}
  \DocInput{lipsum.dtx}
\end{document}
%</driver>
%<*package>
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{l3keys2e}
\@ifundefined{NewDocumentCommand}
  {\RequirePackage{xparse}}{}
\ProvidesExplPackage {lipsum} {\lipsumdate} {\lipsumversion}
  {150 paragraphs of Lorem Ipsum dummy text}
%</package>
% \fi
%
% \title{\pkg{lipsum}}
% \subtitle{Access to 150 paragraphs of Lorem Ipsum dummy
% text\thanks{Version: \lipsumversion}^^A
% \thanks{Since March 2021, Phelype Oleinik maintains this package
%   (\href{mailto:phelype.oleinik@latex-project.org}
%        {phelype.oleinik\meta{at}latex-project.org}).}}
% \author{Patrick Happel\thanks{patrick.happel@rub.de}}
% \date{\today}
% \RecordChanges
% \changes{v1.0}{2004/05/15}{First release}
% \changes{v1.1}{2011/02/08}{Added support for typesetting dummy text without
% paragraphs in between.}
% \changes{v1.2}{2011/04/14}{Bug fix (thanks to  Florent Chervet and Ulrike
% Fischer for reporting).}
% \changes{v1.3}{2014/07/19}{Introduced some improvements and provided some
% new macros (thanks to tex.stackexchange user egreg).}
% \changes{v1.3a}{2017/08/10}{Fixed a type in the documentation (thanks to
% Vincent Belaïche). This version never made its way on CTAN due to some
% version naming conflicts. Since the change here was only in the
% documentation, I first didn't want it to be 1.3a and later had no time to
% update it properly.}
% \changes{v2.0}{2018/11/07}{Added the possibility to fetch a number of sentences from the
% lipsum paragraphs (thanks to Frank Mittelbach).}
% \changes{v2.0}{2018/11/07}{Rewritten code in \pkg{expl3} syntax.}
% \changes{v2.1}{2018/11/18}{Changed defaults, now nothing is typeset at the
% end of any list.}
% \changes{v2.1a}{2018/11/24}{Added forgotten ins-file to CTAN. This requires
% a new version number.}
% \changes{v2.2}{2018/12/25}{replaced \cs{tex_par:D} by \cs{par} to avoid
% incompatibilities with \LaTeX2e's |list|-environment. Thanks to Karl Hagen
% for reporting. See \url{ttps://github.com/patta42/lipsum/issues/12}.}
% \changes{v2.3}{2021/03/03}{Remove dependency on an \pkg{xparse} internal
%   macro.  \pkg{lipsum}'s new home at
%   \url{https://github.com/PhelypeOleinik/lipsum}}
% \changes{v2.4}{2021/06/03}{Major changes documented in \texttt{CHANGELOG.md}.}
%
% \maketitle{\pkg{lipsum} is a \LaTeX{} package that produces dummy text
% to be used in test documents or examples. The paragraphs are taken with
% permission from \url{https://www.lipsum.com/}, thanks to James Wilson for
% this work. Furthermore, the following people contributed to \pkg{lipsum} by
% suggesting improvements, correcting bugs or finding typos in the
% documentation: Florent Chervet, Ulrike Fischer, Vincent Belaïche, Enrico
% Gregorio, Frank Mittelbach, Karl Hagen.
%
% Please, file bug reports, typos in the documentation or
% feature requests as an issue on
% \url{https://github.com/PhelypeOleinik/lipsum/issues}.}
%
% \begin{documentation}
%
% \section{Introduction}
%
% To load the package, write
% \begin{verbatim}
%     \usepackage{lipsum}
% \end{verbatim}
% in the preamble of your document. Probably the most important macro
% provided by this package is \DescribeMacro{\lipsum}\cs{lipsum}, which
% typesets the \emph{Lorem ipsum} paragraphs. The first optional
% argument allows to specify the range of the paragraphs. For example,
% \verb|\lipsum[4-57]| typesets the paragraphs 4 to 57 and accordingly,
% \verb|\lipsum[23]| typesets the 23\textsuperscript{rd} paragraph.
% Using \cs{lipsum} without its optional argument typesets the
% paragraphs 1--7 of \lips
%
% As of version 2.0, \cs{lipsum} has a second optional argument which allows
% selecting a range of sentences from the paragraphs. To get the sentences
% four to eight from paragraphs three to nine, use |\lipsum[3-9][4-8]|.
% The sentences are counted from the first sentence of the first selected
% paragraph.  In the previous example, sentence number~1 is the first
% sentence of paragraph number~3.
%
% \subsection{Foreword to Version 2.4}
% \label{sec:foreword2.4}
%
% Version~2.4 received another almost complete rewrite focussing on the
% internal structure of the package, and some minor fixes (see the
% \texttt{CHANGELOG} for more details).
%
% The package now ships with a new dummy text, in pseudo-Czech, provided
% by Ondřej Macek.  To select this text, load the package with
% |\usepackage[text=lipsum-cs]{lipsum}| or use
% \cs{setlipsum}|{text=lipsum-cs}|.
%
% The dummy texts now have a language metadata which is used to select
% the proper hyphenation patterns to the dummy text.  For compatibility
% with old documents you can load \pkg{lipsum} with
% |\usepackage[auto-lang=false]{lipsum}| or, as above, use
% \cs{setlipsum}|{auto-lang=false}|.
%
% Finally, as demonstrated above, a new macro \cs{setlipsum} was added
% to change package options anywhere in the document, so you may change,
% for example, the dummy text printed by \cs{lipsum} on-the-fly by using
% \cs{setlipsum}|{text=|\meta{name}|}| \secref{sec:other-texts} for a
% list of available texts). In general, a key-val syntax was added which
% will eventually replace the command-based syntax for package settings.
% For the time being, both versions are available.
%
% \subsection{Foreword to Version 2.0}\label{sec:foreword2.0}
%
% Version 2.0 of \pkg{lipsum} is a complete (well, nearly complete)  rewrite
% of the code in \pkg{expl3}
% syntax. I have never used \pkg{expl3} before and thus the code might be too
% complicated, might use wrong or badly chosen data types or weird function
% names. I am happy to receive comments on this.
%
% Due the complete rewrite, some internals have changed which might impact
% older documents. Since, however, I guess that \pkg{lipsum} is not used for
% documents with true, important, content, I think potentially breaking up old
% documents is not a big issue here. The changes are:
% \begin{itemize}
% \item The package option \opt{nopar} now uses a \cs{space} as terminator,
% instead of \cs{relax}.
% \item The commands \cs{UnpackLipsum} and \cs{UnpackLipsum*} are no longer
% available. The effect of \cs{UnpackLipsum} now is default for
% \cs{unpacklipsum} (or \cs{unpacklipsum*}, depending on the package
% option). The effect of \cs{UnpackLipsum*} can be mimicked by using
% \cs{LipsumProtect}\Arg{command}, as in the following example:
% \begin{explbox}
% \begin{verbatim}
% \documentclass{article}
% \usepackage{lipsum,xcolor}
% \newcommand\foo{}
% \SetLipsumParListItemEnd{\LipsumProtect{\foo}}
%
% \begin{document}
% \renewcommand\foo{\color{.!75!red}}
%   { \lipsumexp }
%
% \newcounter{mycnt}\setcounter{mycnt}{1}
% \renewcommand\foo{%
%   (\themycnt)\stepcounter{mycnt}}
% \lipsumexp
% \end{document}
% \end{verbatim}
% \end{explbox}
% \item The internal macros \cs{lips@i}, \cs{lips@ii}, \cs{lips@iii}, \ldots,
%   \cs{lips@cl} are no longer available.
% \item All other internal macros (with one exception) are no longer available,
%   too.
% \end{itemize}
%
% \subsection{Foreword to version 2.2}
%
% As of version 2.2, \pkg{lipsum} provides a simple interface to define other
% texts to be used as output of the \cs{lipsum}-family of commands. This was
% heavily inspired by an issue raised by
% \emph{svenper} on
% github\footnote{\url{https://github.com/patta42/lipsum/issues/13}}. However,
% the implementation of this interface might not match the needs of everyone
% who wants to provide a dummy text in another language. Comments and
% suggestions on this are very welcome.
%
% Please note that the documentation still only refers to the
% \emph{Lorem ipsum} text.
%
% \section{Usage}
%
% \pkg{lipsum} was intended to quickly provide a way to fill a page or two to
% analyze the page
% layout\footnote{\url{https://groups.google.com/d/topic/de.comp.text.tex/oPeLOjkrLfk}}.
% While it has grown in the meanwhile and now provides some more advanced
% features, it still is only intended to quickly provide text. If you want more
% features, look at the \pkg{blindtext}-package.
%
% \subsection{Package Options}
% \label{sec:pkg-opt}
%
% \pkg{lipsum} outputs a range of paragraphs taken from the \lips\ dummy
% text. The package options control mainly the behaviour of the
% \cs{lipsum} and \cs{unpacklipsum} commands, and can be set at
% load-time with \cs{usepackage}|[|\meta{option}|]{lipsum}|, or later in
% the document by using \cs{setlipsum}|{|\meta{option}|}|.
%
% \begingroup
%   \RenewDocumentCommand \item { r[] e= d() }
%     {\par\medskip\noindent\llap
%       {\smash{\begin{tabular}{@{}l@{}}\toprule
%         \opt{#1}\\\bottomrule\end{tabular}}~~}%^^A
%      \IfValueT{#2}{=~~\!\meta{#2}\hfill
%        \IfValueT{#3}{\quad(default: \texttt{#3})}\null
%        \newline}\ignorespaces}
%
% \item[nopar]={boolean}(false)
%   Changes the initial default separator between each paragraph of
%   \cs{lipsum} from \cs{par} to \cs{space}, and the other way around
%   for \cs{lipsum*}.
% \item[text]={name}(lipsum)
%   Selects the dummy text \meta{name} that is used by \cs{lipsum} and
%   \cs{unpacklipsum} \secref{sec:other-texts}.
% \item[language]={lang}(latin)
%   Sets the language to be used by \cs{lipsum} to typeset the currently
%   active dummy text \secref{sec:hyphenation}.  Changing the dummy text
%   with the \opt{text} option will also change the current
%   \opt{language}.
% \item[auto-lang]={boolean}(true)
%   Turns on/off automatic language switching.  This changed since
%   version 2.3, in which this option (didn't exist thus) was |false| by
%   default.  See section~\ref{sec:hyphenation} for more details.
% \item[default-range]={p_i\texttt{-}p_f}(1-7)
%   Sets the default range of paragraphs produced by \cs{lipsum} when no
%   optional argument is provided.  The value to \opt{default-range}
%   obeys the \meta{range} syntax described in
%   section~\ref{sec:range-syntax}.  If no value is given to
%   \opt{default-range} (that is, \cs{setlipsum}|{default-range}|), then
%   the default is reset to |1-7|.
%
% \endgroup
%
% \medskip
%
% Besides these options, there are still ones that can be passed to the
% package to influence the paragraph and sentence separators and other
% such things.  These options are detailed in
% section~\ref{sec:separators}.
%
%^^A Besides the listed options, there are still options that can be
%^^A passed to the package to influence the paragraph and sentence
%^^A separators and other things like that.  The options for paragraphs
%^^A are:
%^^A \AddToHookNext{env/multicols/before}
%^^A   {\setlength{\multicolsep}{0.5\multicolsep}}
%^^A \begin{multicols}{2}
%^^A   \ttfamily \setlist{nosep}
%^^A   \begin{itemize}
%^^A     \item par-before
%^^A     \item par-begin
%^^A     \item par-sep
%^^A     \item par-end
%^^A     \item par-after
%^^A   \end{itemize}
%^^A   \begin{itemize}
%^^A     \item par-before*
%^^A     \item par-begin*
%^^A     \item par-sep*
%^^A     \item par-end*
%^^A     \item par-after*
%^^A   \end{itemize}
%^^A \end{multicols}
%^^A and for sentences, the same group with |sentence| instead of |par|
%^^A in their name.  These options are detailed in
%^^A section~\ref{sec:separators}.
%
% \subsection{User Commands}
%
% \begin{function}{\lipsum}
%   \begin{syntax}
%     \cs{lipsum}\meta{*}\oarg{par range}\oarg{sentence range}
%   \end{syntax}
%   \cs{lipsum} outputs the \meta{par range} from the
%   currently active dummy text.  If \meta{par range} is not given
%   or is empty, the \opt{default-range} (initially |1-7|) is output.
%   ^^A
%   If a \meta{sentence range} is given, the selected paragraphs are
%   split into sentences, numbered starting from~1, and the specified
%   range of sentences is taken out from those paragraphs.
%   ^^A
%   If the \meta{*} version is used, a different set of separators is
%   inserted around the paragraphs or sentences.
%
%   \cs{lipsum} changes the active language to that of the dummy text
%   for typesetting, so the proper hyphenation patterns are used.
%   See section~\ref{sec:hyphenation}.
%   ^^A
%   Section~\ref{sec:range-syntax} explains the syntax of ranges, and
%   section~\ref{sec:separators} explains the separators added around
%   the pieces of text.
% \end{function}
%
% \begin{function}{\unpacklipsum,\lipsumexp}
%   \begin{syntax}
%     \cs{unpacklipsum}\meta{*}\oarg{par range}\oarg{sentence range}
%     \ldots
%     \cs{lipsumexp}
%   \end{syntax}
%   \cs{unpacklipsum} selects the paragraphs and/or sentences exactly as
%   described for \cs{lipsum}, but instead of outputting them, it saves
%   the selected text in the \cs{lipsumexp} macro. Additionally,
%   \cs{unpacklipsum} \ldots\cs{lipsumexp} is not completely equivalent
%   to \cs{lipsum} because it doesn't change languages as \cs{lipsum}
%   does.
% \end{function}
%
% \begin{function}{\setlipsum}
%   \begin{syntax}
%     \cs{setlipsum}\Arg{key-val list}
%   \end{syntax}
%   Applies the \meta{key-val list} of options to the package.  The
%   options are described in section~\ref{sec:pkg-opt} and in
%   section~\ref{sec:separators}.
% \end{function}
%
% \subsection{Other commands}
%
% These commands exist for necessity or backwards comatibility, and
% should normally not be needed in user documents.
%
% \begin{function}{\SetLipsumText}
%   \begin{syntax}
%     \cs{SetLipsumDefault}\Arg{name}
%   \end{syntax}
%   Loads the dummy text \meta{name} \secref{sec:other-texts}.
%   This command does the same as option \opt{text}, but it is
%   kept for backwards compatibility.
% \end{function}
%
% \begin{function}{\SetLipsumDefault}
%   \begin{syntax}
%     \cs{SetLipsumDefault}\Arg{range}
%   \end{syntax}
%   Sets the default range for \cs{lipsum} and \cs{unpacklipsum}.
%   This command does the same as option \opt{default-range}, but it is
%   kept for backwards compatibility.
% \end{function}
%
% \section{General remarks on behaviour}
%
% Here are some topics that are general considerations about the
% behaviour of \pkg{lipsum} and its commands.  These are technicalities
% that most end users don't care too much about, unless you are trying
% to do something beyond the usual ``print me some dummy text''.
%
% \subsection{Syntax of paragraph and sentence ranges}
% \label{sec:range-syntax}
%
% A \meta{range} argument can either be blank, a single integer, or a
% proper integer range.  If the \meta{range} argument is blank, the
% commands behave as if the argument was not given at all.  For example,
% |\lipsum[]| behaves exaclty like |\lipsum| and outputs the default
% paragraph range.  Note that |\lipsum[][2-5]| does \textbf{not} behave
% as |\lipsum[2-5]|, but behaves as |\lipsum[1-7][2-5]| (assuming
% |default=range=1-7|), because the default value is then taken for the
% first argument.  If the \meta{range} argument is an integer, then only
% a single paragraph/sentence is selected.
%
% If the argument contains a |-| (\textsc{ascii}~45), it is interpreted
% as a \emph{proper} range \meta{n_i}|-|\meta{n_f}.  In a proper range,
% if \meta{n_i} is blank, it is taken to be the start of the possible
% range, and in the same way, if \meta{n_f} is empty it is taken to be
% the end of the possible range.  That is, |\lipsum[-9]| is the same as
% |\lipsum[1-9]|, and |\lipsum[5-]| is the same (assuming the standard
% 150-paragraph dummy text) as |\lipsum[5-150]|, and similarly,
% |\lipsum[-]| is the same as |\lipsum[1-150]|.
%
% Only one |-| is allowed in a range, so if more than one |-| is given,
% an error is raised and no paragraphs/sentences are output.  No
% paragraphs or sentences will be output also in case one of the ranges
% is reversed, so |\lipsum[2-1]| returns no paragraphs, as does
% |\lipsum[][2-1]| output no sentences, for example.  Note that
% ``returning no paragraphs/sentences'' is not ``the output is empty'':
% that is mostly true, except that the |-before| and |-after| separators
% are still output \secref{sec:separators}.
%
% Finally, if a range spans more paragraphs or sentences than what the
% dummy text actually provides, the range is truncated so that it fits
% the available text.  If the range in the argument does not intersect
% with the range provided by the dummy text, no paragraphs or sentences
% are output.
%
% \subsection{Hyphenation patterns}
% \label{sec:hyphenation}
%
% Since version~2.4, the command \cs{lipsum} automatically changes the
% hyphenation patterns when typesetting a dummy text, so that
% line-breaking looks better \secref{sec:foreword2.4}.  This feature is
% on by default, so if you need the old behaviour you have to explicitly
% disable automatic language switching with
% |\setlipsum{auto-lang=false}|.
%
% The language is defined individually for each dummy text
% \secref{sec:other-texts}, but you may change it for the current dummy
% text by using |\setlipsum{language=|\meta{lang}|}|.  If you load
% another dummy text (for example with the \opt{text} option), then the
% option \opt{language} is also changed according to the dummy text
% loaded \secref{sec:other-texts}.
%
% \subsection{Paragraph and sentence separators}
% \label{sec:separators}
%
% As may be clear by now, \pkg{lipsum} has two modes of operation:
% sentence output, and paragraph output, selected by providing or not
% providing the second optional argument to \cs{lipsum}.  In each mode,
% the dummy text is separated into chunks (paragraphs or sentences),
% which are counted, and then output accordingly.
%
% When \cs{lipsum} (or \cs{unpacklipsum}) is used with a single (or no)
% optional argument, then a range of paragraphs is output, along with
% some ``separators'' (in the lack of a better name) between paragraphs,
% around each paragraph, and before and after the whole output.
% A schematic (very colorful, because I couldn't find a better visual)
% representation of the output is:
%
% \begin{function}{
%     par-before,
%     par-begin,
%     par-sep,
%     par-end,
%     par-after,
%     sentence-before,
%     sentence-begin,
%     sentence-sep,
%     sentence-end,
%     sentence-after,
%   }
% \noindent
% \begin{tikzpicture}[x=0.703cm,
%     item/.style={
%       draw,
%       rounded corners=2mm,
%       minimum width=2.2cm,
%       execute at begin node=\strut,
%       rotate=54,
%       font=\footnotesize,
%     },
%   ]
%   \def\sep#1{\texttt{par-\textbf{#1}}\null}
%   \node [item,fill=red!40  ] at (0 ,0) {\sep{before}};
%   \node [item,fill=red!20  ] at (1 ,0) {\sep{begin }};
%   \node [item,fill=red!20  ] at (2 ,0) {\meta{paragraph}};
%   \node [item,fill=red!20  ] at (3 ,0) {\sep{end \  }};
%   \node [item,shading=axis,left color=red!30,right color=green!30,
%            shading angle=54] at (4 ,0) {\sep{sep \  }};
%   \node [item,fill=green!20] at (5 ,0) {\sep{begin }};
%   \node [item,fill=green!20] at (6 ,0) {\meta{paragraph}};
%   \node [item,fill=green!20] at (7 ,0) {\sep{end \  }};
%   \node [item,shading=axis,left color=green!30,right color=blue!30,
%            shading angle=54] at (8 ,0) {\sep{sep \  }};
%   \node [item,fill=blue!20 ] at (9 ,0) {\sep{begin }};
%   \node [item,fill=blue!20 ] at (10,0) {\meta{paragraph}};
%   \node [item,fill=blue!20 ] at (11,0) {\sep{end \  }};
%   \node [item,fill=blue!40 ] at (12,0) {\sep{after\ }};
% \end{tikzpicture}
%
% When \cs{lipsum} is called, the first thing it outputs is the
% \opt{par-before} tokens.  These tokens are output unconditionally,
% regardless of how many (if any) paragraph is output.
%
% Then, before each paragraph in the range, \cs{lipsum} outputs the
% \opt{par-begin} tokens, and then the actual text of the
% \meta{paragraph}, and then the \opt{par-end} tokens.  These tokens are
% output conditionally, if the paragraph text is output.  If more than
% one paragraph is output, then the \opt{par-sep} tokens are inserted
% between the \opt{par-end} of one paragraph and the \opt{par-begin} of
% the paragraph that follows.
%
% \end{function}
%
% Finally, at the end, the \opt{par-after} tokens are inserted
% unconditionally at the end, same as for \opt{par-before}.
%
% As mentioned before, in case of an error parsing the range, the output
% will be no paragraphs, but the \opt{par-before} and \opt{par-after}
% tokens are still output.
%
% The explanation above is equally valid for the starred variants.  If
% \cs{lipsum}|*| is used, the \opt{par-before*} tokens are
% inserted, and so on.  It is also true for sentences (starred or
% otherwise), replacing |par| in the option names by |sentence|, so when
% you use, for example, |\lipsum[][1-9]|, the \opt{sentence-before}
% tokens will be unconditionally inserted, and so on.
%
% Note that, when \cs{lipsum} is used in sentence-mode (for example,
% with |\lipsum[1-3][1-9]|), only the |sentence-...| tokens are inserted
% in the output, regardless of how many paragraphs those sentences were
% collected from. In the same way, if paragraph-mode is being used, only
% |par-...| tokens are inserted.
%
% \subsubsection{Deprecated command-based syntax}
%
% Older versions of \pkg{lipsum} (from 2.0 to 2.3) provided~10 CamelCase
% commands for changing the separators, but the syntax was rather
% cumbersome to use, so the keyval syntax presented thus far was
% introduced in the hopes of making things a bit easier.  The old
% commands will still exist for some time in the package, but with a
% deprecation warning.  Changing to the keyval syntax is advised, so
% here is a correspondence table between the old and new syntaxes:
%
% \begin{center}
%   \ttfamily \makeatletter
%   \definecolor{a}{HTML}{E0211A}\colorlet{a}{a!60!black}
%   \definecolor{b}{HTML}{5970D5}\colorlet{b}{b!60!black}
%   \protected@edef\x#1#2{\string\SetLipsum
%     {\color{a}#1}List{\color{b}#2}}%
%   \def\y#1#2{{\color{a}#1}-{\color{b}#2}}
%   \begin{tabular}{@{}ll@{}}
%     \toprule
%       \textrm{Old command}      & \textrm{New key name} \\
%     \midrule
%       \x{Par}{Start}              & \y{par}{before}      \\
%       \x{Par}{ItemStart}          & \y{par}{begin}       \\
%       \x{Par}{ItemSeparator}      & \y{par}{sep}         \\
%       \x{Par}{ItemEnd}            & \y{par}{end}         \\
%       \x{Par}{End}                & \y{par}{after}       \\
%       \x{Sentence}{Start}         & \y{sentence}{before} \\
%       \x{Sentence}{ItemStart}     & \y{sentence}{begin}  \\
%       \x{Sentence}{ItemSeparator} & \y{sentence}{sep}    \\
%       \x{Sentence}{ItemEnd}       & \y{sentence}{end}    \\
%       \x{Sentence}{End}           & \y{sentence}{after}  \\
%     \bottomrule
%   \end{tabular}
% \end{center}
%
% Additionally, the command-based interface provided shortcuts
% |\SetLipsum|\meta{Thing}|List|(|Item|)|Surrounders|, which are
% equivalent to just using the commands
% |\SetLipsum|\meta{Thing}|List|(|Item|)|Start| then |\...End|.  These
% don't provide any functionality, other than requiring a little less
% typing, so no key-val alternative was implemented.
% The |\...|\meta{Thing}|...Surrounders| commands should be replaced by
% \meta{thing}|-before| and \meta{thing}|-after|, and the
% |\...|\meta{Thing}|...ItemSurrounders| commands should be replaced by
% \meta{thing}|-begin| and \meta{thing}|-end|, as in the correspondence
% table below:
%
% \begin{center}
%   \ttfamily \makeatletter
%   \definecolor{a}{HTML}{E0211A}\colorlet{a}{a!60!black}
%   \definecolor{b}{HTML}{5970D5}\colorlet{b}{b!60!black}
%   \protected@edef\x#1#2{\string\SetLipsum
%     {\color{a}#1}List{\color{b}#2}Surrounders%^^A
%      \kern .5\tabcolsep \xleaders\hbox{\vrule
%          width 2pt height \dimexpr .5ex+.4pt\relax depth -.5ex
%          \kern 2pt}%
%        \hskip 0pt plus 1filll \kern -.5\tabcolsep
%      \raise.5ex\rlap{\kern.5\tabcolsep
%        \vrule width \tabcolsep height 0.4pt depth 0pt
%        \kern-0.5\tabcolsep
%        \smash{\vrule depth \normalbaselineskip width 0.4pt
%          \raise-\normalbaselineskip
%            \hbox{\vrule width .5\tabcolsep height 0.4pt depth 0pt}}}}%
%   \def\y#1#2{{\color{a}#1}-{\color{b}#2}}
%   \begin{tabular}{@{}ll@{}}
%     \toprule
%       \textrm{Old command} & \textrm{New key names} \\
%     \midrule
%       \x{Par}{}          & \y{par}{}before      \\
%                          & \y{par}{}after       \\
%       \x{Par}{Item}      & \y{par}{begin}       \\
%                          & \y{par}{end}         \\
%       \x{Sentence}{}     & \y{sentence}{}before \\
%                          & \y{sentence}{}after  \\
%       \x{Sentence}{Item} & \y{sentence}{begin}  \\
%                          & \y{sentence}{end}    \\
%     \bottomrule
%   \end{tabular}
% \end{center}
%
% \section{Loading and defining dummy texts}
% \label{sec:other-texts}
%
% Starting with \pkg{lipsum} v2.2, a simple interface is provided to
% define and load other texts for the output of \cs{lipsum} and friends.
% This interface can, for example, be used to implement dummy texts in
% different languages without re-coding the logic implemented by
% \pkg{lipsum}.
%
% \begin{function}{\NewLipsumPar}
%   \begin{syntax}
%     \cs{NewLipsumPar}\Arg{paragraph}
%   \end{syntax}
%   In order to provide a new text that will be used by \pkg{lipsum},
%   define the text by using a set of \cs{NewLipsumPar}\Arg{paragraph}
%   commands in a file with the ending |.ltd.tex| (|ltd| means
%   \emph{lipsum text definition}\footnotemark{}) to a location where
%   your \TeX{} system will find it. The \meta{paragraph}-argument is a
%   single paragraph of the new text. Thus, the first occurence of
%   \cs{NewLipsumPar} defines the first paragraph, the second occurence
%   the second paragraph and so on.
% \end{function}
% \footnotetext{To avoid name clashes with files using general languages
% as names, I chose to introduce the |.ltd.tex| file ending. I did not
% find a file with this ending in my |texmf|-tree, so I guess it is
% safe.}
%
% \begin{function}{\SetLipsumLanguage}
%   \begin{syntax}
%     \cs{SetLipsumLanguage}\Arg{lang}
%   \end{syntax}
%   Additionally, tell \pkg{lipsum} the language of the dummy text using
%   \cs{SetLipsumLanguage}\Arg{lang} somewhere in the |.ltd.tex| file.
% \end{function}
%
% \medskip
%
% To specify the new text as output for \cs{lipsum} and friends, use
% \cs{setlipsum}|{|\opt{text}|=|\meta{name}|}|, where \meta{name} is the
% name of the file without the ending |.ltd.tex|, as given in the table
% below.  When a new dummy text is loaded, the previous one is cleared,
% and the language is changed as well, according to the table.
%
% \begin{table}[ht]
% \begin{wide}
% \begin{tabularx}{\textwidth}{lllX}
%   \toprule
%     File (\texttt{.ltd.tex}) & Language & Source & Description \\
%   \midrule
%     \texttt{lipsum} & Latin
%       & James Wilson
%         & Contains the standard \emph{Lorem ipsum} dummy text,
%           obtained from \url{https://www.lipsum.com} (default). \\
%     \texttt{cicero} & Latin
%       & GH user \href{https://github.com/svenper}{svenper}
%         & Contains the speech by Cicero which inspired the \lips{}
%           dummy text. \\
%     \texttt{lipsum-cs} & Czech
%       & Ondřej Macek
%         & Lipsum dummy text in the Czech language, obtained from
%           Petr Staníček's website:
%             \url{https://www.wellstyled.com/tools/dummy-cz}. \\
%   \bottomrule
% \end{tabularx}
% \end{wide}
% \end{table}
%
% \subsection{Guidelines on providing new dummy texts}
%
% \cs{SetLipsumText} more or less just uses an \cs{input} or, to be more
% precise, the \LaTeX3-variant \cs{file_input:n}, to load the |.ltd.tex|
% file. This means, that the file is not necessarily loaded in the
% preamble of the document and thus the contents of the file underlie
% the respective restrictions.
%
% Should you want a new dummy text, create an issue in the GitHub
% repository\footnote{\url{https://github.com/PhelypeOleinik/lipsum}}
% with the source for the dummy text.
%
% Should you prefer to distribute the dummy text as a separate package,
% make sure that the text follows the layout of \pkg{lipsum}'s dummy
% texts, so that everything works correctly.  The dummy text definition
% file should contain a line with \cs{SetLipsumLanguage}, and then as
% many \cs{NewLipsumPar} entries as there are paragraphs in the dummy
% text.  Make sure that the file has the |.ltd.tex| extension, and
% everything should work smoothly.
%
% \end{documentation}
%
% \clearpage
% \newgeometry{left=5cm,right=2cm}
%
% \begin{implementation}
%
% \section{\pkg{lipsum} Implementation}
%
%    \begin{macrocode}
%<*package>
%<@@=lipsum>
%    \end{macrocode}
%
% \subsection{Variables}
%
% \begin{variable}{\g_@@_par_int}
%   Stores the number of paragraphs in the current text.
%    \begin{macrocode}
\int_new:N \g_@@_par_int
%    \end{macrocode}
% \end{variable}
%
% \begin{variable}{\g_@@_language_tl}
%   Stores the language of the dummy text for hyphenation patterns.
%    \begin{macrocode}
\tl_new:N \g_@@_language_tl
%    \end{macrocode}
% \end{variable}
%
% \begin{variable}[int]{\g_lipsum_default_range_tl}
%   The default range for lipsum paragraphs.
%    \begin{macrocode}
\tl_new:N \g_lipsum_default_range_tl
%    \end{macrocode}
% \end{variable}
%
% \begin{variable}{\l_@@_output_tl}
%   This variables is used to store the token list containing the
%   selected output.
%    \begin{macrocode}
\tl_new:N \l_@@_output_tl
%    \end{macrocode}
% \end{variable}
%
% \begin{variable}{\g_@@_text_str}
%   Holds the current text loaded for the output of \cs{lipsum} and
%   friends. Used to avoid loading the same text definition if it is
%   already used.
%    \begin{macrocode}
\str_new:N \g_@@_text_str
%    \end{macrocode}
% \end{variable}
%
% \begin{variable}{\l_@@_sep_set_str}
%   Holds the name of the active separator token set.  By default it is
%   empty to use the default separator set (empty).
%    \begin{macrocode}
\str_new:N \l_@@_sep_set_str
%    \end{macrocode}
% \end{variable}
%
% \begin{variable}{\l_@@_autolang_bool}
%   Boolean whether to change hyphenation patterns according to the
%   dummy text language.
%    \begin{macrocode}
\bool_new:N \l_@@_autolang_bool
%    \end{macrocode}
% \end{variable}
%
% \begin{variable}{\q_@@_mark,\s_@@}
%   Quark and scan mark used throughout the package.
%    \begin{macrocode}
\quark_new:N \q_@@_mark
\scan_new:N \s_@@
%    \end{macrocode}
% \end{variable}
%
% \begin{variable}{\l_@@_tmpa_str,\l_@@_a_int,\l_@@_b_int}
%   Scratch variables.
%    \begin{macrocode}
\str_new:N \l_@@_tmpa_str
\int_new:N \l_@@_a_int
\int_new:N \l_@@_b_int
%    \end{macrocode}
% \end{variable}
%
% \begin{macro}{\@@_tmp:w}
%   Scratch macro.
%    \begin{macrocode}
\cs_new_eq:NN \@@_tmp:w ?
%    \end{macrocode}
% \end{macro}
%
% \begin{variable}{\l_@@_<thing>_<place>_<version>_tl}
%   \csname @gobble\endcsname{
%     \l_@@_par_end_nostar_tl,
%     \l_@@_par_end_star_tl,
%     \l_@@_par_end__tl,
%     \l_@@_par_itemend_nostar_tl,
%     \l_@@_par_itemend_star_tl,
%     \l_@@_par_itemend__tl,
%     \l_@@_par_itemseparator_nostar_tl,
%     \l_@@_par_itemseparator_star_tl,
%     \l_@@_par_itemseparator__tl,
%     \l_@@_par_itemstart_nostar_tl,
%     \l_@@_par_itemstart_star_tl,
%     \l_@@_par_itemstart__tl,
%     \l_@@_par_start_nostar_tl,
%     \l_@@_par_start_star_tl,
%     \l_@@_par_start__tl,
%     \l_@@_sentence_end_nostar_tl,
%     \l_@@_sentence_end_star_tl,
%     \l_@@_sentence_end__tl,
%     \l_@@_sentence_itemend_nostar_tl,
%     \l_@@_sentence_itemend_star_tl,
%     \l_@@_sentence_itemend__tl,
%     \l_@@_sentence_itemseparator_nostar_tl,
%     \l_@@_sentence_itemseparator_star_tl,
%     \l_@@_sentence_itemseparator__tl,
%     \l_@@_sentence_itemstart_nostar_tl,
%     \l_@@_sentence_itemstart_star_tl,
%     \l_@@_sentence_itemstart__tl,
%     \l_@@_sentence_start_nostar_tl,
%     \l_@@_sentence_start_star_tl,
%     \l_@@_sentence_start__tl,
%   }
%   These variables store the separators and delimiters added around the
%   paragraphs and sentences, in the starred or nonstarred variants, as
%   well as the generic version for runtime usage.
%    \begin{macrocode}
\clist_map_inline:nn { start, itemstart, itemseparator, itemend, end }
  {
    \clist_map_inline:nn { par, sentence }
      {
        \clist_map_inline:nn { { }, star, nostar }
          { \tl_new:c { l_@@_##1_#1_####1_tl } }
      }
    \tl_new:c { l_@@_par_#1_parsepar_tl }
  }
\tl_set:Nn \l_@@_par_itemseparator_parsepar_tl { ~ }
%    \end{macrocode}
% \end{variable}
%
% \subsection{Developer interface}
%
% \begin{macro}{\@@_parse_par_range:nNN,\@@_parse_par_range:eNN}
% \begin{macro}{\@@_parse_sentence_range:nNN,\@@_parse_sentence_range:eNN}
% \begin{macro}{\@@_parse_range_arg:nNNn,\@@_parse_range_arg:wnNNn}
% \begin{macro}{\@@_int_set:Nnn}
%   Parses an argument that may be a single integer or an integer range
%   separated by a |-|, and stores them into the integer registers |#2|
%   and |#3|.  If a number is blank, zero is used.  If only a single
%   number is given, |#3| is set equal to |#2|.
%    \begin{macrocode}
\cs_new_protected:Npn \@@_parse_par_range:nNN #1 #2 #3
  {
    \tl_if_blank:nTF {#1}
      { \exp_args:NV \@@_parse_range_arg:nNNn \g_lipsum_default_range_tl }
      { \@@_parse_range_arg:nNNn {#1} }
          #2 #3 { \g_@@_par_int }
  }
\cs_new_protected:Npn \@@_parse_sentence_range:nNN #1 #2 #3
  { \@@_parse_range_arg:nNNn {#1} #2 #3 { \c_max_int } }
\cs_new_protected:Npn \@@_parse_range_arg:nNNn #1
  {
    \exp_last_unbraced:No \@@_parse_range_arg:wnNNn
      \tl_to_str:n { #1 - - } \s_@@ {#1}
  }
\cs_new_protected:Npn \@@_parse_range_arg:wnNNn
    #1 - #2 - #3 \s_@@ #4 #5#6 #7
  {
    \str_if_eq:nnTF {#3} { - }
      {
        \@@_int_set:Nnn #5 {#1} { 1 }
        \@@_int_set:Nnn #6 {#2} {#7}
      }
      {
        \tl_if_empty:nTF {#3}
          {
            \@@_int_set:Nnn #5 {#1} { \ERROR }
            \int_set_eq:NN #6 #5
          }
          {
            \msg_error:nnn { lipsum } { invalid-range } {#4}
            \@@_parse_range_arg:nNNn { 2 - 1 } #5 #6 {#7}
          }
      }
  }
\cs_new_protected:Npn \@@_int_set:Nnn #1 #2 #3
  { \int_set:Nn #1 { \tl_if_blank:nT {#2} {#3} #2 } }
\cs_generate_variant:Nn \@@_parse_par_range:nNN { e }
\cs_generate_variant:Nn \@@_parse_sentence_range:nNN { e }
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@@_sep_item:nn}
%   A shorthand to leave an (\cs{undexpanded}) token list.
%    \begin{macrocode}
\cs_new:Npn \@@_sep_item:nn #1 #2
  { \exp_not:v { l_@@_#1_#2_ \l_@@_sep_set_str _tl } }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]{\lipsum_get_range:nn}
% \begin{macro}{
%     \@@_build_list:nn,
%     \@@_build_list_aux:n,
%     \@@_get_paragraph:ww,
%     \@@_get_paragraph_end:w,
%   }
%   Expands to the paragraphs between \meta{number_1} and
%   \meta{number_2} with the proper delimiters added.  Text is returned
%   in \cs{exp_not:n}, so this macro can be safely used in an \cs{edef}.
%    \begin{macrocode}
\cs_new:Npn \lipsum_get_range:nn #1 #2
  {
    \@@_sep_item:nn { par } { start }
    \use:e
      {
        \exp_not:N \@@_get_paragraph:ww
        \@@_build_list:nn {#1} {#2}
        \exp_not:N \q_@@_mark ;
        \exp_not:N \q_@@_mark ; \s_@@
      }
    \@@_sep_item:nn { par } { end }
  }
\cs_new:Npn \@@_build_list:nn #1 #2
  {
    \int_step_function:nnN
      { \int_max:nn {#1} { 1 } }
      { \int_min:nn {#2} { \g_@@_par_int } }
      \@@_build_list_aux:n
  }
\cs_new:Npn \@@_build_list_aux:n #1 { #1 ; }
\cs_new:Npn \@@_get_paragraph:ww #1 ; #2 ;
  {
    \if_meaning:w \q_@@_mark #2
      \if_meaning:w \q_@@_mark #1
        \@@_get_paragraph_end:w
      \else:
        \lipsum_get_paragraph:n {#1}
      \fi:
    \else:
      \lipsum_get_paragraph:n {#1}
      \@@_sep_item:nn { par } { itemseparator }
    \fi:
    \@@_get_paragraph:ww #2 ;
  }
\cs_new:Npn \@@_get_paragraph_end:w #1 \s_@@ { \fi: \fi: }
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}[int]{\lipsum_get_paragraph:n}
%   Expands to the paragraph \meta{number} with the proper delimiters
%   added.  Text is returned in \cs{exp_not:n}, so this macro can be
%   safely used in an \cs{edef}.
%    \begin{macrocode}
\cs_new:Npn \lipsum_get_paragraph:n #1
  {
    \@@_sep_item:nn { par } { itemstart }
    \@@_unexpanded_par:n {#1}
    \@@_sep_item:nn { par } { itemend }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_unexpanded_par:n}
%   Expands to the paragraph \meta{number} wrapped in \cs{exp_not:n}.
%   If \meta{number} is out of range, it expands to nothing.
%    \begin{macrocode}
\cs_new:Npn \@@_unexpanded_par:n #1
  {
    \bool_lazy_and:nnT
        { \int_compare_p:nNn { 0 } < {#1} }
        { \int_compare_p:nNn {#1}  < { \g_@@_par_int + 1 } }
      { \exp_not:v { g_@@_par_#1_tl } }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]{\lipsum_get_sentences:nnn,\lipsum_get_sentences:nnV}
% \begin{macro}{\@@_get_sentences:nnnw,\@@_get_sentences_end:w}
%   Expands to the sentences numbered between \meta{number_1} and
%   \meta{number_2}, inclusive, contained in the \meta{text}, and adding
%   the proper separators.
%    \begin{macrocode}
\cs_new:Npn \lipsum_get_sentences:nnn #1 #2 #3
  {
    \@@_sep_item:nn { sentence } { start }
    \exp_args:Ne \use_ii_i:nn { { \int_max:nn {#1} { 1 } } }
      { \@@_get_sentences:nnnw { 1 } } {#2}
      #3 ~ \q_@@_mark .~ \s_@@
    \@@_sep_item:nn { sentence } { end }
  }
\cs_new:Npn \@@_get_sentences:nnnw #1 #2 #3 #4 .~
  {
    \int_compare:nNnT {#1} > {#3} { \@@_get_sentences_end:w }
    \use:nn { \if_meaning:w \q_@@_mark } #4
      \exp_after:wN \@@_get_sentences_end:w
    \else:
      \int_compare:nNnF {#1} < {#2}
        {
          \int_compare:nNnF {#1} = {#2}
            { \@@_sep_item:nn { sentence } { itemseparator } }
          \@@_sep_item:nn { sentence } { itemstart }
          \exp_not:n { #4 . }
          \@@_sep_item:nn { sentence } { itemend }
        }
    \fi:
    \exp_args:Nf \@@_get_sentences:nnnw { \int_eval:n { #1 + 1 } }
      {#2} {#3}
  }
\cs_new:Npn \@@_get_sentences_end:w #1 \s_@@ { }
\cs_generate_variant:Nn \lipsum_get_sentences:nnn { nnV }
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \subsection{User- and developer-level commands}
%
% \begin{macro}[int]{\LipsumPar}
%   Macro to typeset a single paragraph of \lips\ Was not officially
%   available in version prior to 2.0.
%   \begin{arguments}
%     \item Number of the paragraph to typeset.
%   \end{arguments}
% Implemented as follows:
%    \begin{macrocode}
\NewDocumentCommand \LipsumPar { m }
  {
    \@@_deprecated:n { LipsumPar }
    \@@_unexpanded_par:n {#1} \par
  }
%    \end{macrocode}
% \end{macro}
%
% \subsection{Tokens surrounding the \lips\ content}
%
% \begin{macro}{\@@_element_set:nnn}
%   A general macro for setting starred/non-starred versions of several
%   elements used between chunks of dummy text. Arguments are:
%   \begin{arguments}
%     \item Element name;
%     \item Boolean true or false if the |*| variant was used;
%     \item Value to set the element to.
%   \end{arguments}
%    \begin{macrocode}
\cs_new_protected:Npn \@@_element_set:nnn #1 #2 #3
  { \tl_set:cn { l_@@_ #1 _ \IfBooleanF {#2} { no } star _tl } {#3} }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_deprecated:n}
%   Warns about deprecated commands and destroys itself.
%    \begin{macrocode}
\cs_new_protected:Npn \@@_deprecated:n #1
  {
    \msg_warning:nnn { lipsum } { cmd-deprecated } {#1}
    \cs_gset_eq:NN \@@_deprecated:n \use_none:n
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[int]{
%     \SetLipsumParListStart,
%     \SetLipsumParListEnd,
%     \SetLipsumParListSurrounders,
%     \SetLipsumParListItemSeparator,
%     \SetLipsumParListItemStart,
%     \SetLipsumParListItemEnd,
%     \SetLipsumParListItemSurrounders,
%     \SetLipsumSentenceListStart,
%     \SetLipsumSentenceListEnd,
%     \SetLipsumSentenceListSurrounders,
%     \SetLipsumSentenceListItemSeparator,
%     \SetLipsumSentenceListItemStart,
%     \SetLipsumSentenceListItemEnd,
%     \SetLipsumSentenceListItemSurrounders,
%   }
%   A dirty loop to quickly define the old command-based user-interface.
%    \begin{macrocode}
\cs_set_protected:Npn \@@_tmp:w #1 #2 #3 #4
  {
    \str_set:Nx \l_@@_tmpa_str
      { #2 \tl_if_empty:nTF {#4} {#3} { start } }
    \use:e
      {
        \NewDocumentCommand \exp_not:c { SetLipsum #1 List #2 #3 }
            { s +m \tl_if_empty:nF {#4} { +m } }
          {
            \@@_deprecated:n { SetLipsum #1 List #2 #3 }
            \@@_element_set:nnn
              { \exp_args:Ne \str_lowercase:n { #1_\l_@@_tmpa_str } }
              {##1} {##2}
            \tl_if_empty:nT {#4} { \use_none:nnnn }
            \@@_element_set:nnn { \str_lowercase:n { #1_#2 #4 } }
              {##1} {##3}
          }
      }
  }
\clist_map_inline:nn { Par, Sentence }
  {
    \clist_map_inline:nn
      { { Start } { }, { End } { }, { Surrounders } { end } }
      { \@@_tmp:w {#1} { Item } ##1 \@@_tmp:w {#1} { } ##1 }
    \@@_tmp:w {#1} { Item } { Separator } { }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\SetLipsumDefault}
%   Command to change the default range used by \cs{lipsum} and friends.
%   \begin{arguments}
%     \item[\meta{range}] Range to be used as default.
%   \end{arguments}
% Implemented as:
%    \begin{macrocode}
\NewDocumentCommand \SetLipsumDefault { m }
  {
    \@@_parse_par_range:eNN {#1} \l_@@_a_int \l_@@_b_int
    \tl_gset:Nx \g_lipsum_default_range_tl
      { \int_use:N \l_@@_a_int - \int_use:N \l_@@_b_int }
  }
%    \end{macrocode}
% \end{macro}
%
% The following macros are considered to be user-level commands and thus
% all lower-case.
%
% \begin{macro}{\lipsum}
%   \begin{arguments}
%     \item Range-like string that specifies the number of the
%       paragraphs taken from \lips\ If omitted, the value set by
%       \cs{SetLipsumDefault} is used, which defaults to |1-7|.
%     \item Sentences to be typeset from the range selected by
%       \meta{paragraph range}. If sentences outside the number of
%       sentences in \meta{paragraph range} are specified, only existing
%       sentences are typeset.
%   \end{arguments}
%   The difference between \cs{lipsum} and \cs{lipsum*} is the token(s)
%   that are inserted after each paragraph (only if called without the
%   second optional argument).
%
%   \cs{lipsum} and \cs{unpacklipsum} have the same interface and do
%   almost the same thing, so both are implemented using a common macro
%   \cs{@@_do:nnnn} that does the heavy-lifting, and at the end
%   executes the code in |#4|.
%    \begin{macrocode}
\NewDocumentCommand \lipsum { s O { \g_lipsum_default_range_tl } o }
  {
    \@@_do:nnnn {#1} {#2} {#3}
      {
        \@@_set_hyphens:
        \tl_use:N ##1
        \@@_restore_hyphens:
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\unpacklipsum,\lipsumexp}
%   This command does the same as \cs{lipsum}, but instead of
%   typesetting the paragraphs or sentences, it stores the expanded
%   content in the \cs{lipsumexp} token list. The tokens between items
%   of the list, set, for example, by using the package option
%   \opt{space} or by using the \cs{SetLipsum...List} commands, are
%   |x|-expanded.
%    \begin{macrocode}
\NewDocumentCommand \unpacklipsum { s O { \g_lipsum_default_range_tl } o }
  { \@@_do:nnnn {#1} {#2} {#3} { \tl_gset_eq:NN \lipsumexp ##1 } }
\cs_new_eq:NN \lipsumexp \prg_do_nothing:
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_do:nnnn}
% \begin{macro}{\@@_do:N}
%   This is the main macro for \cs{lipsum} and \cs{unpacklipsum}.
%   It parses the paragraph range, sets the sentence/paragraph
%   separators, then acts accordingly if a sentence range was provided.
%    \begin{macrocode}
\cs_new_protected:Npn \@@_do:nnnn #1 #2 #3 #4
  {
    \cs_set_protected:Npn \@@_do:N ##1 {#4}
    \@@_parse_par_range:eNN {#2} \l_@@_a_int \l_@@_b_int
    \str_set_eq:NN \l_@@_tmpa_str \l_@@_sep_set_str
    \str_set:Nx \l_@@_sep_set_str { \IfBooleanF {#1} { no } star }
    \bool_lazy_or:nnTF
        { \tl_if_novalue_p:n {#3} }
        { \tl_if_blank_p:n {#3} }
      {
        \tl_set:Nx \l_@@_output_tl
          { \lipsum_get_range:nn { \l_@@_a_int } { \l_@@_b_int } }
      }
      {
        \str_set:Nn \l_@@_sep_set_str { parsepar }
        \tl_set:Nx \l_@@_output_tl
          { \lipsum_get_range:nn { \l_@@_a_int } { \l_@@_b_int } }
        \str_set:Nx \l_@@_sep_set_str { \IfBooleanF {#1} { no } star }
        \@@_parse_sentence_range:eNN {#3} \l_@@_a_int \l_@@_b_int
        \tl_set:Nx \l_@@_output_tl
          {
            \lipsum_get_sentences:nnV { \l_@@_a_int } { \l_@@_b_int }
              \l_@@_output_tl
          }
      }
    \str_set_eq:NN \l_@@_sep_set_str \l_@@_tmpa_str
    \@@_do:N \l_@@_output_tl
  }
\cs_new_eq:NN \@@_do:N ?
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\@@_set_hyphens:,\@@_restore_hyphens:}
%   Selects the hyphenation patterns for the language of the dummy text,
%   using \cs{hyphenrules} if that's defined.  If \cs{hyphenrules}
%   doesn't exist try setting hyphenation with \cs{@@_set_hyphens_raw:}.
%   Each \cs[no-index]{@@_set_hyphens_\meta{method}:} function
%   appropriately redefines \cs{@@_restore_hypehens:} to reset the
%   hyphenation patterns.
%    \begin{macrocode}
\cs_new_protected:Npn \@@_set_hyphens:
  {
    \bool_if:NTF \l_@@_autolang_bool
      { \use:n } { \use_none:n }
      {
        \cs_if_exist:NTF \hyphenrules
          {
            \cs_if_exist:cTF { ver@polyglossia.sty }
              { \@@_set_hyphens_polyglossia: }
              { \@@_set_hyphens_babel: }
          }
          { \@@_set_hyphens_raw: }
      }
  }
\cs_new_protected:Npn \@@_restore_hyphens:
  { \prg_do_nothing: }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_set_hyphens_babel:}
%   \pkg{babel} makes things pretty simple.  We just check if
%   \cs[no-index]{l@\meta{lang}} is defined, and if so, use
%   \cs{hyphenrules} to set it, and once more to reset in
%   \cs{@@_restore_hyphens:}.  \cs{hyphenrules} is actually an
%   environment, but in \pkg{babel} its \cs[no-index]{end} part does
%   nothing, and its effect can be undone by just using another
%   \cs{hyphenrules} on top of it.
%
%   If the language is not defined, the language either doesn't exist at
%   all, or we are using Lua\TeX.  Both cases are handled by
%   \cs{@@_lang_not_available:}.
%    \begin{macrocode}
\cs_new_protected:Npn \@@_set_hyphens_babel:
  {
    \cs_if_exist:cTF { l@ \g_@@_language_tl }
      {
        \exp_args:NV \hyphenrules \g_@@_language_tl
        \cs_set_protected:Npx \@@_restore_hyphens:
          { \exp_not:N \hyphenrules { \languagename } }
      }
      { \@@_lang_not_available: }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_set_hyphens_polyglossia:}
%   \pkg{polyglossia} less friendly.  We also check if the language is
%   loaded (looking at \cs[no-index]{\meta{lang}@loaded}), and if it
%   is, load it with the \env{hyphenrules} environment.  Here we can't
%   use the command form, as the \cs[no-index]{end} part is not a no-op.
%   This also means that an extra group is added around the dummy text,
%   which causes issue \ghissue{1} when used with \pkg{wrapfig}, for
%   example.  But not too much we can do about that for now.
%
%   In case the language is not loaded, fall back to
%   \cs{@@_set_hyphens_raw:} for a final attempt before giving up.
%    \begin{macrocode}
\cs_new_protected:Npn \@@_set_hyphens_polyglossia:
  {
    \cs_if_exist:cTF { \g_@@_language_tl @loaded }
      {
        \exp_args:NnV \begin{hyphenrules} \g_@@_language_tl
        \cs_set_protected:Npn \@@_restore_hyphens:
          { \end{hyphenrules} }
      }
      { \@@_set_hyphens_raw: }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_set_hyphens_raw:}
%   If nothing else is available, try setting the language using
%   \cs{language}\meta{number}.  This is always available,
%   except with Lua\TeX, which loads languages on-the-fly.
%    \begin{macrocode}
\cs_new_protected:Npn \@@_set_hyphens_raw:
  {
    \cs_if_exist:cTF { l@ \g_@@_language_tl }
      {
        \use:x
          {
            \language \use:c { l@ \g_@@_language_tl }
            \cs_set_protected:Npn \@@_restore_hyphens:
              { \language \int_eval:n { \language } \scan_stop: }
          }
      }
      { \@@_lang_not_available: }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_lang_not_available:}
%   If the requested language is for some reason unavailable, warn the
%   user, then fall back to the current language.
%    \begin{macrocode}
\cs_new_protected:Npn \@@_lang_not_available:
  {
    \msg_warning:nnx { lipsum } { missing-language }
      { \g_@@_language_tl }
    \tl_gset_eq:NN \g_@@_language_tl \languagename
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\NewLipsumPar}
%   Developer-Level macro to add a paragraph to the dummy text used by
%   \cs{lipsum} and related commands. To specify a new dummy text, see
%   section~\ref{sec:other-texts}.
%    \begin{macrocode}
\cs_new_protected:Npn \NewLipsumPar #1
  {
    \int_gincr:N \g_@@_par_int
    \tl_gclear_new:c { g_@@_par_ \int_use:N \g_@@_par_int _tl }
    \tl_gset:cn { g_@@_par_ \int_use:N \g_@@_par_int _tl } {#1}
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\SetLipsumText}
%   Used to select and load the text output by \cs{lipsum} and friends.
%   See the section on loading and defining new outputs for \cs{lipsum}
%   (section~\ref{sec:other-texts}). It first checks whether the
%   requested text is already loaded, and if not, it loads the
%   corresponding lipsum text definition file, and clears remaining
%   paragraphs from the previous text, in case their lengths differ.
%    \begin{macrocode}
\NewDocumentCommand \SetLipsumText { m }
  {
    \str_if_eq:VnF \g_@@_text_str {#1}
      {
        \tl_gset:Nn \g_@@_language_tl { english }
        \int_gzero:N \g_@@_par_int
        \file_input:n { #1.ltd }
        \str_gset:Nn \g_@@_text_str {#1}
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\SetLipsumLanguage}
%   This macro sets the language for hyphenation patterns of the dummy
%   text.  When a new lipsum text is read, this is reset.
%    \begin{macrocode}
\NewDocumentCommand \SetLipsumLanguage { m }
  { \tl_gset:Nn \g_@@_language_tl {#1} }
%    \end{macrocode}
% \end{macro}
%
% \subsection{Package options and defaults}
%
% \begin{macro}[int]{
%     \LipsumRestoreParList,
%     \LipsumRestoreSentenceList,
%     \LipsumRestoreAll,
%   }
% \begin{macro}{\@@_delim_restore:nnn}
% \begin{macro}{\@@_restore_par_list:,\@@_restore_sentence_list:}
%   These are some auxiliaries for the package options and for setting
%   up the default behaviour.
%    \begin{macrocode}
\cs_new_protected:Npn \@@_delim_restore:nnn #1 #2 #3
  {
    \keys_set:nn { lipsum }
      {
        #1-before  = , #1-begin  = , #1-end  = , #1-after  = ,
        #1-before* = , #1-begin* = , #1-end* = , #1-after* = ,
        #1-sep = {#2}, #1-sep* = {#3}
      }
  }
\cs_new_protected:Nn \@@_restore_sentence_list:
  { \@@_delim_restore:nnn { sentence } { ~ } { ~ } }
\cs_new_eq:NN \@@_restore_par_list: ?
\cs_new_protected:Npn \LipsumRestoreParList
  {
    \@@_deprecated:n { LipsumRestoreParList }
    \@@_restore_par_list:
  }
\cs_new_protected:Npn \LipsumRestoreSentenceList
  {
    \@@_deprecated:n { LipsumRestoreSentenceList }
    \@@_restore_sentence_list:
  }
\cs_new_protected:Npn \LipsumRestoreAll
  {
    \@@_deprecated:n { LipsumRestoreAll }
    \@@_restore_par_list: \@@_restore_sentence_list:
  }
%    \end{macrocode}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\setlipsum}
%   Here are the options available at load-time and to \cs{setlipsum}.
%    \begin{macrocode}
\NewDocumentCommand \setlipsum { +m }
  { \keys_set:nn { lipsum } {#1} }
\keys_define:nn { lipsum }
  {
%    \end{macrocode}
%   \opt{nopar} is implemented as a choice key instead of a boolean so
%   we can update the separators using \cs{@@_delim_restore:nnn}.
%   It's initially false, and the default is |true| so that
%   |\usepackage[nopar]{lipsum}| works as it always did.
%    \begin{macrocode}
    nopar .choice: ,
    nopar / true .code:n =
      {
        \cs_gset_protected:Npn \@@_restore_par_list:
          { \@@_delim_restore:nnn { par } { ~ } { \par } }
      } ,
    nopar / false .code:n =
      {
        \cs_gset_protected:Nn \@@_restore_par_list:
          { \@@_delim_restore:nnn { par } { \par } { ~ } }
      } ,
    nopar .initial:n = false ,
    nopar .default:n = true  ,
%    \end{macrocode}
%   \opt{auto-lang} sets \cs{l_@@_autolang_bool}.  It is initially
%   |true|, changing the default behaviour from previous versions.
%    \begin{macrocode}
    auto-lang .bool_set:N = \l_@@_autolang_bool ,
    auto-lang .initial:n = true ,
    auto-lang .default:n = true ,
%    \end{macrocode}
%   \opt{text} just does \cs{SetLipsumText}.  The |initial| value is not
%   set here because this chunk of code is executed in \pkg{expl3}
%   syntax, then thetextloadswithoutspaces, so |\setlipsum{text=lipsum}|
%   is used later.
%    \begin{macrocode}
    text .code:n = \SetLipsumText{#1} ,
    text .value_required:n = true ,
%    \end{macrocode}
%   \opt{language} sets the language to be used when typesetting.
%    \begin{macrocode}
    language .tl_gset:N = \g_@@_language_tl ,
    language .value_required:n = true ,
%    \end{macrocode}
%   \opt{default-range} does \cs{SetLipsumDefault}, initially |1-7|, as
%   documented.  It's default is also |1-7| so that the key has two
%   meanings: \cs{setlipsum}|{default-range=|\meta{range}|}| sets the
%   range to the given value, while \cs{setlipsum}|{default-range}| sets
%   the range to the ``default default range''.  Pretty neat :)
%    \begin{macrocode}
    default-range .code:n = \SetLipsumDefault{#1} ,
    default-range .initial:n = 1-7 ,
    default-range .default:n = 1-7 ,
  }
%    \end{macrocode}
%   This chunk defines the keys \meta{thing}-\meta{place}[*], where
%   \meta{thing} is |par| or |sentence|, \meta{place} is |before|,
%   |begin|, |sep|, |end|, and |after|, which totals~10 keys, and
%   another~10 with the |*| in the name.  Each sets a token list called
%   \cs[no-index]{l_@@_\meta{thing}_\meta{place}_[no]star_tl}.
%    \begin{macrocode}
\cs_set_protected:Npn \@@_tmp:w #1 #2 #3
  {
    \keys_define:nn { lipsum }
      {
        #1-before #2 .tl_set:c = l_@@_#1_start         _#3star_tl ,
        #1-begin  #2 .tl_set:c = l_@@_#1_itemstart     _#3star_tl ,
        #1-sep    #2 .tl_set:c = l_@@_#1_itemseparator _#3star_tl ,
        #1-end    #2 .tl_set:c = l_@@_#1_itemend       _#3star_tl ,
        #1-after  #2 .tl_set:c = l_@@_#1_end           _#3star_tl ,
      }
  }
\@@_tmp:w { par } { } { no } \@@_tmp:w { sentence } { } { no }
\@@_tmp:w { par }  *  {    } \@@_tmp:w { sentence }  *  {    }
%    \end{macrocode}
% \end{macro}
%
% Now turn \cs{ExplSyntaxOff} for a while, and load the default \lips{}
% text, then process the package options, and finally turn
% \cs{ExplSyntaxOn} again.  Finally, call \cs{@@_restore_par_list:} and
% \cs{@@_restore_sentence_list:} to set the defaults
% (\cs{@@_restore_par_list:} may have been redefined by \opt{nopar}).
%    \begin{macrocode}
\ExplSyntaxOff
\setlipsum{text=lipsum}
\ProcessKeysOptions{lipsum}
\ExplSyntaxOn
\@@_restore_par_list:
\@@_restore_sentence_list:
%    \end{macrocode}
%
% \subsection{Messages}
%
% Now define the messages used throughout the package.
%    \begin{macrocode}
\msg_new:nnn { lipsum } { invalid-range }
  { Invalid~number~or~range~'#1'. }
\msg_new:nnn { lipsum } { cmd-deprecated }
  {
    Command~'\iow_char:N\\#1'~deprecated. \\
    See~the~lipsum~documentation~for~help.
  }
\msg_new:nnn { lipsum } { missing-language }
  {
    Unknown~language~'#1'.~Hyphenation~patterns~for~
    '\languagename'~will~be~used~instead.
    \sys_if_engine_luatex:T
      {
        \\ \\
        \cs_if_exist:cTF { ver@polyglossia.sty }
          {
            With~polyglossia,~you~have~to~explicitly~load~languages~
            with~\iow_char:N\\setotherlanguage{#1}~or~similar.
          }
          {
            With~LuaTeX,~lipsum~requires~babel~to~get~proper~
            hyphenation~(you~can~use~
            \iow_char:N\\usepackage[base]{babel}).
          }
      }
  }
%    \end{macrocode}
%
%    \begin{macrocode}
%</package>
%    \end{macrocode}
%
% \end{implementation}
%
% \endinput
% Local Variables:
% mode: doctex
% TeX-master: t
% End: