Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
29 changes: 19 additions & 10 deletions base/doc/ltnews40.tex
Original file line number Diff line number Diff line change
Expand Up @@ -379,19 +379,28 @@ \section{Improvement to \XeTeX\ \cs{showhyphens}}
\githubissue{1380}


\section{Avoid code duplication in rollback}

When the kernel uses \cs{AddToHook} in a region that might be
rolled back (which happens in a few places) and a document requests a
rollback, then we have the situation that the hook already contains code to which we added the same
(or slightly different) code during the
rollback; this results in code duplication or, worse, in errors. This has
now been corrected by dropping any such code chunk (if there is one) prior to
adding the rollback code.
\section{Passing template keys using \cs{KeyValue}}

With the move of the template code to the kernel, some internal efficiencies
were also made. However, there was an oversight in how passing key values from
one setting to another was implemented, meaning that using \cs{KeyValue} could
result in an infinite loop. This has now been fixed.
%
\githubissue{1407}
\githubissue{1487}



\subsection{Handling of global keys with spaces}

If the global (class) options contained spaces around key names,
\cs{ProcessKeyOptions} would fail to remove known keys from the
list of unused global options and \cs{OptionNotUsed} would mistakenly
add space-surrounded key names to that list.
These has been corrected as a hotfix in patch level 1 of the November 2023
release (but unfortunately not mentioned in~\cite{40:ltnews38}) and
the current release, respectively.
%
\githubissue{1238}


\section{Changes to packages in the \pkg{amsmath} category}
Expand Down
40 changes: 27 additions & 13 deletions base/lttemplates.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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}
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