%%
%% This is file `lipsum.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% lipsum.dtx  (with options: `package')
%% 
%% 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.3}
\def\lipsumdate{2021-03-03}
\NeedsTeXFormat{LaTeX2e}
\RequirePackage{expl3}[2018/10/31]
\RequirePackage{xparse}
\ProvidesExplPackage
  {lipsum}
  {\lipsumdate}
  {\lipsumversion}
  {150 paragraphs of Lorem Ipsum dummy text}
\@ifpackagelater { expl3 } { 2018/10/31 }
  { }
  {
    \PackageError { lipsum } { Package~expl3~too~old }
      {
        You~need~to~update~your~installation~of~the~bundles~
        'l3kernel'~and~'l3packages'.\MessageBreak
        Loading~lipsum~will~abort!
      }
    \tex_endinput:D
  }
\cs_new_eq:NN \__lipsum_split_argument_expanded:nnn \SplitArgument
\cs_generate_variant:Nn \__lipsum_split_argument_expanded:nnn { nne }
\msg_new:nnnn{lipsum}{DeprecatedCommand}
{\string#1\msg_line_context:\\
  \string#1~should~be~substituted~by~\string#2.}
{ The~command~\string#1~is~deprecated~
  and~should~be~substituted~by~
  \string#2.~
  \string#1~might~not~be~available~in~a~
  future~version~of~lipsum.sty.}
\seq_new:N\g__lipsum_paragraph_seq
\tl_new:N \g_lipsum_default_range_tl %
\tl_new:N \l__lipsum_pars_tl
\tl_new:N \l__lipsum_sentences_tl
\seq_new:N \l__lipsum_sentences_seq
\tl_new:N \l__lipsum_par_list_start_nostar_tl
\tl_new:N \l__lipsum_par_list_end_nostar_tl
\tl_new:N \l__lipsum_sentence_list_start_nostar_tl
\tl_new:N \l__lipsum_sentence_list_end_nostar_tl

\tl_new:N \l__lipsum_par_list_start_star_tl
\tl_new:N \l__lipsum_par_list_end_star_tl
\tl_new:N \l__lipsum_sentence_list_start_star_tl
\tl_new:N \l__lipsum_sentence_list_end_star_tl
\tl_new:N \l__lipsum_par_list_itemseparator_nostar_tl
\tl_new:N \l__lipsum_sentence_list_itemseparator_nostar_tl

\tl_new:N \l__lipsum_par_list_itemseparator_star_tl
\tl_new:N \l__lipsum_sentence_list_itemseparator_star_tl

\tl_new:N \l__lipsum_par_list_itemstart_nostar_tl
\tl_new:N \l__lipsum_par_list_itemend_nostar_tl
\tl_new:N \l__lipsum_sentence_list_itemstart_nostar_tl
\tl_new:N \l__lipsum_sentence_list_itemend_nostar_tl

\tl_new:N \l__lipsum_par_list_itemstart_star_tl
\tl_new:N \l__lipsum_par_list_itemend_star_tl
\tl_new:N \l__lipsum_sentence_list_itemstart_star_tl
\tl_new:N \l__lipsum_sentence_list_itemend_star_tl

\tl_new:N\l__lipsum_par_list_start_tl
\tl_new:N\l__lipsum_par_list_end_tl
\tl_new:N\l__lipsum_sentence_list_start_tl
\tl_new:N\l__lipsum_sentence_list_end_tl
\tl_new:N\l__lipsum_par_list_itemseparator_tl
\tl_new:N\l__lipsum_sentence_list_itemseparator_tl
\tl_new:N\l__lipsum_par_list_itemstart_tl
\tl_new:N\l__lipsum_par_list_itemend_tl
\tl_new:N\l__lipsum_sentence_list_itemstart_tl
\tl_new:N\l__lipsum_sentence_list_itemend_tl
\str_new:N\g__lipsum_text_str
\cs_new:Npn \lipsum_store_as_temp_ints:nn #1#2{
  \int_set:Nn\l_tmpa_int{#1}
  \IfNoValueTF{#2}
  {
    \int_set:Nn\l_tmpb_int{#1}
  }
  {
    \int_set:Nn\l_tmpb_int{#2}
  }
}
\cs_new:Npn \lipsum_get_non_terminated_par:n #1{
  \seq_item:Nn \g__lipsum_paragraph_seq{#1}
}

\cs_new:Npn \lipsum_get_terminated_par:n #1 {
   \lipsum_get_non_terminated_par:n{#1}\par
}

\cs_new:Npn \lipsum_add_to_tokenlist:n #1 {
  \tl_put_right:NV
    \l__lipsum_pars_tl
    \l__lipsum_par_list_itemstart_tl
  \tl_put_right:Nn \l__lipsum_pars_tl  {
    \lipsum_get_non_terminated_par:n{#1}
  }
  \tl_put_right:NV
    \l__lipsum_pars_tl
    \l__lipsum_par_list_itemend_tl
}
\cs_generate_variant:Nn
  \lipsum_add_to_tokenlist:n { V }
\cs_new:Npn \lipsum_range_to_tokenlist:nn #1#2 {
  \tl_clear:N \l__lipsum_pars_tl
  \tl_put_right:NV
    \l__lipsum_pars_tl
    \l__lipsum_par_list_start_tl
  \int_set:Nn \l_tmpa_int {#1}
  \int_do_until:nNnn
    {\l_tmpa_int} > {#2}
    {
      \int_compare:nNnT
        \l_tmpa_int > {#1}
        {
          \tl_put_right:NV
            \l__lipsum_pars_tl
            \l__lipsum_par_list_itemseparator_tl
        }
      \lipsum_add_to_tokenlist:V {\l_tmpa_int}
      \int_incr:N\l_tmpa_int
    }
  \tl_put_right:NV
    \l__lipsum_pars_tl
    \l__lipsum_par_list_end_tl
}
\cs_generate_variant:Nn
  \lipsum_range_to_tokenlist:nn { VV }
\cs_new_nopar:Nn
  \__lipsum_expanded_paragraphs_terminated_with_space:{}
\cs_new:Npn \lipsum_sentences_to_tokenlist:nnn #1#2#3{

  \tl_clear:N \l__lipsum_sentences_tl

  \int_compare:nT {#2 >= #1}
  {
      \__lipsum_put_sentence_on_tokenlist:nnnw
      {#1}
      {#2}
      {1}
      #3 .. \q_stop
  }
  \tl_put_left:NV
    \l__lipsum_sentences_tl
    \l__lipsum_sentence_list_start_tl
  \tl_put_right:NV
    \l__lipsum_sentences_tl
    \l__lipsum_sentence_list_end_tl
}
\cs_generate_variant:Nn
  \lipsum_sentences_to_tokenlist:nnn { VVf }

\cs_new:Npn
  \__lipsum_put_sentence_on_tokenlist:nnnw
  #1#2#3#4 .
  {
    \int_compare:nNnTF{#1} > {#2}
      { % start > end: leave loop
        \use_none_delimit_by_q_stop:w
      }
      { % start <= end: perform loop
        \tl_if_blank:oTF{#4}
          { % Argument #4 blank.
            % Should be from the .. in the calling macro.
            % End reached. Leave loop.
            \use_none_delimit_by_q_stop:w
          }
          { % Not yet list end
            \int_compare:nNnTF{#3} > {#2}
              { % Counter > End: Leave loop
                \use_none_delimit_by_q_stop:w
              }
              { % Counter <= End: Proceed
                \int_compare:nT{ #3 >= #1}
                  { % Counter >= Start: Put item on list
                    \int_compare:nNnT{#3}>{#1}
                      { % Counter < Start, insert separator
                        \tl_put_right:NV
                          \l__lipsum_sentences_tl
                          \l__lipsum_sentence_list_itemseparator_tl
                      } % End Counter < Start true
                    % Put item on list
                    \tl_put_right:NV
                      \l__lipsum_sentences_tl
                      \l__lipsum_sentence_list_itemstart_tl
                    \tl_put_right:No
                      \l__lipsum_sentences_tl
                      { \tl_trim_spaces:n{#4}. }
                    \tl_put_right:NV
                      \l__lipsum_sentences_tl
                      \l__lipsum_sentence_list_itemend_tl
                  } % End Counter >= Start: Put item on list
                % Call loop again
                \exp_args:Nnnf
                  \__lipsum_put_sentence_on_tokenlist:nnnw
                  {#1}
                  {#2}
                  { \int_eval:n{#3+1} }
            } % End Counter > Start: Proceed
          } % End Not yet list end
      } % End Start > End: Perform loop
  } % End definition
\cs_new:Npn \__lipsum_protect:n #1 {\tex_noexpand:D#1}
\cs_new:Npn \__lipsum_set_surrounding_tokens_star:
  {
    \tl_set_eq:NN
      \l__lipsum_par_list_start_tl
      \l__lipsum_par_list_start_star_tl
    \tl_set_eq:NN
      \l__lipsum_par_list_end_tl
      \l__lipsum_par_list_end_star_tl
    \tl_set_eq:NN
      \l__lipsum_par_list_itemseparator_tl
      \l__lipsum_par_list_itemseparator_star_tl
    \tl_set_eq:NN
      \l__lipsum_par_list_itemstart_tl
      \l__lipsum_par_list_itemstart_star_tl
    \tl_set_eq:NN
      \l__lipsum_par_list_itemend_tl
      \l__lipsum_par_list_itemend_star_tl

    \tl_set_eq:NN
      \l__lipsum_sentence_list_start_tl
      \l__lipsum_sentence_list_start_star_tl
    \tl_set_eq:NN
      \l__lipsum_sentence_list_end_tl
      \l__lipsum_sentence_list_end_star_tl
    \tl_set_eq:NN
      \l__lipsum_sentence_list_itemseparator_tl
      \l__lipsum_sentence_list_itemseparator_star_tl
    \tl_set_eq:NN
      \l__lipsum_sentence_list_itemstart_tl
      \l__lipsum_sentence_list_itemstart_star_tl
    \tl_set_eq:NN
      \l__lipsum_sentence_list_itemend_tl
      \l__lipsum_sentence_list_itemend_star_tl
  }
  \cs_new:Npn \__lipsum_set_surrounding_tokens_nostar:
  {
    \tl_set_eq:NN
      \l__lipsum_par_list_start_tl
      \l__lipsum_par_list_start_nostar_tl
    \tl_set_eq:NN
      \l__lipsum_par_list_end_tl
      \l__lipsum_par_list_end_nostar_tl
    \tl_set_eq:NN
      \l__lipsum_par_list_itemseparator_tl
      \l__lipsum_par_list_itemseparator_nostar_tl
    \tl_set_eq:NN
      \l__lipsum_par_list_itemstart_tl
      \l__lipsum_par_list_itemstart_nostar_tl
    \tl_set_eq:NN
      \l__lipsum_par_list_itemend_tl
      \l__lipsum_par_list_itemend_nostar_tl

    \tl_set_eq:NN
      \l__lipsum_sentence_list_start_tl
      \l__lipsum_sentence_list_start_nostar_tl
    \tl_set_eq:NN
      \l__lipsum_sentence_list_end_tl
      \l__lipsum_sentence_list_end_nostar_tl
    \tl_set_eq:NN
      \l__lipsum_sentence_list_itemseparator_tl
      \l__lipsum_sentence_list_itemseparator_nostar_tl
    \tl_set_eq:NN
      \l__lipsum_sentence_list_itemstart_tl
      \l__lipsum_sentence_list_itemstart_nostar_tl
    \tl_set_eq:NN
      \l__lipsum_sentence_list_itemend_tl
      \l__lipsum_sentence_list_itemend_nostar_tl

    }
\cs_new:Nn \__lipsum_ensure_parsable_output:
  {
    \tl_set:No
      \l__lipsum_par_list_itemseparator_tl{\space}
    \tl_set:No
      \l__lipsum_par_list_item_start_tl{}
    \tl_set:No
      \l__lipsum_par_list_item_end_tl{}
    \tl_set:No
      \l__lipsum_par_list_start_tl{}
    \tl_set:No
      \l__lipsum_par_list_end_tl{}
  }

\NewDocumentCommand\NewLipsumPar{m}{
  \seq_gput_right:Nn{\g__lipsum_paragraph_seq}{#1}
}
\NewDocumentCommand\LipsumPar{m}{
  \group_begin:
    \lipsum_get_terminated_par:n{#1}
  \group_end:
}
\NewDocumentCommand\SetLipsumParListStart{s+m}{
  \IfBooleanTF{#1}
  {
    \tl_set:No\l__lipsum_par_list_start_star_tl{#2}
  }
  {
    \tl_set:No\l__lipsum_par_list_start_nostar_tl{#2}
  }
}
\NewDocumentCommand\SetLipsumSentenceListStart{s+m}{
  \IfBooleanTF{#1}
  {
    \tl_set:No\l__lipsum_sentence_list_start_star_tl{#2}
  }
  {
    \tl_set:No\l__lipsum_sentence_list_start_nostar_tl{#2}
  }
}
\NewDocumentCommand\SetLipsumParListEnd{s+m}{
  \IfBooleanTF{#1}
  {
    \tl_set:No\l__lipsum_par_list_end_star_tl{#2}
  }
  {
    \tl_set:No\l__lipsum_par_list_end_nostar_tl{#2}
  }
}
\NewDocumentCommand\SetLipsumSentenceListEnd{s+m}{
  \IfBooleanTF{#1}
  {
    \tl_set:No\l__lipsum_sentence_list_end_star_tl{#2}
  }
  {
    \tl_set:No\l__lipsum_sentence_list_end_nostar_tl{#2}
  }
}
\NewDocumentCommand\SetLipsumParListSurrounders{s+m+m}{
  \IfBooleanTF{#1}
  {
    \SetLipsumParListStart*{#2}
    \SetLipsumParListEnd*{#3}
  }
  {
    \SetLipsumParListStart{#2}
    \SetLipsumParListEnd{#3}
  }
}
\NewDocumentCommand\SetLipsumSentenceListSurrounders{s+m+m}{
  \IfBooleanTF{#1}
    {
      \SetLipsumSentenceListStart*{#2}
      \SetLipsumSentenceListEnd*{#3}
    }
    {
      \SetLipsumSentenceListStart{#2}
      \SetLipsumSentenceListEnd{#3}
    }
}
\NewDocumentCommand\SetLipsumParListItemStart{s+m}{
  \IfBooleanTF{#1}
    {
      \tl_set:No
        \l__lipsum_par_list_itemstart_star_tl{#2}
    }
    {
      \tl_set:No
        \l__lipsum_par_list_itemstart_nostar_tl{#2}
    }
}
\NewDocumentCommand\SetLipsumSentenceListItemStart{s+m}{
  \IfBooleanTF{#1}
    {
      \tl_set:No
        \l__lipsum_sentence_list_itemstart_star_tl {#2}
    }
    {
      \tl_set:No
        \l__lipsum_sentence_list_itemstart_nostar_tl{#2}
    }
}
\NewDocumentCommand\SetLipsumParListItemEnd{s+m}{
  \IfBooleanTF{#1}
    {
      \tl_set:No
        \l__lipsum_par_list_itemend_star_tl{#2}
    }
    {
      \tl_set:No
        \l__lipsum_par_list_itemend_nostar_tl{#2}
    }
}
\NewDocumentCommand\SetLipsumSentenceListItemEnd{s+m}{
  \IfBooleanTF{#1}
    {
      \tl_set:No
        \l__lipsum_sentence_list_itemend_star_tl{#2}
    }
    {
      \tl_set:No
        \l__lipsum_sentence_list_itemend_nostar_tl{#2}
    }
}
\NewDocumentCommand\SetLipsumParListItemSurrounders{s+m+m}{
  \IfBooleanTF{#1}
  {
    \SetLipsumParListItemStart*{#2}
    \SetLipsumParListItemEnd*{#3}
  }
  {
    \SetLipsumParListItemStart{#2}
    \SetLipsumParListItemEnd{#3}
  }
}

\NewDocumentCommand\SetLipsumSentenceListItemSurrounders{s+m+m}{
  \IfBooleanTF{#1}
  {
    \SetLipsumSentenceListItemStart*{#2}
    \SetLipsumSentenceListItemEnd*{#3}
  }
  {
    \SetLipsumSentenceListItemStart{#2}
    \SetLipsumSentenceListItemEnd{#3}
  }
}
\NewDocumentCommand\SetLipsumParListItemSeparator{s+m}{
  \IfBooleanTF{#1}
    {
      \tl_set:No
        \l__lipsum_par_list_itemseparator_star_tl{#2}
    }
    {
      \tl_set:No
        \l__lipsum_par_list_itemseparator_nostar_tl{#2}
    }
}
\NewDocumentCommand\SetLipsumSentenceListItemSeparator{s+m}{
  \IfBooleanTF{#1}
    {
      \tl_set:No
        \l__lipsum_sentence_list_itemseparator_star_tl{#2}
    }
    {
      \tl_set:No
        \l__lipsum_sentence_list_itemseparator_nostar_tl{#2}
    }
}
\NewDocumentCommand\LipsumProtect{m}{}
\cs_gset_eq:NN
  \LipsumProtect
  \__lipsum_protect:n

\NewDocumentCommand\SetLipsumDefault{m}{
  \tl_gset:No\g_lipsum_default_range_tl{#1}
}
\NewDocumentCommand\setlipsumdefault{m}{%
  \msg_warning:nnnn
    {lipsum}
    {DeprecatedCommand}
    {\setlipsumdefault}
    {\SetLipsumDefault}
  \SetLipsumDefault{#1}
}

\NewDocumentCommand
  \lipsum{
    s
    >{\__lipsum_split_argument_expanded:nne{1}{-}}
     O{\g_lipsum_default_range_tl}
    >{\__lipsum_split_argument_expanded:nne{1}{-}}
     o
  }
  {
    \group_begin:
      \lipsum_store_as_temp_ints:nn #2
      \IfBooleanTF {#1}
        {
          \__lipsum_set_surrounding_tokens_star:
        }
        {
          \__lipsum_set_surrounding_tokens_nostar:
        }

      \IfNoValueTF{#3}
      {
        \lipsum_range_to_tokenlist:VV
          { \l_tmpa_int }{ \l_tmpb_int }
        \tl_use:N \l__lipsum_pars_tl
      }
      {
        \__lipsum_ensure_parsable_output:
        \lipsum_range_to_tokenlist:VV
          { \l_tmpa_int }{ \l_tmpb_int }
        \lipsum_store_as_temp_ints:nn #3
        \cs_gset_nopar:Nx
          \__lipsum_expanded_paragraphs_terminated_with_space:
          {\tl_use:N\l__lipsum_pars_tl}
        \lipsum_sentences_to_tokenlist:VVf
          { \l_tmpa_int }
          { \l_tmpb_int }
          \__lipsum_expanded_paragraphs_terminated_with_space:
        \tl_use:N \l__lipsum_sentences_tl
      }
    \group_end:
  }
\NewDocumentCommand\lipsumexp{}{}
\cs_new:Nn \__lipsum_expanded: {}
\NewDocumentCommand
  \unpacklipsum
  {
    s
    >{\__lipsum_split_argument_expanded:nne{1}{-}}
      O{\g_lipsum_default_range_tl}
    >{\__lipsum_split_argument_expanded:nne{1}{-}}
      o
  }
  {

    \group_begin:
      \lipsum_store_as_temp_ints:nn #2
      \IfBooleanTF {#1}
        {
          \__lipsum_set_surrounding_tokens_star:
        }
        {
          \__lipsum_set_surrounding_tokens_nostar:
        }
    \IfNoValueTF{#3}
      {
        \lipsum_range_to_tokenlist:VV
          { \l_tmpa_int } { \l_tmpb_int }
        \cs_gset:Nx
          \__lipsum_expanded: {\tl_use:N\l__lipsum_pars_tl}
        \cs_gset_eq:NN
          \lipsumexp \__lipsum_expanded:
      }
      {
        \__lipsum_ensure_parsable_output:
        \lipsum_range_to_tokenlist:VV
          { \l_tmpa_int } { \l_tmpb_int }
        \cs_gset_nopar:Nx
          \__lipsum_expanded_paragraphs_terminated_with_space:
          { \tl_use:N\l__lipsum_pars_tl }
        \lipsum_store_as_temp_ints:nn #3
        \lipsum_sentences_to_tokenlist:VVf
          { \l_tmpa_int }
          { \l_tmpb_int }
          \__lipsum_expanded_paragraphs_terminated_with_space:
        \cs_gset:Nx
          \__lipsum_expanded:
          { \tl_use:N\l__lipsum_sentences_tl }
        \cs_gset_eq:NN
          \lipsumexp \__lipsum_expanded:
      }
    \group_end:
  }
\NewDocumentCommand\IfLipsumText{mmm}{%
  \str_if_eq:VnTF\g__lipsum_text_str{#1}{#2}{#3}
}
\NewDocumentCommand\SetLipsumText{m}{%
  \IfLipsumText{#1}{}{
    \seq_gclear:N\g__lipsum_paragraph_seq
    \file_input:n{#1.ltd}
    \str_gset:Nn\g__lipsum_text_str{#1}
  }
}


\cs_new:Nn \__lipsum_restore_sentence_list: {
  \SetLipsumSentenceListItemSeparator{\space}
  \SetLipsumSentenceListItemSeparator*{\space}
  \SetLipsumSentenceListSurrounders{}{}
  \SetLipsumSentenceListSurrounders*{}{}
  \SetLipsumSentenceListItemSurrounders*{}{}
  \SetLipsumSentenceListItemSurrounders{}{}
}
\cs_new:Nn \__lipsum_restore_par_list: {
  \SetLipsumParListItemSeparator{\par}
  \SetLipsumParListItemSeparator*{\space}
  \SetLipsumParListSurrounders{}{}
  \SetLipsumParListSurrounders*{}{}
  \SetLipsumParListItemSurrounders*{}{}
  \SetLipsumParListItemSurrounders{}{}
}

\DeclareOption{nopar}{%
  \cs_gset:Nn \__lipsum_restore_sentence_list: {
    \SetLipsumSentenceListItemSeparator{\space}
    \SetLipsumSentenceListItemSeparator*{\space}
    \SetLipsumSentenceListEnd{}
    \SetLipsumSentenceListEnd*{}
    \SetLipsumSentenceListItemSurrounders*{}{}
    \SetLipsumSentenceListItemSurrounders{}{}
  }
  \cs_gset:Nn \__lipsum_restore_par_list: {
    \SetLipsumParListItemSeparator{\space}
    \SetLipsumParListItemSeparator*{\par}
    \SetLipsumParListEnd{}
    \SetLipsumParListEnd*{}
    \SetLipsumParListItemSurrounders*{}{}
    \SetLipsumParListItemSurrounders{}{}
  }
}
\ProcessOptions
\NewDocumentCommand\LipsumRestoreParList{}{}
\cs_gset_eq:NN
  \LipsumRestoreParList
  \__lipsum_restore_par_list:
\NewDocumentCommand\LipsumRestoreSentenceList{}{}
\cs_gset_eq:NN
  \LipsumRestoreSentenceList
  \__lipsum_restore_sentence_list:
\NewDocumentCommand\LipsumRestoreAll{}{
  \LipsumRestoreParList
  \LipsumRestoreSentenceList
}
\LipsumRestoreAll
\ExplSyntaxOff

\SetLipsumDefault{1-7}
\SetLipsumText{lipsum}
%% 
%%
%% End of file `lipsum.sty'.
