[latex3-commits] [git/LaTeX3-latex3-latex3] main: Document how to get tl head/tail with space (8ea5fe93d)

Joseph Wright joseph.wright at morningstar2.co.uk
Mon Jun 27 08:25:52 CEST 2022


Repository : https://github.com/latex3/latex3
On branch  : main
Link       : https://github.com/latex3/latex3/commit/8ea5fe93d42640426a5a9f2cdc34d56c9aaf8dfa

>---------------------------------------------------------------

commit 8ea5fe93d42640426a5a9f2cdc34d56c9aaf8dfa
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Mon Jun 27 07:25:52 2022 +0100

    Document how to get tl head/tail with space
    
    This fixes #1092.


>---------------------------------------------------------------

8ea5fe93d42640426a5a9f2cdc34d56c9aaf8dfa
 l3kernel/l3tl.dtx | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/l3kernel/l3tl.dtx b/l3kernel/l3tl.dtx
index 2f00437a6..d5da4a17a 100644
--- a/l3kernel/l3tl.dtx
+++ b/l3kernel/l3tl.dtx
@@ -927,6 +927,26 @@
 %   \end{texnote}
 % \end{function}
 %
+% If you wish to handle token lists where the first token may be a space, and
+% this needs to be treated as the head/tail, this can be accomplished using
+% \cs{tl_if_head_is_space:nTF}, for example
+% \begin{verbatim}
+%   \exp_last_unbraced:NNo
+%     \cs_new:Npn \__mypkg_gobble_space:w \c_space_tl { }
+%   \cs_new:Npn \mypkg_tl_head_keep_space:n #1
+%     {
+%       \tl_if_head_is_space:nTF {#1}
+%         { ~ }
+%         { \tl_head:n {#1} }
+%     }
+%   \cs_new:Npn \mypkg_tl_tail_keep_space:n #1
+%     {
+%       \tl_if_head_is_space:nTF {#1}
+%         { \exp_not:o { \__mypkg_gobble_space:w #1 } }
+%         { \tl_tail:n {#1} }
+%     }
+% \end{verbatim}
+%
 % \subsection{Items and ranges in token lists}
 %
 % \begin{function}[added = 2014-07-17, EXP]





More information about the latex3-commits mailing list.