[latex3-commits] [git/LaTeX3-latex3-latex2e] gh569: Copy \end part of an environment (0f003912)
PhelypeOleinik
phelype.oleinik at latex-project.org
Mon Aug 30 05:20:58 CEST 2021
Repository : https://github.com/latex3/latex2e
On branch : gh569
Link : https://github.com/latex3/latex2e/commit/0f003912c1d1344f48b45dcda06a4127152d9c0d
>---------------------------------------------------------------
commit 0f003912c1d1344f48b45dcda06a4127152d9c0d
Author: PhelypeOleinik <phelype.oleinik at latex-project.org>
Date: Mon Aug 30 00:20:58 2021 -0300
Copy \end part of an environment
A lot of the code goes for checking if the command is valid. Actually copying is pretty simple.
>---------------------------------------------------------------
0f003912c1d1344f48b45dcda06a4127152d9c0d
base/ltcmd.dtx | 42 +++++++++++++++++++++++++++++++++++++-----
1 file changed, 37 insertions(+), 5 deletions(-)
diff --git a/base/ltcmd.dtx b/base/ltcmd.dtx
index 055b631f..4526ccc0 100644
--- a/base/ltcmd.dtx
+++ b/base/ltcmd.dtx
@@ -1991,11 +1991,13 @@
{ \msg_error:nnnn { cmd } { copy-bug } {#1} {#3} }
\msg_new:nnn { cmd } { copy-bug }
{
- Internal~error~while~copying~command~\iow_char:N\\#2:\\
+ Error~while~copying~command~\iow_char:N\\#2:\\
\str_case:nn {#1}
{
{ non-ltcmd } { Command~is~not~a~valid~ltcmd~command. }
{ unknown-type } { Found~an~unknown~argument~type. }
+ { invalid-end }
+ { Target~command~is~not~named~\iow_char:N \\end<name>. }
}
}
% \end{macrocode}
@@ -2210,10 +2212,40 @@
{ \exp_after:wN \@@_copy_environment:Nnnnnnn #4 {#1} }
\cs_set_eq:cc {#1} { environment~ #1 }
}
-\cs_new_protected:Npn \@@_copy_env_end:nnNN #1 #2 #3 #4
- { \msg_error:nn { cmd } { env-copy } }
-\msg_new:nnn { cmd } { env-copy }
- { Copying~environments~is~not~possible. }
+\cs_new:Npn \@@_copy_environment:Nnnnnnn #1 #2 #3 #4 #5 #6 #7
+ { #1 \exp_not:n { {#2} } {#7} \exp_not:n { {#4} {#5} {#6} } }
+\cs_new_protected:Npn \@@_copy_environment_end:nnNN #1 #2
+ {
+ \@@_check_end:Nn \l_@@_tmpa_tl {#1}
+ \@@_check_end:Nn \l_@@_tmpb_tl {#2}
+ \exp_args:Noo \@@_copy_environment_end_aux:nnNN
+ { \l_@@_tmpa_tl } { \l_@@_tmpb_tl }
+ }
+\cs_new_protected:Npn \@@_copy_environment_end_aux:nnNN #1 #2 #3 #4
+ {
+ \cs_set_nopar:cpx { environment~ #1 ~end }
+ { \exp_not:c { environment~ #1 ~end~aux } }
+ \cs_set_eq:cc
+ { environment~ #1 ~end~aux~ } { environment~ #2 ~end~aux~ }
+ \cs_set_eq:cc { end #1 } { environment~ #1 ~end }
+ }
+\cs_new_protected:Npn \@@_check_end:Nn #1 #2
+ {
+ \tl_set:Nx #1 { \@@_check_end:n {#2} }
+ \token_if_eq_meaning:NNT #1 \q_nil
+ { \@@_cant_copy:nwn { invalid-end } }
+ }
+\cs_set_protected:Npn \@@_tmp:w #1
+ {
+ \cs_new:Npn \@@_check_end:n ##1
+ {
+ \exp_after:wN \@@_check_end:w \tl_to_str:n {##1}
+ #1 \q_mark #1 \q_stop
+ }
+ \cs_new:Npn \@@_check_end:w ##1 #1 ##2 #1 ##3 \q_stop
+ { \if_meaning:w ##2 \q_mark \exp_not:N \q_nil \else: ##2 \fi: }
+ }
+\exp_args:No \@@_tmp:w { \tl_to_str:n { end } }
% \end{macrocode}
% \end{macro}
% \end{macro}
More information about the latex3-commits
mailing list.