diff options
Diffstat (limited to 'Master/texmf-dist/source/latex/l3packages/xparse/xparse.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/l3packages/xparse/xparse.dtx | 110 |
1 files changed, 82 insertions, 28 deletions
diff --git a/Master/texmf-dist/source/latex/l3packages/xparse/xparse.dtx b/Master/texmf-dist/source/latex/l3packages/xparse/xparse.dtx index 67b80d5358a..64a7cb504d9 100644 --- a/Master/texmf-dist/source/latex/l3packages/xparse/xparse.dtx +++ b/Master/texmf-dist/source/latex/l3packages/xparse/xparse.dtx @@ -4,7 +4,7 @@ %% David Carlisle %% (C) Copyright 2004-2008 Frank Mittelbach, %% The LaTeX3 Project -%% (C) Copyright 2009-2012 The LaTeX3 Project +%% (C) Copyright 2009-2013 The LaTeX3 Project %% %% It may be distributed and/or modified under the conditions of the %% LaTeX Project Public License (LPPL), either version 1.3c of this @@ -41,8 +41,8 @@ %<*driver|package> % The version of expl3 required is tested as early as possible, as % some really old versions do not define \ProvidesExplPackage. -\RequirePackage{expl3}[2012/12/21] -%<package>\@ifpackagelater{expl3}{2012/12/21} +\RequirePackage{expl3}[2013/03/12] +%<package>\@ifpackagelater{expl3}{2013/03/12} %<package> {} %<package> {% %<package> \PackageError{xparse}{Support package l3kernel too old} @@ -54,7 +54,7 @@ %<package> }% %<package> \endinput %<package> } -\GetIdInfo$Id: xparse.dtx 4390 2012-12-21 06:59:20Z joseph $ +\GetIdInfo$Id: xparse.dtx 4467 2013-03-12 08:29:05Z joseph $ {L3 Experimental document command parser} %</driver|package> %<*driver> @@ -200,24 +200,19 @@ % `|s o o m O{default}|', the input `|*[Foo]{Bar}|' would be parsed as: % \begin{itemize}[nolistsep] % \item |#1| = |\BooleanTrue| -% \item |#2| = |{Foo}| +% \item |#2| = |Foo| % \item |#3| = |-NoValue-| -% \item |#4| = |{Bar}| -% \item |#5| = |{default}| +% \item |#4| = |Bar| +% \item |#5| = |default| % \end{itemize} % whereas `|[One][Two]{}[Three]|' would be parsed as: % \begin{itemize}[nolistsep] % \item |#1| = |\BooleanFalse| -% \item |#2| = |{One}| -% \item |#3| = |{Two}| -% \item |#4| = |{}| -% \item |#5| = |{Three}| +% \item |#2| = |One| +% \item |#3| = |Two| +% \item |#4| = || +% \item |#5| = |Three| % \end{itemize} -% Note that after parsing the input there will be always exactly the -% same number of \meta{balanced text} arguments as the number of letters -% in the argument specifier. The \cs{BooleanTrue} and \cs{BooleanFalse} -% tokens are passed without braces; all other arguments are passed as -% brace groups. % % Delimited argument types (\texttt{d}, \texttt{o} and \texttt{r}) are % defined such that they require matched pairs of delimiters when collecting @@ -230,6 +225,20 @@ % Also note that |{| and |}| cannot be used as delimiters as they are used % by \TeX{} as grouping tokens. Arguments to be grabbed inside these tokens % must be created as either \texttt{m}- or \texttt{g}-type arguments. +% +% Within delimited arguments, non-balanced or otherwise awkward tokens may +% be included by protecting the entire argument with a brace pair +% \begin{verbatim} +% \DeclareDocumentCommand{\foo}{o}{#1} +% \foo[{[}] % Allowed as the "[" is 'hidden' +% \end{verbatim} +% These braces will be stripped if they surround the \emph{entire} content +% of the optional argument +% \begin{verbatim} +% \DeclareDocumentCommand{\foo}{o}{#1} +% \foo[{abc}] % => "abc" +% \foo[ {abc}] % => " {abc}" +% \end{verbatim} % % Two more tokens have a special meaning when creating an argument % specifier. First, \texttt{+} is used to make an argument long (to @@ -1868,6 +1877,13 @@ #4 \l_@@_args_tl } } +% \end{macrocode} +% Inside the \enquote{standard} grabber, there is a test to see if the +% grabbed argument is entirely enclosed by braces. There are a couple of +% extra factors to allow for: the argument might be entirely empty, and +% spaces at the start and end of the input must be retained around a brace +% group. +% \begin{macrocode} \cs_new_protected:Npn \@@_grab_D_aux:NNnN #1#2#3#4 { \cs_set_protected_nopar:Npn \@@_grab_arg:w @@ -1877,7 +1893,15 @@ \tl_if_in:nnTF {####1} {#1} { \@@_grab_D_nested:NNnnN #1 #2 {####1} {#3} #4 } { - \@@_add_arg:o { \use_none:n ####1 } + \tl_if_blank:oTF { \use_none:n ####1 } + { \@@_add_arg:o { \use_none:n ####1 } } + { + \str_if_eq_x:nnTF + { \exp_not:o { \use_none:n ####1 } } + { { \exp_not:o { \use_ii:nnn ####1 \q_nil } } } + { \@@_add_arg:o { \use_ii:nn ####1 } } + { \@@_add_arg:o { \use_none:n ####1 } } + } #3 \l_@@_args_tl } } @@ -2683,14 +2707,23 @@ % delimiter. In that case, we are done, and put the argument (from which we % remove a spurious pair of delimiters coming from how we started the loop). % Otherwise, we go back to looping with -% \cs{@@_expandable_grab_D:NNNwNnnn}. +% \cs{@@_expandable_grab_D:NNNwNnnn}. The code to deal with brace stripping +% is much the same as for the non-expandable case. % \begin{macrocode} \cs_new:Npn \@@_expandable_grab_D:nnNNNwN #1#2#3#4#5#6 \q_@@ #7 { \exp_args:No \tl_if_empty:oTF { #3 { \use_none:nnn } #2 \q_@@ #5 #4 \q_@@ #5 } { - \@@_put_arg_expandable:ow { \use_none:nn #1#2 } + \tl_if_blank:oTF { \use_none:nn #1#2 } + { \@@_put_arg_expandable:ow { } } + { + \str_if_eq_x:nnTF + { \exp_not:o { \use_none:nn #1#2 } } + { { \exp_not:o { \use_iii:nnnn #1#2 \q_nil } } } + { \@@_put_arg_expandable:ow { \use_iii:nnn #1#2 } } + { \@@_put_arg_expandable:ow { \use_none:nn #1#2 } } + } #6 \q_@@ #7 } { @@ -2709,7 +2742,7 @@ % \begin{macro}[EXP]{\@@_expandable_grab_D_alt:w} % \begin{macro}[EXP]{\@@_expandable_grab_D_alt:NNnwNn} % \begin{macro}[EXP]{\@@_expandable_grab_D_alt:Nw} -% When the delimiters are identical, nesting is not possble and a simplified +% When the delimiters are identical, nesting is not possible and a simplified % approach is used. The test concept here is the same as for the case where % the delimiters are different. % \begin{macrocode} @@ -2728,7 +2761,18 @@ { #4 {#3} \q_@@ #5 {#6} } } \cs_new:Npn \@@_expandable_grab_D_alt:Nwn #1#2 \q_@@ #3 - { \@@_put_arg_expandable:ow { \use_none:n #3 } #2 \q_@@ #1 } + { + \tl_if_blank:oTF { \use_none:nn #1#2 } + { \@@_put_arg_expandable:ow { } } + { + \str_if_eq_x:nnTF + { \exp_not:o { \use_none:n #3 } } + { { \exp_not:o { \use_ii:nnn #3 \q_nil } } } + { \@@_put_arg_expandable:ow { \use_ii:nn #3 } } + { \@@_put_arg_expandable:ow { \use_none:n #3 } } + } + #2 \q_@@ #1 + } % \end{macrocode} % \end{macro} % \end{macro} @@ -3405,19 +3449,29 @@ % \end{macro} % % \subsection{Package options} -% -% A faked key--value option to keep the log clean. Not yet perfect, but -% better than nothing. +% +% \begin{variable}{\l_@@_options_clist} +% \begin{variable}{\l_@@_log_bool} +% Key--value option to log information: done by hand to keep dependencies +% down. % \begin{macrocode} -\DeclareOption { log-declarations = true } { } -\DeclareOption { log-declarations = false } +\clist_new:N \l_@@_options_clist +\DeclareOption* { \clist_put_right:NV \l_@@_options_clist \CurrentOption } +\ProcessOptions \relax +\keys_define:nn { xparse } + { + log-declarations .bool_set:N = \l_@@_log_bool , + log-declarations .initial:n = true + } +\keys_set:nV { xparse } \l_@@_options_clist +\bool_if:NF \l_@@_log_bool { \msg_redirect_module:nnn { LaTeX / xparse } { info } { none } \msg_redirect_module:nnn { LaTeX / xparse } { warning } { none } } -\DeclareOption { log-declarations } { } -\ProcessOptions \scan_stop: % \end{macrocode} +% \end{variable} +% \end{variable} % % \begin{macrocode} %</package> |