From 186d7c0795fc4ffce06bc897006e6aad0417cb83 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Sat, 16 May 2020 03:02:23 +0000 Subject: CTAN sync 202005160302 --- macros/latex/contrib/l3kernel/l3text-purify.dtx | 96 ++++++++++++++++--------- 1 file changed, 62 insertions(+), 34 deletions(-) (limited to 'macros/latex/contrib/l3kernel/l3text-purify.dtx') diff --git a/macros/latex/contrib/l3kernel/l3text-purify.dtx b/macros/latex/contrib/l3kernel/l3text-purify.dtx index 54266ba72c..312d7e180d 100644 --- a/macros/latex/contrib/l3kernel/l3text-purify.dtx +++ b/macros/latex/contrib/l3kernel/l3text-purify.dtx @@ -43,7 +43,7 @@ % }^^A % } % -% \date{Released 2020-05-14} +% \date{Released 2020-05-15} % % \maketitle % @@ -72,40 +72,61 @@ % \end{macrocode} % \end{macro} % -% \begin{macro}[rEXP]{\text_purify:n, \@@_purify:n} -% \begin{macro}[rEXP]{\@@_purify_loop:w} -% \begin{macro}[rEXP]{\@@_purify_group:n} -% \begin{macro}[rEXP]{\@@_purify_space:w} -% \begin{macro}[rEXP]{\@@_purify_N_type:N, \@@_purify_N_type_aux:N} -% \begin{macro}[rEXP]{\@@_purify_math_search:NNN} -% \begin{macro}[rEXP]{\@@_purify_math_start:NNw} -% \begin{macro}[rEXP]{\@@_purify_math_store:n} -% \begin{macro}[rEXP]{\@@_purify_math_store:nw} -% \begin{macro}[rEXP]{\@@_purify_math_end:w} -% \begin{macro}[rEXP]{\@@_purify_math_loop:NNw} -% \begin{macro}[rEXP]{\@@_purify_math_N_type:NNN} -% \begin{macro}[rEXP]{\@@_purify_math_group:NNn} -% \begin{macro}[rEXP]{\@@_purify_math_space:NNw} -% \begin{macro}[rEXP]{\@@_purify_math_cmd:N} -% \begin{macro}[rEXP]{\@@_purify_math_cmd:NN} -% \begin{macro}[rEXP]{\@@_purify_math_cmd:Nn} -% \begin{macro}[rEXP]{\@@_purify_replace:N} -% \begin{macro}[rEXP]{\@@_purify_replace:n} -% \begin{macro}[rEXP]{\@@_purify_expand:N, \@@_purify_protect:N} +% \begin{macro}[EXP]{\text_purify:n, \@@_purify:n} +% \begin{macro}[EXP]{\@@_purify_store:n} +% \begin{macro}[EXP]{\@@_purify_store:nw} +% \begin{macro}[EXP]{\@@_purify_end:w} +% \begin{macro}[EXP]{\@@_purify_loop:w} +% \begin{macro}[EXP]{\@@_purify_group:n} +% \begin{macro}[EXP]{\@@_purify_space:w} +% \begin{macro}[EXP]{\@@_purify_N_type:N, \@@_purify_N_type_aux:N} +% \begin{macro}[EXP]{\@@_purify_math_search:NNN} +% \begin{macro}[EXP]{\@@_purify_math_start:NNw} +% \begin{macro}[EXP]{\@@_purify_math_store:n} +% \begin{macro}[EXP]{\@@_purify_math_store:nw} +% \begin{macro}[EXP]{\@@_purify_math_end:w} +% \begin{macro}[EXP]{\@@_purify_math_loop:NNw} +% \begin{macro}[EXP]{\@@_purify_math_N_type:NNN} +% \begin{macro}[EXP]{\@@_purify_math_group:NNn} +% \begin{macro}[EXP]{\@@_purify_math_space:NNw} +% \begin{macro}[EXP]{\@@_purify_math_cmd:N} +% \begin{macro}[EXP]{\@@_purify_math_cmd:NN} +% \begin{macro}[EXP]{\@@_purify_math_cmd:Nn} +% \begin{macro}[EXP]{\@@_purify_replace:N} +% \begin{macro}[EXP]{\@@_purify_replace:n} +% \begin{macro}[EXP]{\@@_purify_expand:N, \@@_purify_protect:N} % As in the other parts of the module, we start off with a standard -% \enquote{action} loop, with expansion applied up-front. Here, as there -% will be no text commands left in the output, there is no concern about -% using \cs{exp_not:n} and \texttt{e}-type expansion. +% \enquote{action} loop, with expansion applied up-front. % \begin{macrocode} \cs_new:Npn \text_purify:n #1 + { + \__kernel_exp_not:w \exp_after:wN + { + \exp:w + \exp_args:Ne \@@_purify:n + { \text_expand:n {#1} } + } + } +\cs_new:Npn \@@_purify:n #1 { \group_align_safe_begin: - \exp_args:Ne \@@_purify:n - { \text_expand:n {#1} } + \@@_purify_loop:w #1 + \q_@@_recursion_tail \q_@@_recursion_stop + \@@_purify_result:n { } + } +% \end{macrocode} +% As for expansion, collect up the tokens for future use. +% \begin{macrocode} +\cs_new:Npn \@@_purify_store:n #1 + { \@@_purify_store:nw {#1} } +\cs_new:Npn \@@_purify_store:nw #1#2 \@@_purify_result:n #3 + { #2 \@@_purify_result:n { #3 #1 } } +\cs_new:Npn \@@_purify_end:w #1 \@@_purify_result:n #2 + { \group_align_safe_end: + \exp_end: + #2 } -\cs_new:Npn \@@_purify:n #1 - { \@@_purify_loop:w #1 \q_@@_recursion_tail \q_@@_recursion_stop } % \end{macrocode} % The main loop is a standard \enquote{tl action}. Unlike the expansion % or case changing, here any groups have to be run inline. Most of the @@ -125,7 +146,7 @@ \cs_new:Npn \@@_purify_group:n #1 { \@@_purify_loop:w #1 } \exp_last_unbraced:NNo \cs_new:Npn \@@_purify_space:w \c_space_tl { - \c_space_tl + \@@_purify_store:n { ~ } \@@_purify_loop:w } % \end{macrocode} @@ -135,7 +156,7 @@ % \begin{macrocode} \cs_new:Npn \@@_purify_N_type:N #1 { - \@@_if_recursion_tail_stop:N #1 + \@@_if_recursion_tail_stop_do:Nn #1 { \@@_purify_end:w } \@@_purify_N_type_aux:N #1 } \cs_new:Npn \@@_purify_N_type_aux:N #1 @@ -167,11 +188,14 @@ { #2 \@@_purify_math_result:n { #3 #1 } } \cs_new:Npn \@@_purify_math_end:w #1 \@@_purify_math_result:n #2 { - \exp_not:n { $ #2 $ } + \@@_purify_store:n { $ #2 $ } \@@_purify_loop:w #1 } \cs_new:Npn \@@_purify_math_stop:Nw #1 \@@_purify_math_result:n #2 - { \exp_not:n {#1#2} } + { + \@@_purify_store:n {#1#2} + \@@_purify_end:w + } \cs_new:Npn \@@_purify_math_loop:NNw #1#2#3 \q_@@_recursion_stop { \tl_if_head_is_N_type:nTF {#3} @@ -253,7 +277,8 @@ \token_if_cs:NTF #1 { \@@_purify_expand:N #1 } { - \@@_token_to_explicit:N #1 + \exp_args:Ne \@@_purify_store:n + { \@@_token_to_explicit:N #1 } \@@_purify_loop:w } } @@ -271,7 +296,7 @@ } \cs_new:Npn \@@_purify_protect:N #1 { - \@@_if_recursion_tail_stop:N #1 + \@@_if_recursion_tail_stop_do:Nn #1 { \@@_purify_end:w } \@@_purify_loop:w } % \end{macrocode} @@ -295,6 +320,9 @@ % \end{macro} % \end{macro} % \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} % % \begin{macro} % { -- cgit v1.2.3