summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/l3kernel/l3text.dtx
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2020-01-24 03:00:54 +0000
committerNorbert Preining <norbert@preining.info>2020-01-24 03:00:54 +0000
commite1192611f0655a1ccaff0dff2f53c7c65fa5db07 (patch)
tree232f5be17a2221a57cc6515bfe8692772b3a3e89 /macros/latex/contrib/l3kernel/l3text.dtx
parentf7e5d81fe9880913485f7f8c541eeca7adf4c195 (diff)
CTAN sync 202001240300
Diffstat (limited to 'macros/latex/contrib/l3kernel/l3text.dtx')
-rw-r--r--macros/latex/contrib/l3kernel/l3text.dtx92
1 files changed, 84 insertions, 8 deletions
diff --git a/macros/latex/contrib/l3kernel/l3text.dtx b/macros/latex/contrib/l3kernel/l3text.dtx
index 0efc072cf8..ba97945154 100644
--- a/macros/latex/contrib/l3kernel/l3text.dtx
+++ b/macros/latex/contrib/l3kernel/l3text.dtx
@@ -43,7 +43,7 @@
% }^^A
% }
%
-% \date{Released 2020-01-12}
+% \date{Released 2020-01-22}
%
% \maketitle
%
@@ -77,6 +77,19 @@
% expansion
% \end{function}
%
+% \begin{function}[added = 2020-01-22]
+% {
+% \text_declare_expand_equivalent:Nn ,
+% \text_declare_expand_equivalent:cn
+% }
+% \begin{syntax}
+% \cs{text_declare_expand_equivalent:Nn} \meta{cmd} \Arg{replacement}
+% \end{syntax}
+% Declares that the \meta{replacement} tokens should be used whenever the
+% \meta{cmd} (a single token) is encountered. The \meta{replacement} tokens
+% should be expandable.
+% \end{function}
+%
% \subsection{Case changing}
%
% \begin{function}[EXP, added = 2019-11-20]
@@ -189,8 +202,7 @@
% \end{variable}
%
% \begin{variable}{\l_text_expand_exclude_tl}
-% Lists commands which are excluded from expansion. (Defined only for the
-% \LaTeXe{} package.)
+% Lists commands which are excluded from expansion.
% \end{variable}
%
% \end{documentation}
@@ -426,7 +438,7 @@
% Non-text arguments.
% \begin{macrocode}
\tl_new:N \l_text_case_exclude_arg_tl
-\tl_set:Nn \l_text_case_exclude_arg_tl { \cite \label \ref }
+\tl_set:Nn \l_text_case_exclude_arg_tl { \begin \cite \end \label \ref }
% \end{macrocode}
% \end{variable}
%
@@ -449,8 +461,8 @@
% \begin{variable}{\l_text_expand_exclude_tl}
% Commands which need not to expand.
% \begin{macrocode}
-%<*package>
\tl_new:N \l_text_expand_exclude_tl
+%<*package>
\tl_set:Nn \l_text_expand_exclude_tl
{ \cite \label \ref }
%</package>
@@ -523,7 +535,10 @@
% }
% \begin{macro}[EXP]{\@@_expand_protect:nN}
% \begin{macro}[EXP]{\@@_expand_protect:Nw}
+% \begin{macro}[EXP]{\@@_expand_replace:N}
+% \begin{macro}[EXP]{\@@_expand_replace:n}
% \begin{macro}[EXP]{\@@_expand_cs_expand:N}
+% \begin{macro}[EXP]{\@@_expand_noexpand:n}
% After precautions against |&| tokens, start a simple loop: that of
% course means that \enquote{text} cannot contain the two recursion
% quarks. The loop here must be \texttt{f}-type expandable; we have
@@ -835,7 +850,7 @@
{
\str_if_eq:nnTF {#1} { \protect }
{ \@@_expand_protect:N }
- { \@@_expand_cs_expand:N #1 }
+ { \@@_expand_replace:N #1 }
}
\cs_new:Npn \@@_expand_protect:N #1
{
@@ -856,18 +871,47 @@
\@@_expand_loop:w
}
% \end{macrocode}
+% See if there is a dedicated replacement, and if there is, insert it.
+% \begin{macrocode}
+\cs_new:Npn \@@_expand_replace:N #1
+ {
+ \bool_lazy_and:nnTF
+ { \cs_if_exist_p:c { l_@@_expand_ \token_to_str:N #1 _tl } }
+ {
+ \bool_lazy_or_p:nn
+ { \token_if_cs_p:N #1 }
+ { \token_if_active_p:N #1 }
+ }
+ {
+ \exp_args:Nv \@@_expand_replace:n
+ { l_@@_expand_ \token_to_str:N #1 _tl }
+ }
+ { \@@_expand_cs_expand:N #1 }
+ }
+\cs_new:Npn \@@_expand_replace:n #1 { \@@_expand_loop:w #1 }
+% \end{macrocode}
% Finally, expand any macros which can be: this then loops back around to
-% deal with what they produce.
+% deal with what they produce. The only issue is if the token is
+% \cs{exp_not:n}, as that must apply to the following balanced text.
% \begin{macrocode}
\cs_new:Npn \@@_expand_cs_expand:N #1
{
\@@_if_expandable:NTF #1
- { \exp_after:wN \@@_expand_loop:w #1 }
+ {
+ \str_if_eq:nnTF {#1} { \exp_not:n }
+ { \@@_expand_noexpand:n }
+ { \exp_after:wN \@@_expand_loop:w #1 }
+ }
{
\@@_expand_store:n {#1}
\@@_expand_loop:w
}
}
+\cs_new:Npn \@@_expand_noexpand:n #1
+ {
+ \@@_expand_store:n {#1}
+ \@@_expand_loop:w
+ }
% \end{macrocode}
% \end{macro}
% \end{macro}
@@ -893,6 +937,38 @@
% \end{macro}
% \end{macro}
% \end{macro}
+% \end{macro}
+% \end{macro}
+% \end{macro}
+%
+% \begin{macro}
+% {
+% \text_declare_expand_equivalent:Nn ,
+% \text_declare_expand_equivalent:cn
+% }
+% Create equivalents to allow replacement.
+% \begin{macrocode}
+\cs_new_protected:Npn \text_declare_expand_equivalent:Nn #1#2
+ {
+ \tl_clear_new:c { l_@@_expand_ \token_to_str:N #1 _tl }
+ \tl_set:cn { l_@@_expand_ \token_to_str:N #1 _tl } {#2}
+ }
+\cs_generate_variant:Nn \text_declare_expand_equivalent:Nn { c }
+% \end{macrocode}
+% \end{macro}
+%
+% \begin{macro}[EXP]{\@@_expand_textcomp:NN}
+% Filter out \pkg{textcomp}-like commands.
+% \begin{macrocode}
+%<*package>
+\cs_new:Npn \@@_expand_textcomp:NN #1#2 { \exp_not:n {#1} }
+\text_declare_expand_equivalent:cn { ?-cmd } { \@@_expand_textcomp:NN }
+\text_declare_expand_equivalent:cn { T1-cmd } { \@@_expand_textcomp:NN }
+\text_declare_expand_equivalent:cn { TS1-cmd } { \@@_expand_textcomp:NN }
+\text_declare_expand_equivalent:cn { TU-cmd } { \@@_expand_textcomp:NN }
+%</package>
+% \end{macrocode}
+% \end{macro}
%
% \begin{macrocode}
%</initex|package>