[latex3-commits] [git/LaTeX3-latex3-latex3] gh839: Allow alignment tab token in delimited argument (fixes #839) (c472d9c3c)
PhelypeOleinik
phelype.oleinik at latex-project.org
Wed Jan 13 02:28:15 CET 2021
Repository : https://github.com/latex3/latex3
On branch : gh839
Link : https://github.com/latex3/latex3/commit/c472d9c3c0950e52bc3925479ffd35e0b8c68238
>---------------------------------------------------------------
commit c472d9c3c0950e52bc3925479ffd35e0b8c68238
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date: Tue Jan 12 22:28:15 2021 -0300
Allow alignment tab token in delimited argument (fixes #839)
>---------------------------------------------------------------
c472d9c3c0950e52bc3925479ffd35e0b8c68238
l3packages/xparse/xparse.dtx | 24 ++++++++++++++++++------
1 file changed, 18 insertions(+), 6 deletions(-)
diff --git a/l3packages/xparse/xparse.dtx b/l3packages/xparse/xparse.dtx
index eeae7fdf2..a4ef444b8 100644
--- a/l3packages/xparse/xparse.dtx
+++ b/l3packages/xparse/xparse.dtx
@@ -1536,11 +1536,16 @@
% \cs{scan_stop:}, whose name gives a reasonable error message if the
% command is used inside a csname and protects against
% \texttt{f}-expansion. This is useless for environments since
-% \cs{begin} is already not expandable.
+% \cs{begin} is already not expandable. Both the command and
+% environment codes start with \cs{group_align_safe_begin:}, then
+% \cs{@@_run_code:} (used by both) does \cs{group_align_safe_end:}, so
+% that delimited arguments may be grabbed in alignments if they
+% contain and alignment tab token (see latex3/latex3/issues/839).
% \begin{macrocode}
\cs_new_protected:Npn \@@_start_env:nnnnn #1#2
{
\cs_if_exist_use:N \conditionally at traceoff
+ \group_align_safe_begin:
\str_set:Nn \l_@@_environment_str {#2}
\bool_set_true:N \l_@@_environment_bool
\@@_start_aux:ccnnnn
@@ -1552,6 +1557,7 @@
{
\exp_not:c { xparse~function~is~not~expandable }
\exp_not:n { \cs_if_exist_use:N \conditionally at traceoff }
+ \exp_not:N \group_align_safe_begin:
\exp_not:n { \bool_set_false:N \l_@@_environment_bool }
\exp_not:N \@@_start_aux:NNnnnn
#2 #3 {#1}
@@ -1580,13 +1586,14 @@
%
% \begin{macro}{\@@_run_code:}
% After arguments are grabbed, this function is responsible for
-% inserting default values, running processors, and finally running
-% the code.
+% inserting default values, running processors, and finally doing
+% \cs{group_align_safe_end:} as promised, and running the code.
% \begin{macrocode}
\cs_new_protected:Npn \@@_run_code:
{
\tl_if_empty:NF \l_@@_defaults_tl { \@@_defaults: }
\tl_if_empty:NF \l_@@_process_all_tl { \@@_args_process: }
+ \group_align_safe_end:
\cs_if_exist_use:N \conditionally at traceon
\exp_after:wN \l_@@_fn_code_tl \l_@@_args_tl
}
@@ -1713,10 +1720,15 @@
% default values (or is |?| if there are none). |#4| is the code to run.
% |#2|~and~|#3| are functions (named after the command) that grab a single
% argument in the input stream (|#3|~is~short). The argument specification |#1| is
-% only used by diagnostic functions.
+% only used by diagnostic functions. Same as for the non-expandable
+% version, this starts with \cs{group_align_safe_begin:}, which
+% expands to nothing, so may be safely used in an expandable context.
% \begin{macrocode}
\cs_new:Npn \@@_start_expandable:nNNNNn #1#2#3#4#5#6
- { #6 \@@_end_expandable:NNw #5 #4 \q_@@ #2#3 }
+ {
+ \group_align_safe_begin:
+ #6 \@@_end_expandable:NNw #5 #4 \q_@@ #2#3
+ }
% \end{macrocode}
% \end{macro}
%
@@ -1759,7 +1771,7 @@
{
#6
\str_if_eq:nnTF {#1} {#2}
- { \use_i_delimit_by_q_stop:nw { #5 #1 } }
+ { \use_i_delimit_by_q_stop:nw { \group_align_safe_end: #5 #1 } }
{
\exp_args:No \@@_tl_mapthread_function:nnN
{ #4 #1 } {#3}
More information about the latex3-commits
mailing list.