[latex3-commits] [git/LaTeX3-latex3-latex3] master: Make \text_purify:n f-type expandable (338fda11d)
Joseph Wright
joseph.wright at morningstar2.co.uk
Fri May 15 14:31:04 CEST 2020
Repository : https://github.com/latex3/latex3
On branch : master
Link : https://github.com/latex3/latex3/commit/338fda11d8f324c8d0e20526da5d767ec288dcd8
>---------------------------------------------------------------
commit 338fda11d8f324c8d0e20526da5d767ec288dcd8
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date: Thu May 14 16:32:32 2020 +0100
Make \text_purify:n f-type expandable
>---------------------------------------------------------------
338fda11d8f324c8d0e20526da5d767ec288dcd8
l3kernel/CHANGELOG.md | 3 ++
l3kernel/l3text-purify.dtx | 94 ++++++++++++++++++++++++++++++----------------
l3kernel/l3text.dtx | 2 +-
3 files changed, 65 insertions(+), 34 deletions(-)
diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index 41cffac25..0bd67cd6d 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -7,6 +7,9 @@ this project uses date-based 'snapshot' version identifiers.
## [Unreleased]
+### Changed
+- Make `\text_purify:n` `f`-type expandable
+
## [2020-05-14]
### Changed
diff --git a/l3kernel/l3text-purify.dtx b/l3kernel/l3text-purify.dtx
index 54266ba72..b3351b028 100644
--- a/l3kernel/l3text-purify.dtx
+++ b/l3kernel/l3text-purify.dtx
@@ -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}
% {
diff --git a/l3kernel/l3text.dtx b/l3kernel/l3text.dtx
index 0f8f24caf..a02ca32b8 100644
--- a/l3kernel/l3text.dtx
+++ b/l3kernel/l3text.dtx
@@ -197,7 +197,7 @@
%
% \subsection{Removing formatting from text}
%
-% \begin{function}[rEXP, added = 2020-03-05]{\text_purify:n}
+% \begin{function}[EXP, added = 2020-03-05, updated = 2020-05-14]{\text_purify:n}
% \begin{syntax}
% \cs{text_purify:n} \Arg{text}
% \end{syntax}
More information about the latex3-commits
mailing list.