[latex3-commits] [git/LaTeX3-latex3-latex3] cs-delimited-args: Support control sequences as argument delimiters (e2a9003ce)

PhelypeOleinik tex.phelype at gmail.com
Tue Feb 25 16:29:04 CET 2020


Repository : https://github.com/latex3/latex3
On branch  : cs-delimited-args
Link       : https://github.com/latex3/latex3/commit/e2a9003ce38cf016ba9b6bdd214f5ab8ea13251d

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

commit e2a9003ce38cf016ba9b6bdd214f5ab8ea13251d
Author: PhelypeOleinik <tex.phelype at gmail.com>
Date:   Tue Feb 25 12:29:04 2020 -0300

    Support control sequences as argument delimiters


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

e2a9003ce38cf016ba9b6bdd214f5ab8ea13251d
 l3packages/xparse/xparse.dtx | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/l3packages/xparse/xparse.dtx b/l3packages/xparse/xparse.dtx
index fc0164a8c..5a74dcbb2 100644
--- a/l3packages/xparse/xparse.dtx
+++ b/l3packages/xparse/xparse.dtx
@@ -2991,6 +2991,12 @@
 %   the grabber. (This assumes that the open and close delimiters are not the
 %   same character with different category codes, but that really should not
 %   happen in any sensible document-level syntax.)
+%   An exception is when |#1| is a control sequence token, in which case the
+%   character-token treatment is no good because if hit with \cs{token_to_str:N}
+%   it would add sputios tokens to the argument. In this case a different
+%   branch is taken. The token inserted is then the same \meta{csname} as |#1|,
+%   but with a space appended, so that the grabber don't see it as another
+%   of the same delimiter.
 %    \begin{macrocode}
 \cs_new_protected_nopar:Npn \@@_grab_D_call:Nw #1
   {
@@ -3000,8 +3006,15 @@
           \l_@@_fn_tl \char_generate:nn { `#1 } { 11 }
       }
       {
-        \exp_after:wN \l_@@_fn_tl
-        \token_to_str:N #1
+        \token_if_cs:NTF #1
+          {
+            \exp_after:wN \l_@@_fn_tl
+            \cs:w \cs_to_str:N #1 ~ \cs_end:
+          }
+          {
+            \exp_after:wN \l_@@_fn_tl
+            \token_to_str:N #1
+          }
       }
   }
 %    \end{macrocode}





More information about the latex3-commits mailing list.