[latex3-commits] [latex3/latex2e] develop: Expand variable contents when passing \KeyValue content (fixes #1486) (193bfa8d)

github at latex-project.org github at latex-project.org
Tue Oct 8 14:50:03 CEST 2024


Repository : https://github.com/latex3/latex2e
On branch  : develop
Link       : https://github.com/latex3/latex2e/commit/193bfa8d42b48925f0615a8be46b23498e3c44e5

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

commit 193bfa8d42b48925f0615a8be46b23498e3c44e5
Author: Joseph Wright <joseph at texdev.net>
Date:   Mon Oct 7 12:23:29 2024 +0100

    Expand variable contents when passing \KeyValue content (fixes #1486)


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

193bfa8d42b48925f0615a8be46b23498e3c44e5
 base/changes.txt                              |  6 +++-
 base/lttemplates.dtx                          | 40 ++++++++++++++++++---------
 base/testfiles-lttemplates/lttemplates005.lvt |  5 +++-
 base/testfiles-lttemplates/lttemplates005.tlg |  1 +
 4 files changed, 37 insertions(+), 15 deletions(-)

diff --git a/base/changes.txt b/base/changes.txt
index 66f76188..ed2c5848 100644
--- a/base/changes.txt
+++ b/base/changes.txt
@@ -5,6 +5,11 @@ hotfixes). It is provided for convenience only.  It therefore makes no claims
 to completeness or accuracy and it contains some references to files that are
 not part of the distribution.
 ================================================================================
+
+2024-10-07  Joseph Wright  <Joseph.Wright at latex-project.org>
+	* lttemplates.dtx
+	Correct passing of token list content using \KeyValue
+
 2024-10-02 Ulrike Fischer <Ulrike.Fischer at latex-project.org>
 	* lttagging.dtx: restore also paratagging in the para/restore socket, 
 	see https://github.com/latex3/tagging-project/issues/723
@@ -17,7 +22,6 @@ not part of the distribution.
 	* lttagging.dtx: declare tagging sockets for floats and caption.
 
 2024-09-15  Joseph Wright  <Joseph.Wright at latex-project.org>
-
 	* lttemplates-doc.tex, lttemplates-code.tex:
 	New files
 	* clsguide.tex
diff --git a/base/lttemplates.dtx b/base/lttemplates.dtx
index a25fac9d..66a69c17 100644
--- a/base/lttemplates.dtx
+++ b/base/lttemplates.dtx
@@ -36,7 +36,7 @@
 %<*driver>
 % \fi
 \ProvidesFile{lttemplates.dtx}
-  [2024-08-28 v1.0c LaTeX Kernel (Prototype document functions)]
+  [2024-10-07 v1.0d LaTeX Kernel (Prototype document functions)]
 % \iffalse
 \documentclass{l3doc}
 \GetFileInfo{lttemplates.dtx}
@@ -2098,30 +2098,44 @@
 % \end{macro}
 %
 % \begin{macro}{\@@_assign_variable:}
-% \begin{macro}{\@@_assign_variable:N, \@@_assign_variable:c}
+% \changes{2024-10-07}{v1.0d}{Correct passing of \cs{KeyValue} contents}
+% \begin{macro}{\@@_assign_variable:n}
 %   A general-purpose function for all of the other assignments.
 %   As long as the value is not coming from another variable, the stored
-%   value is simply transferred for output.
+%   value is simply transferred for output. We use \texttt{V}-type expansion
+%   for the \cs{KeyValue} case: for token lists this is essential, whilst
+%   for register-based variables, it does no harm and avoids needing a
+%   low-level test.
 %    \begin{macrocode}
 \cs_new_protected:Npn \@@_assign_variable:
   {
-    \@@_assign_variable:c
+    \exp_args:Ne \@@_assign_variable:n
       {
-        \@@_map_var_type: _
-        \bool_if:NT \l_@@_global_bool { g } set:Nn
+        \@@_map_var_type:
+        _
+        \bool_if:NT \l_@@_global_bool { g } 
+        set:N
       }
   }
-\cs_new_protected:Npn \@@_assign_variable:N #1
+\cs_new_protected:Npn \@@_assign_variable:n #1
   {
-    \@@_if_key_value:VT \l_@@_value_tl
-      { \@@_key_to_value: }
-    \tl_put_right:Ne \l_@@_assignments_tl
+    \@@_if_key_value:VTF \l_@@_value_tl
       {
-        #1 \exp_not:V \l_@@_var_tl
-         { \exp_not:V \l_@@_value_tl }
+        \@@_key_to_value:
+        \tl_put_right:Ne \l_@@_assignments_tl
+          {
+            \exp_not:c { #1 V } \exp_not:V \l_@@_var_tl
+             \exp_not:V \l_@@_value_tl
+          }
+      }
+      {
+        \tl_put_right:Ne \l_@@_assignments_tl
+          {
+            \exp_not:c { #1 n } \exp_not:V \l_@@_var_tl
+             { \exp_not:V \l_@@_value_tl }
+          }
       }
   }
-\cs_generate_variant:Nn \@@_assign_variable:N { c }
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
diff --git a/base/testfiles-lttemplates/lttemplates005.lvt b/base/testfiles-lttemplates/lttemplates005.lvt
index 5243dc85..ee85f8a9 100644
--- a/base/testfiles-lttemplates/lttemplates005.lvt
+++ b/base/testfiles-lttemplates/lttemplates005.lvt
@@ -52,17 +52,20 @@
       dim-b : length    = \KeyValue { dim-a } ,
       tl-a  : tokenlist = abc ,
       tl-b  : tokenlist = \KeyValue { tl-a } ,
+      tl-c  : tokenlist = \KeyValue { tl-a } ,
     }
   \DeclareTemplateCode { test } { std2 } { 0 }
     {
       dim-a = global \g_tmpa_dim ,
       dim-b = \l_tmpb_dim ,
       tl-a  = \l_tmpa_tl ,
-      tl-b  = \l_tmpb_tl
+      tl-b  = \l_tmpb_tl ,
+      tl-c  = \l_tmpa_tl
     }
     {
       \typeout { \dim_use:N \l_tmpb_dim }
       \typeout { \tl_use:N \l_tmpb_tl }
+      \typeout { \tl_use:N \l_tmpa_tl }
     }
   \DeclareInstance { test } { run } { std2 } { }
 
diff --git a/base/testfiles-lttemplates/lttemplates005.tlg b/base/testfiles-lttemplates/lttemplates005.tlg
index 20d83e71..7b5478e4 100644
--- a/base/testfiles-lttemplates/lttemplates005.tlg
+++ b/base/testfiles-lttemplates/lttemplates005.tlg
@@ -16,6 +16,7 @@ TEST 2: Key values with global
 ============================================================
 10.0pt
 abc
+abc
 ============================================================
 ============================================================
 TEST 3: Key values for booleans





More information about the latex3-commits mailing list.