Skip to content

Commit

Permalink
Exclude accents/letter-likes from ext expansion in a controlled way
Browse files Browse the repository at this point in the history
This is a beer approach than the reverted checkin here:
it allows the same ideas to be explored but
as a wider re-working not just an ah hoc change.
  • Loading branch information
josephwright committed Feb 6, 2023
1 parent 5627f43 commit f01907b
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 95 deletions.
3 changes: 3 additions & 0 deletions l3kernel/CHANGELOG.md
Expand Up @@ -11,6 +11,9 @@ this project uses date-based 'snapshot' version identifiers.
- Swap meaning of `el` and `el-x-iota` when case changing
Greek: match traditional LaTeX approach

### Removed
- `\l_text_accents_tl` and `\l_text_letterlike_l`

## [2023-02-02]

### Fixed
Expand Down
2 changes: 2 additions & 0 deletions l3kernel/doc/l3obsolete.txt
Expand Up @@ -342,6 +342,8 @@ Function Date removed
\KV_process_space_removal_sanitize:NNn 2011-09-08
\l_iow_line_length_int 2013-01-08
\l_last_box 2012-05-11
\l_text_accedtns_tl 2023-02-06
\l_text_letterlike_tl 2023-02-06
\l_tl_replace_toks 2011-09-08
\l_tmpa_toks 2011-09-08
\l_tmpb_toks 2011-09-08
Expand Down
2 changes: 1 addition & 1 deletion l3kernel/l3text-purify.dtx
Expand Up @@ -547,7 +547,7 @@
\exp_not:v { c_@@_purify_ \token_to_str:N #1 _tl }
}
}
\tl_map_inline:Nn \l_text_accents_tl
\tl_map_inline:nn { \` \' \^ \~ \= \u \. \" \r \H \v \d \c \k \b \t }
{ \text_declare_purify_equivalent:Nn #1 { \@@_purify_accent:NN #1 } }
% \end{macrocode}
% First set up the combining accents.
Expand Down
119 changes: 25 additions & 94 deletions l3kernel/l3text.dtx
Expand Up @@ -58,7 +58,7 @@
%
% \section{Expanding text}
%
% \begin{function}[EXP, added = 2020-01-02]{\text_expand:n}
% \begin{function}[EXP, added = 2020-01-02, updated = 2023-02-06]{\text_expand:n}
% \begin{syntax}
% \cs{text_expand:n} \Arg{text}
% \end{syntax}
Expand All @@ -69,8 +69,7 @@
% \cs{l_text_math_delims_tl} or as the argument to commands listed
% in \cs{l_text_math_arg_tl}). Commands which are neither engine-
% nor \LaTeX{} protected are expanded exhaustively.
% Any commands listed in \cs{l_text_expand_exclude_tl},
% \cs{l_text_accents_tl} and \cs{l_text_letterlike_tl} are excluded from
% Any commands listed in \cs{l_text_expand_exclude_tl} are excluded from
% expansion.
% \end{function}
%
Expand Down Expand Up @@ -256,16 +255,6 @@
%
% \section{Control variables}
%
% \begin{variable}{\l_text_accents_tl}
% Lists commands which represent accents, and which are left unchanged
% by expansion. (Defined only for the \LaTeXe{} package.)
% \end{variable}
%
% \begin{variable}{\l_text_letterlike_tl}
% Lists commands which represent letters; these are left unchanged by
% expansion. (Defined only for the \LaTeXe{} package.)
% \end{variable}
%
% \begin{variable}{\l_text_math_arg_tl}
% Lists commands present in the \meta{text} where the argument of the
% command should be treated as math mode material. The treatment here is
Expand Down Expand Up @@ -794,31 +783,6 @@
%
% \subsection{Configuration variables}
%
% \begin{variable}{\l_text_accents_tl, \l_text_letterlike_tl}
% Special cases for accents and letter-like symbols, which in some cases will
% need to be converted further.
% \begin{macrocode}
\tl_new:N \l_text_accents_tl
\tl_set:Nn \l_text_accents_tl
{ \` \' \^ \~ \= \u \. \" \r \H \v \d \c \k \b \t }
\tl_new:N \l_text_letterlike_tl
\tl_set:Nn \l_text_letterlike_tl
{
\AA \aa
\AE \ae
\DH \dh
\DJ \dj
\IJ \ij
\L \l
\NG \ng
\O \o
\OE \oe
\SS \ss
\TH \th
}
% \end{macrocode}
% \end{variable}
%
% \begin{variable}{\l_text_case_exclude_arg_tl}
% Non-text arguments, including covering the case of \tn{protected@edef}
% applied to \cs{cite}.
Expand Down Expand Up @@ -951,10 +915,6 @@
% \begin{macro}[EXP]{\@@_expand_exclude:NN}
% \begin{macro}[EXP]{\@@_expand_exclude:Nw}
% \begin{macro}[EXP]{\@@_expand_exclude:Nnn}
% \begin{macro}[EXP]{\@@_expand_accent:N}
% \begin{macro}[EXP]{\@@_expand_accent:NN}
% \begin{macro}[EXP]{\@@_expand_letterlike:N}
% \begin{macro}[EXP]{\@@_expand_letterlike:NN}
% \begin{macro}[EXP]{\@@_expand_cs:N}
% \begin{macro}[EXP]{\@@_expand_protect:w}
% \begin{macro}[EXP]{\@@_expand_protect:N}
Expand Down Expand Up @@ -1239,7 +1199,7 @@
\cs_new:Npn \@@_expand_exclude:NN #1#2
{
\@@_if_q_recursion_tail_stop_do:Nn #2
{ \@@_expand_accent:N #1 }
{ \@@_expand_cs:N #1 }
\str_if_eq:nnTF {#1} {#2}
{
\@@_use_i_delimit_by_q_recursion_stop:nw
Expand All @@ -1255,53 +1215,6 @@
\@@_expand_loop:w
}
% \end{macrocode}
% Accents.
% \begin{macrocode}
\cs_new:Npn \@@_expand_accent:N #1
{
\exp_after:wN \@@_expand_accent:NN \exp_after:wN
#1 \l_text_accents_tl
\q_@@_recursion_tail \q_@@_recursion_stop
}
\cs_new:Npn \@@_expand_accent:NN #1#2
{
\@@_if_q_recursion_tail_stop_do:Nn #2
{ \@@_expand_letterlike:N #1 }
\cs_if_eq:NNTF #2 #1
{
\@@_use_i_delimit_by_q_recursion_stop:nw
{
\@@_expand_store:n {#1}
\@@_expand_loop:w
}
}
{ \@@_expand_accent:NN #1 }
}
% \end{macrocode}
% Another list of exceptions: these ones take no arguments so are
% easier to handle.
% \begin{macrocode}
\cs_new:Npn \@@_expand_letterlike:N #1
{
\exp_after:wN \@@_expand_letterlike:NN \exp_after:wN
#1 \l_text_letterlike_tl
\q_@@_recursion_tail \q_@@_recursion_stop
}
\cs_new:Npn \@@_expand_letterlike:NN #1#2
{
\@@_if_q_recursion_tail_stop_do:Nn #2
{ \@@_expand_cs:N #1 }
\cs_if_eq:NNTF #2 #1
{
\@@_use_i_delimit_by_q_recursion_stop:nw
{
\@@_expand_store:n {#1}
\@@_expand_loop:w
}
}
{ \@@_expand_letterlike:NN #1 }
}
% \end{macrocode}
% \LaTeXe{}'s \cs{protect} makes life interesting. Where possible, we
% simply remove it and replace with the \enquote{parent} command; of course,
% the \cs{protect} might be explicit, in which case we need to leave it alone.
Expand Down Expand Up @@ -1493,10 +1406,6 @@
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
% \end{macro}
%
% \begin{macro}
% {
Expand All @@ -1514,6 +1423,28 @@
% \end{macrocode}
% \end{macro}
%
% Prevent expansion of various standard values.
% \begin{macrocode}
\tl_map_inline:nn
{ \` \' \^ \~ \= \u \. \" \r \H \v \d \c \k \b \t }
{ \text_declare_expand_equivalent:Nn #1 { \exp_not:n {#1} } }
\tl_map_inline:nn
{
\AA \aa
\AE \ae
\DH \dh
\DJ \dj
\IJ \ij
\L \l
\NG \ng
\O \o
\OE \oe
\SS \ss
\TH \th
}
{ \text_declare_expand_equivalent:Nn #1 { \exp_not:n {#1} } }
% \end{macrocode}
%
% \begin{macrocode}
%</package>
% \end{macrocode}
Expand Down

0 comments on commit f01907b

Please sign in to comment.