summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/zhlipsum/zhlipsum.dtx
blob: f6e0c1b118191247d7672fcfcc8f1d1174ea3389 (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
% \iffalse meta-comment
%
% Copyright (C) 2017--2020 by Xiangdong Zeng <xdzeng96@gmail.com>
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License, either
% version 1.3c 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.
%
% This work has the LPPL maintenance status `maintained'.
%
% The Current Maintainer of this work is Xiangdong Zeng.
%
% This work consists of the files zhlipsum.dtx,
%                                 zhlipsum-text.dtx,
%           and the derived files zhlipsum.ins,
%                                 zhlipsum.sty,
%                                 zhlipsum-utf8.def,
%                                 zhlipsum-gbk.def,
%                                 zhlipsum-big5.def,
%                                 zhlipsum-en.tex,
%                                 zhlipsum.pdf,
%                                 zhlipsum-en.pdf,
%                             and README.md.
%
%<*internal>
\iffalse
%</internal>
%
%<*readme>
The `zhlipsum` package
======================

The `zhlipsum` package provides an interface to dummy text in
Chinese language, which will be useful for testing Chinese
documents.

`zhlipsum` supports UTF-8, GBK and Big5 encodings.

Basic usage
-----------

    \zhlipsum
    \zhlipsum*[1-5]
    \zhlipsum[6-10,18][name=trad]

More information can be found in the package documentation
[zhlipsum.pdf](http://mirror.ctan.org/macros/latex/contrib/zhlipsum/zhlipsum.pdf)
(Chinese version) or [zhlipsum-en.pdf](http://mirror.ctan.org/macros/latex/contrib/zhlipsum/zhlipsum-en.pdf)
(English version).

Installation
------------

To install `zhlipsum`, you can use one of the following methods:

- If you are running TeX Live, the simplest way is to run

      tlmgr install zhlipsum

- Download
  [zhlipsum.tds.zip](http://mirror.ctan.org/install/macros/latex/contrib/zhlipsum.tds.zip)
  from CTAN, extract it in the root of one of your TDS trees, and
  update the filename database.

Contributing
------------

[Issues](https://github.com/stone-zeng/zhlipsum/issues) and
[pull requests](https://github.com/stone-zeng/zhlipsum/pulls)
are always welcome.

License
-------

This work may be distributed and/or modified under the conditions of
the [LaTeX Project Public License](http://www.latex-project.org/lppl.txt),
either version 1.3c of this license or (at your option) any later
version.

-----

Copyright (C) 2017&ndash;2020 by Xiangdong Zeng <xdzeng96@gmail.com>.
%</readme>
%
%<*internal>
\fi
\begingroup
  \def\NameOfLaTeXe{LaTeX2e}
\expandafter\endgroup\ifx\NameOfLaTeXe\fmtname\else
\csname fi\endcsname
%</internal>
%
%<*install>
\input ctxdocstrip.tex
\keepsilent

\preamble

    Copyright (C) 2017--2020 by Xiangdong Zeng <xdzeng96@gmail.com>

    This work may be distributed and/or modified under the
    conditions of the LaTeX Project Public License, either
    version 1.3c 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.

    This work has the LPPL maintenance status `maintained'.

    The Current Maintainer of this work is Xiangdong Zeng.

    This work consists of the files zhlipsum.dtx,
                                    zhlipsum-text.dtx,
              and the derived files zhlipsum.ins,
                                    zhlipsum.sty,
                                    zhlipsum-utf8.def,
                                    zhlipsum-gbk.def,
                                    zhlipsum-big5.def,
                                    zhlipsum-en.tex,
                                    zhlipsum.pdf,
                                    zhlipsum-en.pdf,
                                and README.md.

\endpreamble

\generate{
  \usedir{tex/latex/zhlipsum}
    \file{\jobname.sty}      {\from{\jobname.dtx}{package}}
    \file{\jobname-utf8.def} {\from{\jobname.dtx}{text,utf8}
                              \from{\jobname-text.dtx}{text,utf8}}
    \file{\jobname-gbk.def}  {\from{\jobname.dtx}{text,gbk}
                              \from{\jobname-text.dtx}{text,gbk}}
    \file{\jobname-big5.def} {\from{\jobname.dtx}{text,big5}
                              \from{\jobname-text.dtx}{text,big5}}
%</install>
%<*internal>
  \usedir{source/latex/zhlipsum}
    \file{\jobname.ins}      {\from{\jobname.dtx}{install}}
%</internal>
%<*install>
  \usedir{doc/latex/zhlipsum}
  \nopreamble\nopostamble
    \file{README.md}         {\from{\jobname.dtx}{readme}}
}

\obeyspaces
\Msg{****************************************************}
\Msg{*                                                  *}
\Msg{* To finish the installation you have to move the  *}
\Msg{* following file into a directory searched by TeX: *}
\Msg{*                                                  *}
\Msg{*     zhlipsum.sty                                 *}
\Msg{*     zhlipsum-utf8.def                            *}
\Msg{*     zhlipsum-gbk.def                             *}
\Msg{*     zhlipsum-big5.def                            *}
\Msg{*                                                  *}
\Msg{* The recommended directory is                     *}
\Msg{*   TDS:tex/latex/zhlipsum                         *}
\Msg{*                                                  *}
\Msg{* To produce the documentation run the file        *}
\Msg{* zhlipsum.dtx through XeLaTeX.                    *}
\Msg{*                                                  *}
\Msg{* Happy TeXing!                                    *}
\Msg{*                                                  *}
\Msg{****************************************************}

\endbatchfile
%</install>
%
%<*internal>
\fi
%</internal>
%
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\RequirePackage{expl3}
%<*!(driver|install)>
%<!readme>\GetIdInfo $Id: zhlipsum.dtx 1.2.0 2020-04-10 12:00:00Z Xiangdong Zeng <xdzeng96@gmail.com> $
%<package>  {Chinese dummy text}
%<package>\ProvidesExplPackage{\ExplFileName}
%<utf8>  {Chinese dummy text with UTF-8 encoding (for zhlipsum)}
%<utf8>\ProvidesExplFile{\ExplFileName-utf8.def}
%<gbk>  {Chinese dummy text with GBK encoding (for zhlipsum)}
%<gbk>\ProvidesExplFile{\ExplFileName-gbk.def}
%<big5>  {Chinese dummy text with Big5 encoding (for zhlipsum)}
%<big5>\ProvidesExplFile{\ExplFileName-big5.def}
%<!readme>  {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
%</!(driver|install)>
%<*driver>
%^^A! \PassOptionsToPackage{scheme=plain, linespread=1.1}{ctex}
%^^A+
\documentclass{ctxdoc}
\usepackage{multirow}
\setCJKmainfont{Source Han Serif SC}[ItalicFont=Kaiti SC]
\setCJKmonofont{STFangsong}[ItalicFont=Kaiti SC]
%^^A-
\hypersetup{%
  pdftitle={zhlipsum: 中文乱数假文(Lorem ipsum)},
  pdfauthor={曾祥东},
  bookmarksnumbered=true
}
%^^A! \hypersetup{%
%^^A!   pdftitle={zhlipsum: Chinese dummy text},
%^^A!   pdfauthor={Xiangdong Zeng},
%^^A!   bookmarksnumbered=true
%^^A! }
%^^A! \ctexset{%
%^^A!   section={name={}, format+=\raggedright},
%^^A!   subsubsection/tocline={\CTEXnumberline{#1}#2}
%^^A! }
%^^A! \pagestyle{headings}
%^^A+
% Use `!` for comment in `ctexexam`.
\catcode`!=\active
\RecustomVerbatimEnvironment{ctexexam}{Verbatim}{%
  frame=single, framesep=10pt,
%^^A-
  gobble=4,
  label=\rule{0pt}{12pt}\textnormal{\bfseries 例 \arabic{ctexexam}},
  defineactive=\def!{\color{gray}\%},
%^^A!   gobble=2,
%^^A!   label=\rule{0pt}{12pt}\textnormal{\bfseries Example \arabic{ctexexam}},
%^^A!   defineactive=\def!{\color{gray}\itshape\%},
%^^A+
  listparameters=%
    \setlength\topsep{\bigskipamount}%
    \refstepcounter{ctexexam}\ctexexamlabelref}
\preto\ctexexam{\catcode`!=\active}
\preto\endctexexam{\catcode`!=12}
\catcode`!=12
% Do not add hyperlink for `TF`, and do not change color.
\ExplSyntaxOn
\cs_set_protected:Npn \__codedoc_typeset_TF:
  {
    \group_begin:
      \exp_args:No \__codedoc_if_macro_internal:nT \l__codedoc_tmpa_tl
        { \color[gray]{0.5} }
      \itshape TF
      \makebox[0pt][r]
        {
          \color{red}
          \underline{\phantom{\itshape TF} \kern-0.1em}
        }
    \group_end:
  }
\ExplSyntaxOff
\makeatother
\RenewDocumentEnvironment{arguments}{}%
  {\enumerate[label={\texttt{\#\arabic*:~}},
    leftmargin=2em, labelsep=0pt, nolistsep]}%
  {\endenumerate}
%^^A-
\def\IndexLayout{%
  \newgeometry{hmargin=1.00in, vmargin={1.25in, 1.00in}}%
  \ctexset{section/numbering=false}%
  \StopSpecialIndexModule}
\DoNotIndex{\\}
\begin{document}
  \DocInput{\jobname.dtx}
  \IndexLayout
  \PrintChanges
  \PrintIndex
\end{document}
%</driver>
% \fi
%
% \changes{v0.1}{2017/04/08}{开始编写宏包。}
% \changes{v0.2}{2017/04/14}{仿照 \pkg{kantlipsum} 宏包,实现
%   任意的段落选取。}
% \changes{v0.2}{2017/04/14}{使用名字空间。}
% \changes{v0.4}{2017/09/16}{将安装、测试文件集成进源文件。}
% \changes{v0.4}{2017/09/16}{优化宏包实现。}
% \changes{v0.5}{2018/01/06}{添加英文版用户文档。}
% \changes{v1.1.1}{2018/09/08}{完善持续集成系统,在多平台上进行测试。}
%
% \CheckSum{0}
%
% \CharacterTable
%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%   Digits        \0\1\2\3\4\5\6\7\8\9
%   Exclamation   \!     Double quote  \"     Hash (number) \#
%   Dollar        \$     Percent       \%     Ampersand     \&
%   Acute accent  \'     Left paren    \(     Right paren   \)
%   Asterisk      \*     Plus          \+     Comma         \,
%   Minus         \-     Point         \.     Solidus       \/
%   Colon         \:     Semicolon     \;     Less than     \<
%   Equals        \=     Greater than  \>     Question mark \?
%   Commercial at \@     Left bracket  \[     Backslash     \\
%   Right bracket \]     Circumflex    \^     Underscore    \_
%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%   Right brace   \}     Tilde         \~}
%
% \title{\textbf{zhlipsum: 中文乱数假文(Lorem ipsum)}}
% \author{曾祥东}
% \date{2020/04/10 \quad v1.2.0^^A
%   \thanks{\url{https://github.com/stone-zeng/zhlipsum}.}}
%^^A! \title{\textbf{The \pkg{zhlipsum} Package: Chinese Dummy Text}}
%^^A! \author{Xiangdong Zeng}
%^^A! \date{2020/04/10 \quad v1.2.0%
%^^A!   \thanks{\url{https://github.com/stone-zeng/zhlipsum}.}}
%^^A!
%
%^^A 标题页页边距
% \newgeometry{hmargin={1.25in, 1.25in}, vmargin={1.25in, 1.00in}}
%
%^^A! \begin{document}
%^^A!
%
% \maketitle
%
% \begin{minipage}{0.9\textwidth}
% \small \itshape
% \mbox{} \par \mbox{} \par
% \qquad 如彭奇和瓦特曼的公共事业所证实的那样有一个胡子雪雪白的上帝超
% 越时间超越空间确确实实存在他在神圣的冷漠神圣的疯狂神圣的喑哑的高处深
% 深地爱着我们除了少数的例外不知什么原因但时间将会揭示他像神圣的密兰达
% 一样和人们一起忍受着痛苦这班人不知什么原因但时间将会揭示生活在痛苦中
% 生活在烈火中这烈火这火焰如果继续燃烧毫无疑问将使穹苍着火也就是说将地
% 狱炸上天去天是那么蓝那么澄澈那么平静这种平静尽管时断时续总比没有好得
% 多但是别这么快还要进一步考虑到泰斯丢和丘那德的人体测定学院的未完成的
% 研究结果早已断定毫无疑问换句话说除了依附着人类的疑问之外别无其他疑问
% 根据泰斯丢和丘那德的未完成的劳动的结果早已作出如下的论断但是别这么快
% 不知什么原因根据彭奇和瓦特曼的公共事业的结果已毫无疑问地断定鉴于波波
% 夫和贝尔契不知什么原因未完成的劳动以及泰斯丢和丘那德的未完成的劳动已
% 经就业已被许多人所否认的论点作出论断认为泰斯丢和丘那德所假设的人认为
% 实际存在的人认为人类总而言之统而言之尽管有进步的营养学和通大便药却在
% 衰弱萎缩衰弱萎缩而且与此同时尤其是不知什么原因尽管体育运动在各方面都
% 有很大进展如网球足球田径车赛游泳飞行划船骑马滑翔溜冰各式各样的网球各
% 种各样致人死命的飞行运动各式各样的秋天夏天冬天冬天网球各种各样的曲棍
% 球盘尼西林和代用品总之我接下去讲与此同时不知什么原因要萎缩要减少尽管
% 有网球我接下去讲飞行滑翔九穴和十八穴的高尔夫球各种各样的网球总之不知
% 什么原因在番克汉贝克汉福尔汉克莱普汉换句话说与此同时尤其是不知什么原
% 因但时间将会揭示要减少减少我接下去讲福尔汉克莱普汉总之自从塞缪尔·约
% 翰逊去世以后到现在每个人的全部损失共计每人一吋四唡只是大概约略粗粗计
% 算到小数点分量很足保持整数赤裸裸的光穿着袜子在康纳马拉总之不知什么原
% 因不管怎样无论如何事实俱在尤其是考虑到更加远为严肃的看来更加严肃的鉴
% 于斯丹威格和彼特曼的徒劳看来更加严肃的鉴于鉴于鉴于斯丹威格和彼特曼徒
% 劳在平原在山地在海洋在烈火沸腾的河里天空是一样的随后是大地换句话说天
% 空随后是大地在一片寒冷一片漆黑中天空大地石头的住所在一片寒冷中哎哟哟
% 在我们的主诞生六百年左右天空大地海洋大地石头的住所汪洋中一片寒冷中在
% 海上在陆地在空中我接下去讲不知什么原因尽管有网球事实俱在但时间将会揭
% 示我接下去讲哎哟哟总之一句话石头的住所谁能怀疑我接下去讲但是别这么快
% 我接下去讲头颅要萎缩衰弱减少与此同时尤其是不知什么原因尽管有网球胡子
% 火焰球队石头那么蓝那么平静哎哟哟头颅头颅头颅头颅在康纳马拉尽管有网球
% 未完成的徒然的劳动更加严肃的石头的住所总之我接下去讲哎哟哟徒劳的未完
% 成的头颅头颅在康纳马拉尽管有网球头颅哎哟石头丘那德(混战,最后的狂
% 喊)网球……石头……那么平静……丘那德……未完成的……
% \end{minipage}
%
% \begin{flushright}
%   \small \itshape ——萨缪尔·贝克特《等待戈多》
% \end{flushright}
%
%^^A 用户手册的页边距
%^^A+
% \newgeometry{%
%   hmargin={2.0in, 0.8in},
%   vmargin={1.2in, 1.0in},
%   marginpar=1.8in
% }
%^^A-
%^^A!
%
%^^A! \maketitle
%^^A!
%
% \section{简介}
%^^A! \section{Introduction}
%^^A!
%
% \pkg{zhlipsum} 宏包用于输入中文乱数假文(拉丁语为 \emph{Lorem
% ipsum})。乱数假文是大段无意义的文字,常用来测试排版效果。支持其他
% 语言乱数假文的宏包还有 \pkg{lipsum}、\pkg{kantlipsum}、
% \pkg{blindtext} 等。
%^^A! The \pkg{zhlipsum} package is used for typesetting dummy text
%^^A! (i.e.\ ``\emph{Lorem ipsum}'') as \pkg{lipsum},
%^^A! \pkg{kantlipsum}, \pkg{blindtext} etc., but for Chinese
%^^A! language. Dummy text will be pretty useful, for example, when
%^^A! testing fonts or page styles.
%^^A!
%
% \pkg{zhlipsum} 宏包支持 UTF-8、GBK 和 Big5 编码,依赖 \LaTeX3{} 项目
% 中的 \pkg{expl3}、\pkg{xparse} 和 \pkg{l3keys2e} 宏包。为正确输入中
% 文,\pkg{zhlipsum} 需要与 \pkg{CJK} 宏包或 \CTeX{} 宏集等配套使用。
%^^A! \pkg{zhlipsum} supports UTF-8, GBK and Big5 encodings. Packages
%^^A! \pkg{expl3}, \pkg{xparse} and \pkg{l3keys2e} in the \LaTeX3{}
%^^A! Project are required. To typeset Chinese properly, \pkg{zhlipsum}
%^^A! should be used with \pkg{CJK} package or \CTeX{} bundle.
%^^A!
%
% \section{使用说明} \label{sec:user-guide}
%^^A! \section{User's guide} \label{sec:user-guide}
%^^A!
%
%^^A+
% \begin{function}[added=2017-09-16,updated=2018-04-01]{encoding}
%   \begin{syntax}
%     encoding = <(utf8)|gbk|big5>
%   \end{syntax}
%^^A-
%   用于指定编码的宏包选项,可在调用宏包的时候设定。默认为
%   \opt{utf8}。对于 \XeLaTeX{}、\LuaLaTeX{} 和 \upLaTeX{} 等 Unicode
%   引擎,\opt{gbk} 和 \opt{big5} 编码无效,宏包将强制使用 \opt{utf8}
%   编码。
% \end{function}
%^^A!   Package option for selecting encoding. Default value is
%^^A!   \opt{utf8}. For Unicode engines as \XeLaTeX{}, \LuaLaTeX{} and
%^^A!   \upLaTeX{}, \opt{gbk} / \opt{big5} encodings are invalid and
%^^A!   \opt{utf8} will be used forcibly.
%^^A! \end{function}
%^^A!
%
% 如果使用了 \CTeX{} 宏集,则编码会根据 \CTeX{} 自动确定。但需注意,
% 在 \CTeX{} 宏集中,相应的宏包选项为大写的 \opt{UTF8} 和 \opt{GBK},
% 而本宏包中所有选项均为小写。
%^^A! If you have loaded \CTeX{} bundle, then the encoding will be
%^^A! selected automatically according to \CTeX{}. Note that in \CTeX{}
%^^A! bundle, the correspoding options are \opt{UTF8} and \opt{GBK},
%^^A! while the options in \pkg{zhlipsum} are all in \emph{lowercase}.
%^^A!
%
%^^A+
% \begin{function}[updated=2020-04-08]{\zhlipsum}
%^^A-
%   \begin{syntax}
%     \cs{zhlipsum}\oarg{段落}\oarg{选项}
%     \cs{zhlipsum}*\oarg{段落}\oarg{选项}
%   \end{syntax}
%   插入假文文本。参数 \meta{段落} 和 \meta{选项} 都是可选的。注意各
%   参数之间不可以有空格。
% \end{function}
%^^A!   \begin{syntax}
%^^A!     \cs{zhlipsum}\oarg{paragraph}\oarg{options}
%^^A!     \cs{zhlipsum*}\oarg{paragraph}\oarg{options}
%^^A!   \end{syntax}
%^^A!   Produce dummy text. Both arguments \meta{paragraph} and
%^^A!   \meta{options} are optional. Note that spaces are not allowed
%^^A!   between the arguments.
%^^A! \end{function}
%^^A!
%
% 默认情况下,不带星号的命令 \cs{zhlipsum} 会在假文段落之后与之间
% 进行分段(即插入 \tn{par}),而带星号的命令 \cs{zhlipsum}|*|
% 则不做额外处理。您可以利用后文给出的 \opt{before}、\opt{after}、
% \opt{inter} 选项来更改默认设置。
%^^A! By default, the \cs{zhlipsum} command will insert \tn{par}
%^^A! after and between dummy text paragraphs, while \cs{zhlipsum}|*|
%^^A! will not give any extra processing. To change the default
%^^A! behavior, you can use the \opt{before}, \opt{after} and
%^^A! \opt{inter} options described below.
%^^A!
%
% 第一个可选参数 \meta{段落} 为英文逗号分隔的段落编号列表,举例如下:
%^^A! The first optional argument \meta{paragraph} should be a comma
%^^A! list. It can be specified as the following:
%^^A!
%
% \begin{ctexexam}
%   ! 假设假文最大段落数为 50
%   \zhlipsum[2-4]          ! 可用 a-b 的形式指定
%   \zhlipsum[4,12,3-8]     ! 也可用单个数字指定
%   \zhlipsum[-10,40-]      ! 输出 1-10 段和 40-50 段
%   \zhlipsum[-]            ! 输出全部段落,即 1-50 段
%   \zhlipsum               ! 默认输出 1-3 段
%   \zhlipsum[48-52]        ! 超出部分会自动忽略,即只输出 48-50 段
% \end{ctexexam}
%^^A! \begin{ctexexam}
%^^A!   ! Suppose the dummy text has 50 paragraphs.
%^^A!   \zhlipsum[2-4]          ! Can be specified as a-b
%^^A!   \zhlipsum[4,12,3-8]     ! A single number is also acceptable
%^^A!   \zhlipsum[-10,40-]      ! Produce paragraphs 1-10 and 40-50
%^^A!   \zhlipsum[-]            ! Produce all paragraphs, i.e. 1-50
%^^A!   \zhlipsum               ! Default value is 1-3
%^^A!   \zhlipsum[48-52]        ! Numbers larger than 50 will not be considered
%^^A!                           ! i.e. only paragraphs 48-50 are produced
%^^A! \end{ctexexam}
%^^A!
%
% 第二个可选参数 \meta{选项} 通过英文逗号分隔的键值列表形式给出。
% 支持的选项见下。
%^^A! The second optional argument \meta{options} should be a
%^^A! key-value list. Supported options are the listed below.
%^^A!
%
%^^A+
% \begin{function}[added=2018-03-24]{name}
%^^A-
%   \begin{syntax}
%     name = \meta{假文名称}
%   \end{syntax}
%   选择插入假文的名称。预定义的假文共有 6 种,见表~^^A
%   \ref{tab:pre-defined-dummy-text}。当 |encoding=utf8| 或 |gbk| 时,
%   默认使用的假文为 |simp|;而当 |encoding=big5| 时,默认则为 |trad|。
% \end{function}
%^^A!   \begin{syntax}
%^^A!     name = \meta{name}
%^^A!   \end{syntax}
%^^A!   Select the name of the dummy text. There are 6 pre-defined
%^^A!   dummy texts described in table~\ref{tab:pre-defined-dummy-text}.
%^^A!   The default text is |simp| when |encoding=utf8| or |gbk|, but
%^^A!   |trad| when |encoding=big5|.
%^^A! \end{function}
%^^A!
%
%^^A+
% \begingroup
% \def\B{\bullet}
% \def\M#1{\multirow{2}*{\textbf{#1}}}
% \def\T#1{\textbf{#1}}
% \begin{table}[htb]
%^^A-
%   \caption{预定义假文} \label{tab:pre-defined-dummy-text}
%   \centering\small
%   \begin{tabular}{cccccccc}
%     \toprule
%       \M{名称} & \M{段落数} & \M{简体 / 繁体} & \M{描述} &
%         \multicolumn{3}{c}{\T{各编码下的支持情况}} \\
%       & & & & |utf8| & |gbk| & |big5| \\
%     \midrule
%       |simp|        &  50 & 简 & 无意义随机假文          & \B & \B &    \\
%       |trad|        &  50 & 繁 & 无意义随机假文          & \B & \B & \B \\
%       |nanshanjing| &  43 & 繁 & 《山海经·南山经》       & \B &    &    \\
%       |xiangyu|     &  45 & 繁 & 司马迁《史记·项羽本纪》 & \B & \B & \B \\
%       |zhufu|       & 110 & 简 & 鲁迅《祝福》            & \B & \B &    \\
%       |aspirin|     &  66 & 简 & 维基百科条目:阿司匹林  & \B & \B &    \\
%     \bottomrule
%   \end{tabular}
% \end{table}
% \endgroup
%^^A!   \caption{Pre-defined dummy texts} \label{tab:pre-defined-dummy-text}
%^^A!   \centering\scriptsize
%^^A!   \begin{tabular}{cccccccc}
%^^A!     \toprule
%^^A!       \M{Name} & \T{Paragraph} & \T{Simplified /} & \M{Description} &
%^^A!         \multicolumn{3}{c}{\T{Encodings' support}} \\
%^^A!       & \T{numbers} & \T{traditional} & & |utf8| & |gbk| & |big5| \\
%^^A!     \midrule
%^^A!       |simp|        &  50 & S & Random dummy text                         & \B & \B &    \\
%^^A!       |trad|        &  50 & T & Random dummy text                         & \B & \B & \B \\
%^^A!       |nanshanjing| &  43 & T & \emph{Shanhaijing: Nanshanjing}           & \B &    &    \\
%^^A!       |xiangyu|     &  45 & T & \emph{Shiji: Xiang Yu Benji} by Sima Qian & \B & \B & \B \\
%^^A!       |zhufu|       & 110 & S & \emph{Zhufu} by Lu Xun                    & \B & \B &    \\
%^^A!       |aspirin|     &  66 & S & Wikipedia: \emph{Aspirin}                 & \B & \B &    \\
%^^A!     \bottomrule
%^^A!   \end{tabular}
%^^A! \end{table}
%^^A! \endgroup
%^^A!
%
% 您也可以通过 \cs{newzhlipsum} 命令来定义新的假文。
%^^A! You can use \cs{newzhlipsum} command to define new dummy text
%^^A! as well.
%^^A!
%
%^^A+
% \begin{function}[added=2018-03-29]{before,after,inter}
%^^A-
%   \begin{syntax}
%     before = \meta{内容}
%     after  = \meta{内容}
%     inter  = \meta{内容}
%   \end{syntax}
%   在假文段落之前、之后与之间插入内容。注意使用不带星号的
%   \cs{zhlipsum} 命令时插入的分段命令会被这里的设置覆盖。
% \end{function}
%^^A!   \begin{syntax}
%^^A!     before = \meta{content}
%^^A!     after  = \meta{content}
%^^A!     inter  = \meta{content}
%^^A!   \end{syntax}
%^^A!   Insert contents before, after or between dummy text paragraphs.
%^^A!   Note that the \tn{par} command inserted when using \cs{zhlipsum}
%^^A!   will be overridden by the settings here.
%^^A! \end{function}
%^^A!
%
% \pagebreak[3]
%
%^^A+
% \begin{function}[added=2018-03-29]{\newzhlipsum}
%^^A-
%   \begin{syntax}
%     \cs{newzhlipsum}\Arg{假文名称}\Arg{段落列表}
%   \end{syntax}
%   声明新的假文。假文名称区分大小写。段落列表以英文逗号分隔,示例如下:
% \end{function}
%^^A!   \begin{syntax}
%^^A!     \cs{newzhlipsum}\Arg{name}\Arg{paragraphs list}
%^^A!   \end{syntax}
%^^A!   Declare new dummy text. The \meta{name} is case sensitive and
%^^A!   the \meta{paragraphs list} is a comma list. An example is
%^^A!   shown below:
%^^A! \end{function}
%^^A!
%
% \begin{ctexexam}
%   ! 注意区分中文逗号与英文逗号
%   \newzhlipsum{jingyesi}{!
%     {床前明月光,}, {疑是地上霜。}, {举头望明月,}, {低头思故乡。}}
%
%   \zhlipsum*[-][name=jingyesi]  ! 输出全部四句假文,且不分段
% \end{ctexexam}
%^^A! \begin{ctexexam}
%^^A!   ! Fullwidth comma `,' is used in Chinese language.
%^^A!   ! Normal comma `,' is used as separator.
%^^A!   \newzhlipsum{jingyesi}{!
%^^A!     {床前明月光,}, {疑是地上霜。}, {举头望明月,}, {低头思故乡。}}
%^^A!
%^^A!   \zhlipsum*[-][name=jingyesi]  ! Print all the four sentences without `\par'
%^^A! \end{ctexexam}
%^^A!
%
% \section{编程接口}
%^^A! \section{Programming interface}
%^^A!
%
% 一般而言,第~\ref{sec:user-guide} 节中列出的命令足够一般用户使用。
% 如需使用编程接口,则可以考虑以下变量和函数。注意使用时需确保开启
% \LaTeX3 语法。
%^^A! Usually, the commands provided in section~\ref{sec:user-guide}
%^^A! are sufficient for users. For programmers professional users,
%^^A! however, the programming interface is also necessary and provided
%^^A! here. \LaTeX3 syntax should be opened when using them.
%^^A!
%
%
%^^A+
% \begin{variable}{\g_zhlipsum_seq}
%^^A-
%   假文名称列表。
%\end{variable}
%^^A!   A sequence of dummy text names.
%^^A! \end{variable}
%^^A!
%
%^^A+
% \begin{function}{\zhlipsum_use:nn}
%^^A-
%   输出多段假文。
%   \begin{arguments}
%     \item 假文名称
%     \item 段落编号列表
%   \end{arguments}
% \end{function}
%^^A!   Produce some dummy text paragraphs.
%^^A!   \begin{arguments}
%^^A!     \item Name
%^^A!     \item Comma list of aragraph numbers.
%^^A!   \end{arguments}
%^^A! \end{function}
%^^A!
%
%^^A+
% \begin{function}[TF]{\zhlipsum_if_exist:n}
%^^A-
%   判断是否存在对应名称的假文。
%   \begin{arguments}
%     \item 假文名称
%   \end{arguments}
% \end{function}
%^^A!   Test whether the name has been used for dummy text。
%^^A!   \begin{arguments}
%^^A!     \item Name
%^^A!   \end{arguments}
%^^A! \end{function}
%^^A!
%
%^^A+
% \begin{function}{\zhlipsum_new:nn}
%^^A-
%   声明假文。
%   \begin{arguments}
%     \item 假文名称
%     \item 文本列表
%   \end{arguments}
% \end{function}
%^^A!   Declare dummy text.
%^^A!   \begin{arguments}
%^^A!     \item Name.
%^^A!     \item Comma list of texts.
%^^A!   \end{arguments}
%^^A! \end{function}
%^^A!
%
% \section{兼容性信息}
%^^A! \section{Compatibility information}
%^^A!
%
% 以下选项在测试版 \pkg{zhlipsum} 宏包中存在,但在 1.0.0 版本之后不
% 建议继续使用。这里仅为兼容性保留。未来将可能删除对它们的支持。
%^^A! The following option exists in the beta version of \pkg{zhlipsum}
%^^A! package, but has become deprecated after version 1.0.0. It is
%^^A! reserved only for compatibility and may be removed in the future.
%^^A!
%
% \begin{function}{script}
%   过时选项。现在相当于 \opt{name}。
% \end{function}
%^^A! \begin{function}{script}
%^^A!   Deprecated option. Now it's the same as \opt{name}.
%^^A! \end{function}
%^^A!
%
% \section{已知问题}
%^^A! \section{Known issues}
%^^A!
%
% 名称为 |nanshanjing| 和 |xiangyu| 的假文文本含有若干生僻字。如需正确
% 显示,可使用 \pkg{xeCJK} 宏包,并设置后备字体为 SimSun-ExtB、Hanazono
% Mincho (花园明朝)等,具体方法请参考 \pkg{xeCJK} 宏包文档(仅针对
% 编码为 UTF-8,且使用 \XeLaTeX{} 编译的情况)。
%^^A! Dummy text |nanshanjing| and |xiangyu| have some rarely used
%^^A! characters. To display them correctly, you can use the \pkg{xeCJK}
%^^A! package and set SimSun-ExtB or Hanazono Mincho as the fallback
%^^A! font. Refer to the \pkg{xeCJK}'s user guide for specific methods
%^^A! (only for UTF-8 encoding and \XeLaTeX{} engine).
%^^A!
%
% GBK 和 Big5 编码在第二字节并没有避开 ASCII 码的范围,因此部分汉字编
% 码的第二字节恰好是 ASCII 编码中的一些特殊字符(如 |{|、|}|、|\|
% 等),将导致编译失败。本宏包在这两种编码下的 \file{.def} 文件中采取
%了特殊技巧(见~\ref{subsec:dummy-text} 小节),请避免修改这些文件。
%^^A! GBK and Big5 encodings do not escape the ASCII range in the
%^^A! second byte, so the second byte of some Chinese characters may
%^^A! have the same encoding as special characters in ASCII like |{|,
%^^A! |}|, |\| etc., which will lead to compilation failure. The
%^^A! \file{.def} files in \pkg{zhlipsum} are created with special
%^^A! techniques. Please do not modify them.
%^^A!
%
% 如无特殊需要,始终建议您采用 UTF-8 编码,并使用 \XeLaTeX{}、
% \LuaLaTeX{} 等 Unicode 引擎编译。
%^^A! If there is no special requirement, UTF-8 encoding and Unicode
%^^A! engines as \XeLaTeX{} and \LuaLaTeX{} are always recommended.
%^^A!
%
% 特殊情况下,如果您必须使用 GBK 或 Big5 编码,并需要声明新的假文,
% 可以采取以下手段临时回避上述问题。
%^^A! In special cases, if you must use GBK or Big5 encoding and need
%^^A! to declare new dummy text, the following method can be taken in
%^^A! order to avoid the problem temporarily.
%^^A!
%
% \begin{ctexexam}
%   ! 文件编码需使用 Big5
%   ! \usepackage[encoding=big5]{zhlipsum}
%
%   ! 直接使用 \newzhlipsum{big5}{許蓋功, 蓋功許, 功許蓋} 会报错
%   ! 原理:分组内使用 < > + 代替 { } \ 后,再将原先的 { } \ 设为“其他”类(即
%   ! 类别码为 12)
%   \begingroup
%     \catcode`\<=1
%     \catcode`\>=2
%     \catcode`\+=0
%     \catcode`\{=12
%     \catcode`\}=12
%     \catcode`\\=12
%     +newzhlipsum<big5><許蓋功, 蓋功許, 功許蓋>
%   +endgroup
%   \zhlipsum[name=big5]
% \end{ctexexam}
%^^A! \begin{ctexexam}
%^^A!   ! File encoding should be Big5.
%^^A!   ! \usepackage[encoding=big5]{zhlipsum}
%^^A!
%^^A!   ! Using `\newzhlipsum{big5}{許蓋功, 蓋功許, 功許蓋}' directly will
%^^A!   ! lead to an error.
%^^A!   ! Use <, >, + to replace {, } and \, then set the original {, } and \
%^^A!   ! to be `other' category (i.e. catcode=12).
%^^A!   \begingroup
%^^A!     \catcode`\<=1
%^^A!     \catcode`\>=2
%^^A!     \catcode`\+=0
%^^A!     \catcode`\{=12
%^^A!     \catcode`\}=12
%^^A!     \catcode`\\=12
%^^A!     +newzhlipsum<big5><許蓋功, 蓋功許, 功許蓋>
%^^A!   +endgroup
%^^A!   \zhlipsum[name=big5]
%^^A! \end{ctexexam}
%^^A!
%
%^^A! \end{document}
%
% \StopEventually{}
%
% \begin{implementation}
%
% \section{实现细节}
%
%    \begin{macrocode}
%<*package>
%<@@=zhlipsum>
%    \end{macrocode}
%
% 检查 \LaTeX3 编程环境。
%    \begin{macrocode}
\RequirePackage { xparse, l3keys2e }
\msg_new:nnn { zhlipsum } { l3-too-old }
  {
    Package~ "#1"~ is~ too~ old. \\\\
    Please~ update~ an~ up-to-date~ version~ of~ the~ bundles \\
    "l3kernel"~ and~ "l3packages"~ using~ your~ TeX~ package \\
    manager~ or~ from~ CTAN.
  }
\clist_map_inline:nn { expl3, xparse, l3keys2e }
  {
    \@ifpackagelater {#1} { 2018/05/12 }
      { } { \msg_error:nnn { zhlipsum } { l3-too-old } {#1} }
  }
%    \end{macrocode}
%
% \subsection{内部变量和函数}
%
% \begin{variable}{
%   \l_@@_tmpa_tl,
%   \l_@@_tmpa_seq,
%   \l_@@_tmpb_seq,
%   \l_@@_tmpa_str}
% 临时变量。
%    \begin{macrocode}
\tl_new:N  \l_@@_tmpa_tl
\seq_new:N \l_@@_tmpa_seq
\seq_new:N \l_@@_tmpb_seq
\str_new:N \l_@@_tmpa_str
%    \end{macrocode}
% \end{variable}
%
% \begin{variable}{\g_zhlipsum_seq}
% 假文名称列表。
%    \begin{macrocode}
\seq_new:N \g_zhlipsum_seq
%    \end{macrocode}
% \end{variable}
%
% \begin{variable}{\c_zhlipsum_simp_seq,\c_zhlipsum_trad_seq}
% 预定义的简体中文与繁体中文的假文名称列表。
%    \begin{macrocode}
\seq_const_from_clist:Nn \c_zhlipsum_simp_seq { simp, zhufu, aspirin }
\seq_const_from_clist:Nn \c_zhlipsum_trad_seq { trad, xiangyu, nanshanjing }
%    \end{macrocode}
% \end{variable}
%
% \begin{macro}[int]{\file_input:x}
% \LaTeX3 函数变体。
%    \begin{macrocode}
\cs_generate_variant:Nn \file_input:n { x }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[TF]{\@@_if_unicode_engine:}
% 判断是否为 Unicode 引擎。来自于 \pkg{zhnumber} 宏包。
%    \begin{macrocode}
\prg_new_conditional:Npnn \@@_if_unicode_engine: { T, F, TF }
  {
    \bool_lazy_any:nTF
      {
        \sys_if_engine_xetex_p:
        \sys_if_engine_luatex_p:
        \sys_if_engine_uptex_p:
      }
      { \prg_return_true: } { \prg_return_false: }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[TF]{\@@_if_encoding:n}
% \begin{variable}{\g_@@_encoding_str}
% 判断当前编码。
%    \begin{macrocode}
\prg_new_conditional:Npnn \@@_if_encoding:n #1 { T, F, TF }
  {
    \str_if_eq:VnTF \g_@@_encoding_str {#1}
      { \prg_return_true: } { \prg_return_false: }
  }
\prg_generate_conditional_variant:Nnn \@@_if_encoding:n { V } { T, F, TF }
\str_new:N \g_@@_encoding_str
%    \end{macrocode}
% \end{variable}
% \end{macro}
%
% \begin{macro}{
%   \@@_msg_new:nn,
%   \@@_error:n,
%   \@@_error:nn,
%   \@@_warning:n,
%   \@@_warning:nn,
%   \@@_warning:nnn,
%   \@@_warning:nxxx,
%   \@@_info:nn}
% 各种信息函数的缩略形式。
%    \begin{macrocode}
\cs_new:Npn \@@_msg_new:nn   { \msg_new:nnn       { zhlipsum } }
\cs_new:Npn \@@_error:n      { \msg_error:nn      { zhlipsum } }
\cs_new:Npn \@@_error:nn     { \msg_error:nnn     { zhlipsum } }
\cs_new:Npn \@@_warning:n    { \msg_warning:nn    { zhlipsum } }
\cs_new:Npn \@@_warning:nn   { \msg_warning:nnn   { zhlipsum } }
\cs_new:Npn \@@_warning:nnn  { \msg_warning:nnnn  { zhlipsum } }
\cs_new:Npn \@@_warning:nxxx { \msg_warning:nnxxx { zhlipsum } }
\cs_new:Npn \@@_info:nn      { \msg_info:nnn      { zhlipsum } }
%    \end{macrocode}
% \end{macro}
%
% \subsection{宏包选项}
%
% \changes{v0.4}{2017/09/16}{新增 \opt{encoding} 选项。}
% \changes{v0.5}{2017/12/22}{支持 Big5 编码。}
% \changes{v1.0.0}{2018/04/01}{根据 \CTeX{} 宏集的选项自动确定编码。}
% \changes{v1.2.0}{2020/02/20}{优化编码判断。}
%
% \begin{macro}{encoding}
% 设置编码。
%    \begin{macrocode}
\keys_define:nn { zhlipsum / option }
  {
    encoding .choices:nn =
      { utf8, gbk, big5 }
      { \str_gset:Nn \g_@@_encoding_str {#1} },
    encoding / unknown .code:n =
      { \@@_error:nn { invalid-encoding } {#1} },
    encoding .value_required:n = true,
%    \end{macrocode}
% \end{macro}
%
% 处理未知选项。
%    \begin{macrocode}
    unknown .code:n = { \@@_error:n { unknown-option } }
  }
%    \end{macrocode}
%
% 提示信息。
%    \begin{macrocode}
\@@_msg_new:nn { invalid-encoding }
  {
    Encoding~"#1"~is~invalid. \\
    Available~encodings~are~"utf8",~"gbk"~and~"big5".
  }
\@@_msg_new:nn { unknown-option }
  { Package~option~'\l_keys_key_tl'~is~unknown. }
%    \end{macrocode}
%
% \begin{macro}{\@@_check_unicode_engine_encoding:}
% Unicode 引擎下编码始终设为 UTF-8。
%    \begin{macrocode}
\cs_new_protected:Npn \@@_check_unicode_engine_encoding:
  {
    \@@_if_unicode_engine:T
      {
        \str_if_empty:NF \g_@@_encoding_str
          {
            \@@_if_encoding:nF { utf8 }
              { \@@_warning:n { unicode-engine } }
          }
        \str_gset:Nn \g_@@_encoding_str { utf8 }
      }
  }
\@@_msg_new:nn { unicode-engine }
  {
    You~are~now~using~Unicode~engine~\c_sys_engine_str\c_space_tl~so~
    encoding~"\g_@@_encoding_str"~is~invalid. \\
    Changed~into~"utf8".
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_check_ctex_encoding:}
% 如果调用了 \CTeX{} 宏集,则自动确定编码。
%    \begin{macrocode}
\cs_new_protected:Npn \@@_check_ctex_encoding:
  {
    \tl_if_exist:NT \l__ctex_encoding_tl
      {
        \str_set:Nx \l_@@_tmpa_str
          { \str_lower_case:f { \l__ctex_encoding_tl } }
        \str_if_empty:NF \g_@@_encoding_str
          {
            \@@_if_encoding:VF \l_@@_tmpa_str
              { \@@_warning:n { ctex-encoding-conflict } }
          }
        \str_gset_eq:NN \g_@@_encoding_str \l_@@_tmpa_str
      }
  }
\@@_msg_new:nn { ctex-encoding-conflict }
  {
    Package~option~"encoding=\g_@@_encoding_str"~is~in~conflict~with~
    ctex's~option~"\l__ctex_encoding_tl". \\
    Changed~into~"encoding=\l_@@_tmpa_str".
  }
%    \end{macrocode}
% \end{macro}
%
% 将宏包选项传给 |zhlipsum/option|。
%    \begin{macrocode}
\ProcessKeysOptions { zhlipsum / option }
%    \end{macrocode}
%
% 检查编码兼容性。
%    \begin{macrocode}
\@@_check_unicode_engine_encoding:
\@@_check_ctex_encoding:
\str_if_empty:NT \g_@@_encoding_str
  { \str_gset:Nn \g_@@_encoding_str { utf8 } }
%    \end{macrocode}
%
% \subsection{函数选项}
%
% \begin{variable}{\l_@@_name_tl}
% 保存假文名称。
%    \begin{macrocode}
\tl_new:N \l_@@_name_tl
%    \end{macrocode}
% \end{variable}
%
% \begin{variable}{\l_@@_before_tl,\l_@@_after_tl,\l_@@_inter_tl}
% 保存假文之前、之后与之间插入的内容。
%    \begin{macrocode}
\tl_new:N \l_@@_before_tl
\tl_new:N \l_@@_after_tl
\tl_new:N \l_@@_inter_tl
%    \end{macrocode}
% \end{variable}
%
%    \begin{macrocode}
\keys_define:nn { zhlipsum }
  {
%    \end{macrocode}
%
% \changes{v1.0.0}{2018/03/24}{新增选项 \opt{name}。}
%
% \begin{macro}{name}
% 假文名称。Big5 编码不支持简体中文。
%    \begin{macrocode}
    name .code:n =
      {
        \tl_set:Nn \l_@@_name_tl {#1}
        \@@_if_encoding:nT { big5 }
          {
            \seq_if_in:NVT \c_zhlipsum_simp_seq \l_@@_name_tl
              {
                \@@_warning:nn { big5-require-trad } {#1}
                \tl_set:Nn \l_@@_name_tl { trad }
              }
          }
      },
%    \end{macrocode}
% \end{macro}
%
% \changes{v0.5}{2017/12/22}{新增选项 \opt{script},同时支持简体中文和繁体中文。}
% \changes{v1.0.0}{2018/03/24}{\opt{script} 成为过时选项。}
%
% \begin{macro}{script}
% 选择输入简体中文或繁体中文。过时选项。
%    \begin{macrocode}
    script .code:n =
      {
        \@@_warning:nn { deprecated-option }
          { Option~ "name=#1"~ will~ be~ set. }
        \keys_set:nn { zhlipsum } { name = #1 }
      },
%    \end{macrocode}
% \end{macro}
%
% \changes{v1.0.0}{2018/03/23}{新增选项 \opt{before}、\opt{after}。}
% \changes{v1.0.0}{2018/03/29}{新增选项 \opt{inter}。}
%
% \begin{macro}{before,after,inter}
% 假文之前、之后与之间插入的内容。
%    \begin{macrocode}
    before .tl_set:N = \l_@@_before_tl,
    after  .tl_set:N = \l_@@_after_tl,
    inter  .tl_set:N = \l_@@_inter_tl
  }
%    \end{macrocode}
% \end{macro}
%
% 提示信息。
%    \begin{macrocode}
\@@_msg_new:nn { big5-require-trad }
  {
    Name~ "#1"~ is~ not~ available~ in~ "Big5"~ encoding. \\
    Changed~ into~ "trad".
  }
\@@_msg_new:nn { deprecated-option }
  { Option~ "\l_keys_key_tl"~ is~ deprecated. \\ #1 }
%    \end{macrocode}
%
% 初始选项设置。
%    \begin{macrocode}
\@@_if_encoding:nTF { big5 }
  { \keys_set:nn { zhlipsum } { name = trad } }
  { \keys_set:nn { zhlipsum } { name = simp } }
%    \end{macrocode}
%
% \subsection{输出假文}
%
% \begin{macro}{\zhlipsum,\@@:n}
% \changes{v0.5}{2018/01/05}{支持选项设置。}
% \changes{v1.0.0}{2018/03/23}{更改参数形式,允许利用逗号分隔列表选择段落。}
% \changes{v1.1.0}{2018/04/08}{改回使用方括号指定段落数的形式。}
% \changes{v1.2.0}{2020/04/08}{修正 \env{quote}/\env{quotation} 等环境中段落缩进消失问题。}
% \changes{v1.2.0}{2020/04/08}{与 \pkg{lipsum} 等宏包保持一致,不在开头插入分段命令。}
% 输出假文,第一个可选参数表示段落数,默认为 |1-3|;第二个可选参数为选项列表。
%    \begin{macrocode}
\NewDocumentCommand \zhlipsum { s o +o }
  {
    \group_begin:
      \IfBooleanF {#1}
        {
          \tl_set:Nn \l_@@_before_tl { }
          \tl_set:Nn \l_@@_after_tl  { \par }
          \tl_set:Nn \l_@@_inter_tl  { \par }
        }
      \IfValueTF {#3}
        {
          \keys_set:nn { zhlipsum } {#3}
          \@@:n {#2}
        }
        {
          \IfValueTF {#2}
            {
%    \end{macrocode}
% 如果只带一个参数,那么根据其是否含有 |=| 来判断该参数是段落数还是选项列表。
%    \begin{macrocode}
              \@@_if_key_value_list:nTF {#2}
                {
                  \keys_set:nn { zhlipsum } {#2}
                  \@@:n { 1 - 3 }
                }
                { \@@:n {#2} }
            }
            { \@@:n { 1 - 3 } }
        }
    \group_end:
  }
\cs_new_protected:Npn \@@:n #1
  { \exp_args:No \zhlipsum_use:nn { \l_@@_name_tl } {#1} }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_if_key_value_list:nTF}
% 判断是否为键值列表,即是否含有 |=|。
%    \begin{macrocode}
\cs_new_protected:Npn \@@_if_key_value_list:nTF #1
  { \tl_if_in:nnTF {#1} {=} }
%    \end{macrocode}
% \end{macro}
%
% \begin{variable}{\l_@@_par_num_seq}
% 保存段落编号。
%    \begin{macrocode}
\seq_new:N \l_@@_par_num_seq
%    \end{macrocode}
% \end{variable}
%
% \begin{macro}{\zhlipsum_use:nn}
% \changes{v1.2.0}{2019/08/11}{检查空的段落范围避免陷入死循环。}
% 输出多段假文。|#1| = 假文名称,|#2| = 段落编号列表。解析段落编号之
% 后,按次序逐项输出,并在前后插入相应内容。注意最后一段需要单独处理。
%    \begin{macrocode}
\cs_new_protected:Npn \zhlipsum_use:nn #1#2
  {
    \@@_if_cjk_valid_encoding:TF
      {
        \zhlipsum_if_exist:nTF {#1}
          {
            \@@_parse_par:nn {#1} {#2}
            \seq_if_empty:NF \l_@@_par_num_seq
              {
                \seq_pop_right:NN  \l_@@_par_num_seq \l_@@_tmpa_tl
                \l_@@_before_tl
                \seq_map_inline:Nn \l_@@_par_num_seq
                  {
                    \@@_use:nn {#1} {##1}
                    \l_@@_inter_tl
                  }
                \@@_use:nn {#1} { \l_@@_tmpa_tl }
                \l_@@_after_tl
              }
          }
          { \@@_error:nn { invalid-name } {#1} }
      }
      { \@@_error:n { CJK-invalid-encoding } }
  }
\@@_msg_new:nn { invalid-name }
  {
    Name~ "#1"~ is~ unknown. \\
    Please~ use~ the~ pre-defined~ Chinese~ dummy~ texts~ or~
    declare~ new~ one.
  }
\@@_msg_new:nn { CJK-invalid-encoding }
  {
    The~ current~ CJK~ environment~ uses~ "\CJK@@@@@enc"~ encoding,~
    but~ zhlipsum~ package~ has~ been~ loaded~ with~ the~ option~
    "encoding=\g_@@_encoding_str". \\
    Please~ check~ the~ package~ options.
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[TF]{\@@_if_cjk_valid_encoding:}
% 检查 \env{CJK} 环境编码。
%    \begin{macrocode}
\prg_new_protected_conditional:Npnn \@@_if_cjk_valid_encoding: { TF }
  {
    \tl_if_exist:NTF \CJK@@@@@enc
      {
        \exp_args:NV \str_case:nn \g_@@_encoding_str
          {
            { utf8 } { \str_if_eq:VnTF \CJK@@@@@enc { UTF8 } }
            { gbk  } { \str_if_in:NnTF \CJK@@@@@enc { GB   } }
            { big5 } { \str_if_eq:VnTF \CJK@@@@@enc { Bg5  } }
          }
        { \prg_return_true: } { \prg_return_false: }
      }
      { \prg_return_true: }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}[TF]{\zhlipsum_if_exist:n}
% 判断是否存在对应名称的假文。
%    \begin{macrocode}
\prg_new_protected_conditional:Npnn \zhlipsum_if_exist:n #1 { T, F, TF }
  {
    \seq_if_in:NnTF \g_zhlipsum_seq {#1}
      { \prg_return_true: } { \prg_return_false: }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{variable}{\l_@@_begin_int,\l_@@_end_int,\l_@@_max_int}
%    \begin{macrocode}
\int_new:N \l_@@_begin_int
\int_new:N \l_@@_end_int
\int_new:N \l_@@_max_int
%    \end{macrocode}
% \end{variable}
%
% \begin{variable}{\l_@@_modified_range_bool,\l_@@_invalid_range_bool}
%    \begin{macrocode}
\bool_new:N \l_@@_modified_range_bool
\bool_new:N \l_@@_invalid_range_bool
%    \end{macrocode}
% \end{variable}
%
% \begin{macro}{\@@_parse_par:nn}
% 解析段落编号列表。|#1| = 假文名称,|#2| = 段落编号列表。
%
% 编号列表用逗号分隔,其中的每一项为单个数字或为 |a-b| 的形式。若
% |a|、|b| 为空,则分别取为 1 或允许的最大值(即段落数)。超过范围的
% 数字则忽略。
%    \begin{macrocode}
\cs_new_protected:Npn \@@_parse_par:nn #1#2
  {
    \seq_clear:N \l_@@_par_num_seq
    \int_set_eq:Nc \l_@@_max_int { g_@@_ #1 _int }
    \clist_map_inline:nn {#2}
      {
        \@@_parse_par_aux:n {##1}
        \bool_if:NTF \l_@@_invalid_range_bool
          { \@@_warning:nnn { invalid-range } {##1} {#2} }
          {
            \bool_if:NT \l_@@_modified_range_bool
              {
                \@@_warning:nxxx { modified-range }
                  {##1} {#2} { \@@_par_range: }
              }
            \seq_concat:NNN \l_@@_par_num_seq
              \l_@@_par_num_seq \l_@@_tmpa_seq
          }
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_parse_par_aux:n}
%    \begin{macrocode}
\cs_new_protected:Npn \@@_parse_par_aux:n #1
  {
    \bool_set_false:N \l_@@_modified_range_bool
    \bool_set_false:N \l_@@_invalid_range_bool
    \seq_clear:N \l_@@_tmpa_seq
    \tl_if_in:nnTF {#1} { - }
      {
        \seq_set_split:Nnn \l_@@_tmpb_seq { - } {#1}
%    \end{macrocode}
% “|-|” 左侧的数字。
%    \begin{macrocode}
        \seq_pop_left:NN \l_@@_tmpb_seq \l_@@_tmpa_tl
        \tl_if_empty:NTF \l_@@_tmpa_tl
          { \int_set_eq:NN \l_@@_begin_int \c_one_int }
          {
            \int_set:Nn \l_@@_begin_int { \l_@@_tmpa_tl }
            \int_compare:nNnT \l_@@_begin_int < \c_one_int
              {
                \int_set_eq:NN \l_@@_begin_int \c_one_int
                \bool_set_true:N \l_@@_modified_range_bool
              }
          }
%    \end{macrocode}
% “|-|” 右侧的数字。注意左右数字均由 \cs{seq_pop_left:NN} 得到,因此
% |-3-4| 实际相当于 |-3|,进而被解析为 |1-3|。
%    \begin{macrocode}
        \seq_pop_left:NN \l_@@_tmpb_seq \l_@@_tmpa_tl
        \tl_if_empty:NTF \l_@@_tmpa_tl
          { \int_set_eq:NN \l_@@_end_int \l_@@_max_int }
          {
            \int_set:Nn \l_@@_end_int { \l_@@_tmpa_tl }
            \int_compare:nNnT \l_@@_end_int > \l_@@_max_int
              {
                \int_set_eq:NN \l_@@_end_int \l_@@_max_int
                \bool_set_true:N \l_@@_modified_range_bool
              }
          }
%    \end{macrocode}
% 检查取值范围。
%    \begin{macrocode}
        \bool_lazy_or:nnTF
          { \int_compare_p:nNn \l_@@_begin_int > \l_@@_max_int }
          { \int_compare_p:nNn \l_@@_begin_int > \l_@@_end_int }
          { \bool_set_true:N \l_@@_invalid_range_bool }
          {
            \int_step_inline:nnn
              { \l_@@_begin_int } { \l_@@_end_int }
              { \seq_put_right:Nn \l_@@_tmpa_seq {##1} }
          }
      }
      {
%    \end{macrocode}
% 单个数字的处理。
%    \begin{macrocode}
        \bool_lazy_or:nnTF
          { \int_compare_p:nNn {#1} > \l_@@_max_int }
          { \int_compare_p:nNn {#1} < \c_one_int }
          { \bool_set_true:N \l_@@_invalid_range_bool }
          { \seq_put_right:Nn \l_@@_tmpa_seq {#1} }
      }
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_par_range:}
% 显示段落范围(用在提示信息中,可以完全展开)。
%    \begin{macrocode}
\cs_new:Npn \@@_par_range:
  {
    \int_compare:nNnTF \l_@@_begin_int = \l_@@_end_int
      { \int_use:N \l_@@_begin_int }
      { \int_use:N \l_@@_begin_int - \int_use:N \l_@@_end_int }
  }
%    \end{macrocode}
% \end{macro}
%
% 提示信息。
%    \begin{macrocode}
\@@_msg_new:nn { modified-range }
  {
    Your~ required~ range~ "#1"~ in~ "#2"~ will~ be~ modified. \\
    Changed~ into~ "#3".
  }
\@@_msg_new:nn { invalid-range }
  {
    Your~ required~ range~ "#1"~ in~ "#2"~ is~ invalid. \\
    Nothing~ will~ be~ output.
  }
%    \end{macrocode}
%
% \begin{macro}{\@@_use:nn}
% 输出一段假文。|#1| = 假文名称,|#2| = 段落编号。
%    \begin{macrocode}
\cs_new_protected:Npn \@@_use:nn #1#2
  { \tl_use:c { c_@@_ #1 @ #2 _tl } }
%    \end{macrocode}
% \end{macro}
%
% \subsection{声明假文}
%
% \begin{macro}{\newzhlipsum,\zhlipsum_new:nn}
% 声明假文。|#1| = 假文名称,|#2| = 文本 clist。
%    \begin{macrocode}
\NewDocumentCommand \newzhlipsum { m m }
  { \zhlipsum_new:nn {#1} {#2} }
\cs_new_protected:Npn \zhlipsum_new:nn #1#2
  {
    \zhlipsum_if_exist:nTF {#1}
      { \@@_error:nn { already-defined } {#1} }
      {
        \seq_gput_left:Nn \g_zhlipsum_seq {#1}
        \int_new:c { g_@@_ #1 _int }
        \clist_map_inline:nn {#2} { \@@_new:nn {#1} {##1} }
        \@@_info:nn { defining-text } {#1}
      }
  }
\@@_msg_new:nn { already-defined }
  {
    Chinese~ dummy~ text~ "#1"~ has~ been~ used.~
    Please~ use~ another~ name.
  }
\@@_msg_new:nn { defining-text }
  {
    Chinese~ dummy~ text~ "#1"~ is~ created.~
    It~ has~ \int_use:c { g_@@_ #1 _int }~ paragraphs.
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_new:nn}
% 定义新的假文段落。|#1| = 假文名称,|#2| = 文本。
%    \begin{macrocode}
\cs_new_protected:Npn \@@_new:nn #1#2
  {
    \int_gincr:c { g_@@_ #1 _int }
    \tl_const:cn
      { c_@@_ #1 @ \int_use:c { g_@@_ #1 _int } _tl } {#2}
  }
%    \end{macrocode}
% \end{macro}
%
% 根据编码读入假文文本定义文件。
%    \begin{macrocode}
\file_input:x { zhlipsum- \g_@@_encoding_str .def }
%</package>
%    \end{macrocode}
%
% \subsection{假文文本} \label{subsec:dummy-text}
%
% \changes{v1.0.0}{2018/03/27}{利用类别码机制回避 \pkg{CJK} 宏包的
%   预处理操作。}
%
% \begin{macro}{\@@_set_special_catcode:}
% 在声明预定义文本时,为了兼容 \pkg{CJK} 宏包的特殊处理,需要临时更改
% 类别码。具体来说,在 GBK/Big5 编码下,由于汉字的第二个字节会与
% \TeX{} 中的特殊符号 |\|、|{|、|}|、|~| 冲突,所以需要将它们的类别码
% 改为 12(其他),并分别用 |+|、|<|、|>| 和 |*| 代替。星号 |*| 在
% 开启 \LaTeX3 语法后实际相当于空格(类别码为 10)。
%    \begin{macrocode}
%<*text>
\cs_new_protected:Npn \@@_set_special_catcode:
  {
%<!utf8>    \@@_active_first_byte:
    \char_set_catcode_escape:N      \+
    \char_set_catcode_group_begin:N \<
    \char_set_catcode_group_end:N   \>
    \char_set_catcode_space:N       \*
    \char_set_catcode_other:N \\
    \char_set_catcode_other:N \{
    \char_set_catcode_other:N \}
    \char_set_catcode_other:N \~
  }
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\@@_active_first_byte:}
% 将汉字的首字节设为活动字符(类别码 12)。UTF-8 编码下不需要该操作。
%    \begin{macrocode}
%<*!utf8>
\cs_new_protected:Npx \@@_active_first_byte:
  {
    \int_step_function:nnN { "81 } { "FE }
      \char_set_catcode_active:n
  }
%</!utf8>
%</text>
%    \end{macrocode}
% \end{macro}
%
% \changes{v1.0.0}{2018/03/26}{增加预定义假文。}
% \changes{v1.1.1}{2018/07/19}{更新假文文本。}
%
% 预定义假文的声明放置在分组内,利用 \cs{@@_set_special_catcode:} 切换
% 类别码后可以不再需要 \pkg{CJK} 的预处理操作。具体声明此处不再列出。
%
% \end{implementation}
%