%%
%% This is file `zhlipsum.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% zhlipsum.dtx  (with options: `package')
%% 
%%     Copyright (C) 2017, 2018 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-utf8.def,
%%                                    zhlipsum-gbk.def,
%%                                    zhlipsum-big5.def,
%%                                    zhlipsum-example-utf8.tex,
%%                                    zhlipsum-example-gbk.tex,
%%                                    zhlipsum-example-big5.tex,
%%                                    zhlipsum-en.tex,
%%                                    zhlipsum.pdf,
%%                                    zhlipsum-en.pdf,
%%                                and README.md.
%% 
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{expl3}
\GetIdInfo $Id: zhlipsum.dtx 0.5 2018-01-06 12:00:00Z Xiangdong Zeng <pssysrq@163.com> $
  {Chinese dummy text}
\ProvidesExplPackage{\ExplFileName}
  {\ExplFileDate}{\ExplFileVersion}{\ExplFileDescription}
\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} { 2017/12/16 }
      { } { \msg_error:nnn { zhlipsum } { l3-too-old } {#1} }
  }
\str_new:N \l__zhlipsum_tmpa_str
\tl_new:N \g__zhlipsum_encoding_tl
\int_const:Nn \c__zhlipsum_max_par_number_int { 50 }
\prg_generate_conditional_variant:Nnn \tl_if_eq:nn { Vn } { T, TF }
\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
  { \file_input:n { zhlipsum- #1 .def } }
\cs_generate_variant:Nn \__zhlipsum_input_def_file:n { V }
\cs_new_eq:NN \__zhlipsum_par: \tex_par:D
\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:nnn { zhlipsum } { unicode-engine } { gbk }
          }
          { \tl_set:Nn \g__zhlipsum_encoding_tl { gbk } }
      },
    encoding / big5    .code:n =
      {
        \__zhlipsum_if_unicode_engine:TF
          {
            \tl_set:Nn \g__zhlipsum_encoding_tl { utf8 }
            \msg_warning:nnn { zhlipsum } { unicode-engine } { big5 }
          }
          { \tl_set:Nn \g__zhlipsum_encoding_tl { big5 } }
      },
    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~ "#1"~ is~ invalid.~ Changed~ into~ "utf8".
  }
\msg_new:nnn { zhlipsum } { encoding-invalid }
  {
    Encoding~ "#1"~ is~ invalid. \\
    Available~ encodings~ are~ "utf8",~ "gbk"~ and~ "big5".
  }
\msg_new:nnn { zhlipsum } { unknown-option }
  { Package~ option~ "\l_keys_key_tl"~ is~ unknown. }
\ProcessKeysOptions { zhlipsum / option }
\__zhlipsum_input_def_file:V \g__zhlipsum_encoding_tl
\str_new:N \l__zhlipsum_script_str
\keys_define:nn { zhlipsum }
  {
    script .choice:,
    script / simp    .code:n =
      {
        \str_set:Nn \l__zhlipsum_script_str { simp }
        \tl_if_eq:VnT \g__zhlipsum_encoding_tl { big5 }
          {
            \str_set:Nn \l__zhlipsum_script_str { trad }
            \msg_warning:nn { zhlipsum } { big5-require-trad }
          }
      },
    script / trad    .code:n =
      { \str_set:Nn \l__zhlipsum_script_str { trad } },
    script / unknown .code:n =
      { \msg_error:nnn { zhlipsum } { script-invalid } {#1} },
    script .value_required:n = true
  }
\msg_new:nnn { zhlipsum } { big5-require-trad }
  {
    "script=simp"~ is~ not~ available~ in~ "BIG5"~ encoding.\\
    Changed~ into~ "script=trad".
  }
\msg_new:nnn { zhlipsum } { script-invalid }
  {
    Script~ "#1"~ is~ unknown. \\
    Available~ scripts~ are~ "simp"~ and~ "trad".
  }
\tl_if_eq:VnTF \g__zhlipsum_encoding_tl { big5 }
  { \keys_set:nn { zhlipsum } { script = trad } }
  { \keys_set:nn { zhlipsum } { script = simp } }
\NewDocumentCommand \zhlipsum
  { s >{ \SplitArgument { 1 } { - } } O{ 1 - 3 } o }
  {
    \group_begin:
      \__zhlipsum_process_par_number:nn #2
      \IfValueT {#3} { \keys_set:nn { zhlipsum } {#3} }
      \__zhlipsum_par:
      \IfBooleanTF {#1}
        {
          \zhlipsum_print_multi_no_par:VVV
            \l__zhlipsum_begin_int
            \l__zhlipsum_step_int
            \l__zhlipsum_end_int
          \__zhlipsum_par:
        }
        {
          \zhlipsum_print_multi:VVV
            \l__zhlipsum_begin_int
            \l__zhlipsum_step_int
            \l__zhlipsum_end_int
        }
    \group_end:
  }
\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} \__zhlipsum_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:Nx  \l__zhlipsum_tmpa_str
      { c__zhlipsum_text_ \l__zhlipsum_script_str _ }
    \str_put_right:Nn \l__zhlipsum_tmpa_str { _tl }
    \use:c { \str_use:N \l__zhlipsum_tmpa_str }
  }
\endinput
%%
%% End of file `zhlipsum.sty'.
