[latex3-commits] [git/LaTeX3-latex3-latex3] main: More work on spaces in template keys (3a801be0e)

Joseph Wright joseph.wright at morningstar2.co.uk
Tue Jun 7 10:13:03 CEST 2022


Repository : https://github.com/latex3/latex3
On branch  : main
Link       : https://github.com/latex3/latex3/commit/3a801be0e5203f9e82a59b47014a9474983de9c8

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

commit 3a801be0e5203f9e82a59b47014a9474983de9c8
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Tue Jun 7 09:12:57 2022 +0100

    More work on spaces in template keys


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

3a801be0e5203f9e82a59b47014a9474983de9c8
 l3packages/xtemplate/testfiles/xtemplate001.lvt | 15 +++++++++++++-
 l3packages/xtemplate/testfiles/xtemplate001.tlg | 27 ++++++++++++++++++++++---
 l3packages/xtemplate/xtemplate.dtx              |  8 +++++---
 3 files changed, 43 insertions(+), 7 deletions(-)

diff --git a/l3packages/xtemplate/testfiles/xtemplate001.lvt b/l3packages/xtemplate/testfiles/xtemplate001.lvt
index c85794834..f3b90d221 100644
--- a/l3packages/xtemplate/testfiles/xtemplate001.lvt
+++ b/l3packages/xtemplate/testfiles/xtemplate001.lvt
@@ -19,6 +19,7 @@
 \DeclareObjectType { test-zero } 0
 \DeclareObjectType { test-one }  1
 \DeclareObjectType { test-two }  2
+\DeclareObjectType { test-three }  3
 \TIMO
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 \TEST{Making~object~types}{
@@ -46,7 +47,19 @@
   \DeclareTemplateInterface { undeclared } { template } 1 { }
 }
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
+\ExplSyntaxOff
+\TEST{Template~interfaces: spaces}{
+  \DeclareTemplateInterface{test-three}{template} 3 {
+    key-one   : tokenlist = default ,
+    key-two   : tokenlist           ,
+    key-three : integer   = 4       ,
+    key-four  : choice { one, two, three },
+    key-five  : code      = {#1}
+  }
+  \ShowTemplateKeytypes{test-three}{template}
+  \ShowTemplateDefaults{test-three}{template}
+}
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 
 \END
diff --git a/l3packages/xtemplate/testfiles/xtemplate001.tlg b/l3packages/xtemplate/testfiles/xtemplate001.tlg
index 1a3776733..70a8d02e7 100644
--- a/l3packages/xtemplate/testfiles/xtemplate001.tlg
+++ b/l3packages/xtemplate/testfiles/xtemplate001.tlg
@@ -5,11 +5,11 @@ Author: Joseph Wright
 TEST 1: Making object types
 ============================================================
 Package xtemplate Info: Declaring object type 'test' taking 0 argument(s) on
-(xtemplate)             line 28.
+(xtemplate)             line 29.
 Package xtemplate Info: Declaring object type 'test' taking 1 argument(s) on
-(xtemplate)             line 28.
+(xtemplate)             line 29.
 Package xtemplate Info: Declaring object type 'test' taking 2 argument(s) on
-(xtemplate)             line 28.
+(xtemplate)             line 29.
 ============================================================
 ============================================================
 TEST 2: Template interfaces: correct
@@ -62,3 +62,24 @@ For immediate help type H <return>.
 l. ...}
 An object type needs to be declared with \DeclareObjectType prior to using it.
 ============================================================
+============================================================
+TEST 4: Template~interfaces: spaces
+============================================================
+Defining \template defaults > test-three/template on line ...
+Defining \template key types > test-three/template on line ...
+Defining \template key order > test-three/template on line ...
+The template 'template' of object type 'test-three' has interface:
+>  key-one  =>  tokenlist
+>  key-two  =>  tokenlist
+>  key-three  =>  integer
+>  key-four  =>  choice{ one, two, three }
+>  key-five  =>  code.
+<recently read> }
+l. ...}
+The template 'template' of object type 'test-three' has default values:
+>  key-one  =>  default
+>  key-three  =>  4
+>  key-five  =>  ##1.
+<recently read> }
+l. ...}
+============================================================
diff --git a/l3packages/xtemplate/xtemplate.dtx b/l3packages/xtemplate/xtemplate.dtx
index 9894be538..a1a99aaa7 100644
--- a/l3packages/xtemplate/xtemplate.dtx
+++ b/l3packages/xtemplate/xtemplate.dtx
@@ -1399,10 +1399,12 @@
             \cs_set:Npn \@@_split_keytype_arg_aux:w
               ####1 ##1 ####2 \s_@@_stop
               {
-                \tl_if_empty:nT {####1}
+                \tl_if_blank:nT {####1}
                   {
-                    \tl_set:Nn \l_@@_keytype_tl {##1}
-                    \tl_set:Nn \l_@@_keytype_arg_tl {####2}
+                    \tl_set:Nx \l_@@_keytype_tl
+                      { \tl_trim_spaces:n {##1} }
+                    \tl_set:Nx \l_@@_keytype_arg_tl
+                      { \use:n ####2 }
                     \seq_map_break:
                   }
               }





More information about the latex3-commits mailing list.