summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/zhlipsum/zhlipsum.sty
blob: d7d01c820ecf5f21ac2490f4663ea72a753aa3dd (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
%%
%% This is file `zhlipsum.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% zhlipsum.dtx  (with options: `package')
%% 
%%     Copyright (C) 2017 by Xiangdong Zeng <pssysrq@163.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.ins
%%                                     README.md
%%               and the derived files zhlipsum.pdf
%%                                     zhlipsum.sty
%%                                     zhlipsum-zh-cn.def.
%% 
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{expl3,xparse}
\GetIdInfo $Id: zhlipsum.dtx 0.3 2017-07-28 12:00:00Z Xiangdong Zeng $
  {Chinese dummy text}
\ProvidesExplPackage{\ExplFileName}
  {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
\str_new:N \l__zhlipsum_tmpa_str
\str_new:N    \l__zhlipsum_lang_code_str
\str_const:Nn \c__zhlipsum_text_cs_prefix { c__zhlipsum_text_ }
\str_const:Nn \c__zhlipsum_text_cs_suffix { _tl }
\int_const:Nn \c__zhlipsum_max_par_number_int { 50 }
\cs_new:Npn \__zhlipsum_print_single:N #1
  {
    \str_set:Nx \l__zhlipsum_tmpa_str
      { \int_to_roman:n { #1 } }
    \str_set:Nn \l__zhlipsum_lang_code_str
      { zh_cn_ }
    \str_put_left:Nx  \l__zhlipsum_tmpa_str
      \l__zhlipsum_lang_code_str
    \str_put_left:Nx  \l__zhlipsum_tmpa_str
      \c__zhlipsum_text_cs_prefix
    \str_put_right:Nx \l__zhlipsum_tmpa_str
      \c__zhlipsum_text_cs_suffix
%% Print paragrapf number string. For debug.
    \use:c { \str_use:N \l__zhlipsum_tmpa_str }
  }
\int_new:N \l__zhlipsum_begin_int
\int_new:N \l__zhlipsum_end_int
\int_new:N \l__zhlipsum_step_int
\cs_new:Npn \__zhlipsum_process_par_number:nn #1 #2
  {
    \int_compare:nTF { #1 <= \c__zhlipsum_max_par_number_int }
      { \int_set:Nn \l__zhlipsum_begin_int { #1 } }
      {
        \int_set_eq:NN \l__zhlipsum_begin_int
          \c__zhlipsum_max_par_number_int
      }
    \IfNoValueTF { #2 }
      {
        \int_set_eq:NN \l__zhlipsum_end_int
          \l__zhlipsum_begin_int
      }
      {
        \int_compare:nTF { #2 <= \c__zhlipsum_max_par_number_int }
          { \int_set:Nn \l__zhlipsum_end_int { #2 } }
          {
            \int_set_eq:NN \l__zhlipsum_end_int
              \c__zhlipsum_max_par_number_int
          }
      }
      \int_compare:nTF
        { \l__zhlipsum_begin_int <= \l__zhlipsum_end_int }
        { \int_set_eq:NN \l__zhlipsum_step_int \c_one }
        { \int_set:Nn    \l__zhlipsum_step_int { -1 } }
  }
\cs_new:Npn \zhlipsum_print_multi_par:nn #1 #2
  {
    \__zhlipsum_process_par_number:nn { #1 } { #2 }
    \int_step_inline:nnnn
      { \l__zhlipsum_begin_int }
      { \l__zhlipsum_step_int }
      { \l__zhlipsum_end_int }
      {
        \__zhlipsum_print_single:N { ##1 }
        \par
      }
  }
\cs_new:Npn \zhlipsum_print_multi_no_par:nn #1 #2
  {
    \__zhlipsum_process_par_number:nn { #1 } { #2 }
    \int_step_inline:nnnn
      { \l__zhlipsum_begin_int }
      { \l__zhlipsum_step_int }
      { \l__zhlipsum_end_int }
      {
        \__zhlipsum_print_single:N { ##1 }
      }
  }
\NewDocumentCommand \zhlipsum
  { s >{ \SplitArgument { 1 } { - } } O{ 1 - 3 } }
  {
    \par
    \IfBooleanTF { #1 }
      {
        \zhlipsum_print_multi_no_par:nn #2
        \par
      }
      { \zhlipsum_print_multi_par:nn #2 }
  }
\file_input:n { zhlipsum-zh-cn.def }
\endinput
%%
%% End of file `zhlipsum.sty'.