Skip to content

Commit

Permalink
Expand variable contents when passing \KeyValue content (fixes #1486)
Browse files Browse the repository at this point in the history
  • Loading branch information
josephwright committed Oct 7, 2024
1 parent d508a8d commit 9444a90
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 14 deletions.
6 changes: 5 additions & 1 deletion base/changes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
* lttemplates.dtx
Correct passing of token list content using \KeyValue

2024-10-02 Ulrike Fischer <[email protected]>
* lttagging.dtx: restore also paratagging in the para/restore socket,
see https://github.com/latex3/tagging-project/issues/723
Expand All @@ -17,7 +22,6 @@ not part of the distribution.
* lttagging.dtx: declare tagging sockets for floats and caption.

2024-09-15 Joseph Wright <[email protected]>

* lttemplates-doc.tex, lttemplates-code.tex:
New files
* clsguide.tex
Expand Down
37 changes: 25 additions & 12 deletions base/lttemplates.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -2098,30 +2098,43 @@
% \end{macro}
%
% \begin{macro}{\@@_assign_variable:}
% \begin{macro}{\@@_assign_variable:N, \@@_assign_variable:c}
% \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}
Expand Down
5 changes: 4 additions & 1 deletion base/testfiles-lttemplates/lttemplates005.lvt
Original file line number Diff line number Diff line change
Expand Up @@ -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 } { }

Expand Down
1 change: 1 addition & 0 deletions base/testfiles-lttemplates/lttemplates005.tlg
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ TEST 2: Key values with global
============================================================
10.0pt
abc
abc
============================================================
============================================================
TEST 3: Key values for booleans
Expand Down

0 comments on commit 9444a90

Please sign in to comment.