-
-
Notifications
You must be signed in to change notification settings - Fork 266
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
When using \KeyValue, lttemplates and xtemplate have different results #1486
Comments
Ah, I see what's happened - I streamlined the auxiliaries a bit, but I'd not allowed for the fact that there needs to be different handling for token lists and registers in terms for |
947d414 (Re-factor internals for template var setting, 2024-04-15) merged various Try this \RequirePackage{latexbug}
\documentclass{article}
\ExplSyntaxOn
\cs_undefine:N \__template_assign_variable:
\cs_new_protected:Npn \__template_assign_variable:
{
\exp_args:Nee \__template_assign_variable:nn
{ \__template_map_var_type: }
{ \bool_if:NT \l__template_global_bool { g } }
}
\cs_new_protected:Npn \__template_assign_variable:nn #1#2
{
\str_case_e:nnTF { #1 }
{
{ tl } {}
{ clist } {}
}
% tl and clist need :NV if \l__template_value_tl starts with \KeyValue
% see https://github.com/latex3/latex2e/commit/947d41437824b2a69ef0a3644128c574ae6f72df
{ \__template_assign_variable:cc { #1 _ #2 set:NV } { #1 _ #2 set:Nn } }
{ \__template_assign_variable:cc { #1 _ #2 set:Nn } { #1 _ #2 set:Nn } }
}
\cs_new_protected:Npn \__template_assign_variable:NN #1#2
{
\__template_if_key_value:VTF \l__template_value_tl
{
\__template_key_to_value:
\tl_put_right:Ne \l__template_assignments_tl
{
#1 \exp_not:V \l__template_var_tl
{ \exp_not:V \l__template_value_tl }
}
}
{
\tl_put_right:Ne \l__template_assignments_tl
{
#2 \exp_not:V \l__template_var_tl
{ \exp_not:V \l__template_value_tl }
}
}
\tl_show:N \l__template_assignments_tl
}
\cs_generate_variant:Nn \__template_assign_variable:NN {cc}
\ExplSyntaxOff
\ExplSyntaxOff
\ifdefined\NewTemplateType
\NewTemplateType{foo}{0} % current LaTeX version
\else
\usepackage{xtemplate} % TeXLive 2023
\DeclareObjectType{foo}{0}
\fi
\def\foocode{}
\DeclareTemplateInterface{foo}{FOO}{0}
{
foo.code : tokenlist ,
code.foo : tokenlist = \KeyValue{foo.code} ,
}
\DeclareTemplateCode{foo}{FOO}{0}
{
foo.code = \foocode ,
code.foo = \foocode ,
}
{\AssignTemplateKeys (\foocode)}
\DeclareInstance{foo}{i1}{FOO}{ foo.code=A }
\DeclareInstance{foo}{i2}{FOO}{ code.foo=B }
\begin{document}
\UseInstance{foo}{i1} % typesets "(A)"
\UseInstance{foo}{i2} % typesets "(B)"
\end{document} |
We also need to cover |
Also, there are some stray braces (likely going back a long way - perhaps we had |
As I'm far from familiar with |
Not necessary, as BTW the test needed here is similar to the logic in |
True but I think we might be best off simply making a clear distinction. Anyway, do you want to do it, or should I? |
|
I have a shorter approach I'll go with: PR very shortly |
Brief outline of the bug
When using
\KeyValue
,lttemplates
andxtemplate
have different results.lttemplates
may cause endless loop.Minimal example showing the bug
Overleaf with TeXLive 2023 works well, but on my computer, there is an endless loop.
It seems there is no
\__xtemplate_assign_tokenlist:
inlttemplates
https://github.com/latex3/latex3/blob/1a856471a905fe70b564ff645f6f390bd2a019af/l3packages/xtemplate/xtemplate-2023-10-10.sty#L971-L995
I simply put them in the preamble replaced
xtemplate
withtemplate
and changed\__xtemplate_if_key_value:oTF
to\__template_if_key_value:VTF
, it works as in TeXLive 2023.Log file (required) and possibly PDF file
demo.log
The text was updated successfully, but these errors were encountered: