%%
%% 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 file zhlipsum.dtx,
%%              and the derived files zhlipsum.ins,
%%                                    zhlipsum.sty,
%%                                    zhlipsum-zh-cn-utf8.def,
%%                                    zhlipsum-zh-cn-gbk.def,
%%                                    zhlipsum-example-utf8.tex,
%%                                    zhlipsum-example-gbk.tex,
%%                                    zhlipsum.pdf,
%%                                and README.md.
%% 
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{expl3}
\GetIdInfo $Id: zhlipsum.dtx 0.4 2017-09-16 12:00:00Z Xiangdong Zeng <pssysrq@163.com> $
  {Chinese dummy text}
\ProvidesExplPackage{\ExplFileName}
  {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
\RequirePackage { xparse, l3keys2e }
\str_new:N \l__zhlipsum_tmpa_str
\tl_new:N \g__zhlipsum_encoding_tl
\int_const:Nn \c__zhlipsum_max_par_number_int { 50 }
\bool_lazy_any:nTF
  {
    { \sys_if_engine_xetex_p:  }
    { \sys_if_engine_luatex_p: }
    { \sys_if_engine_uptex_p:  }
  }
  { \cs_new_eq:NN \__zhlipsum_if_unicode_engine:TF \use_i:nn  }
  { \cs_new_eq:NN \__zhlipsum_if_unicode_engine:TF \use_ii:nn }
\cs_new:Npn \__zhlipsum_input_def_file:N #1
  { \exp_args:Nx \file_input:n { zhlipsum-zh-cn- #1 .def } }
\keys_define:nn { zhlipsum / option }
  {
    encoding .choice:,
    encoding / UTF8    .code:n =
      { \tl_set:Nn \g__zhlipsum_encoding_tl { utf8 } },
    encoding / GBK     .code:n =
      {
        \__zhlipsum_if_unicode_engine:TF
          {
            \tl_set:Nn \g__zhlipsum_encoding_tl { utf8 }
            \msg_warning:nn { zhlipsum } { unicode-engine }
          }
          { \tl_set:Nn \g__zhlipsum_encoding_tl { gbk  } }
      },
    encoding / unknown .code:n =
      { \msg_error:nnn { zhlipsum } { encoding-invalid } {#1} },
    encoding .value_required:n = true,
    encoding .initial:n        = { UTF8 },
    unknown  .code:n =
      { \msg_error:nn { zhlipsum } { unknown-option } }
  }
\msg_new:nnn { zhlipsum } { unicode-engine }
  {
    You~ are~ now~ using~ Unicode~ engine~ \c_sys_engine_str. \\
    Encoding~ "GBK"~ is~ invalid.~ Changed~ into~ UTF8.
  }
\msg_new:nnn { zhlipsum } { encoding-invalid }
  {
    Encoding~ "#1"~ is~ invalid. \\
    Available~ encodings~ are~ "UTF8"~ and~ "GBK".
  }
\msg_new:nnn { zhlipsum } { unknown-option }
  { Package~ option~ "\l_keys_key_tl"~ is~ unknown. }
\ProcessKeysOptions { zhlipsum / option }
\__zhlipsum_input_def_file:N \g__zhlipsum_encoding_tl
\NewDocumentCommand \zhlipsum
  { s >{ \SplitArgument { 1 } { - } } O{ 1 - 3 } }
  {
    \__zhlipsum_process_par_number:nn #2
    \par
    \IfBooleanTF {#1}
      {
        \zhlipsum_print_multi_no_par:VVV
          \l__zhlipsum_begin_int \l__zhlipsum_step_int \l__zhlipsum_end_int
        \par
      }
      {
        \zhlipsum_print_multi:VVV
          \l__zhlipsum_begin_int \l__zhlipsum_step_int \l__zhlipsum_end_int
      }
  }
\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
  {
    \__zhlipsum_process_par_number_aux:Nn \l__zhlipsum_begin_int {#1}
    \IfNoValueTF {#2}
      { \int_set_eq:NN \l__zhlipsum_end_int \l__zhlipsum_begin_int }
      { \__zhlipsum_process_par_number_aux:Nn \l__zhlipsum_end_int {#2} }
      \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_process_par_number_aux:Nn #1#2
  {
    \int_compare:nTF { #2 <= \c__zhlipsum_max_par_number_int }
      { \int_set:Nn #1 {#2} }
      { \int_set_eq:NN #1 \c__zhlipsum_max_par_number_int }
  }
\cs_new:Npn \zhlipsum_print_multi:nnn #1#2#3
  {
    \int_step_inline:nnnn {#1} {#2} {#3}
      { \__zhlipsum_print_single:n {##1} \par }
  }
\cs_generate_variant:Nn \zhlipsum_print_multi:nnn { VVV }
\cs_new:Npn \zhlipsum_print_multi_no_par:nnn #1#2#3
  {
    \int_step_inline:nnnn {#1} {#2} {#3}
      { \__zhlipsum_print_single:n {##1} }
  }
\cs_generate_variant:Nn \zhlipsum_print_multi_no_par:nnn { VVV }
\cs_new:Npn \__zhlipsum_print_single:n #1
  {
    \str_set:Nx \l__zhlipsum_tmpa_str { \int_to_roman:n {#1} }
    \str_put_left:Nn  \l__zhlipsum_tmpa_str { c__zhlipsum_text_zh_cn_ }
    \str_put_right:Nn \l__zhlipsum_tmpa_str { _tl }
    \use:c { \str_use:N \l__zhlipsum_tmpa_str }
  }
\endinput
%%
%% End of file `zhlipsum.sty'.
