[latex3-commits] [git/LaTeX3-latex3-latex3] main: Refine \l_text_expand_exclude_tl (a395cd452)

Joseph Wright joseph.wright at morningstar2.co.uk
Fri Apr 8 11:23:51 CEST 2022


Repository : https://github.com/latex3/latex3
On branch  : main
Link       : https://github.com/latex3/latex3/commit/a395cd452f84de37dba442270a23b76aabdda32a

>---------------------------------------------------------------

commit a395cd452f84de37dba442270a23b76aabdda32a
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Fri Apr 8 10:23:51 2022 +0100

    Refine \l_text_expand_exclude_tl
    
    Nowadays \begin and \cite are all robust, so don't need special handling.
    However, some packages/classes might revert that,
    so we actively test at the start of the document.
    
    The advantage to *not* listing is there is no arg. grabbing. That makes a few edge cases safer.


>---------------------------------------------------------------

a395cd452f84de37dba442270a23b76aabdda32a
 l3kernel/l3text.dtx | 36 +++++++++++++++++++++++++++++++++++-
 1 file changed, 35 insertions(+), 1 deletion(-)

diff --git a/l3kernel/l3text.dtx b/l3kernel/l3text.dtx
index ae01ecc17..7f151b7a0 100644
--- a/l3kernel/l3text.dtx
+++ b/l3kernel/l3text.dtx
@@ -562,11 +562,45 @@
 % \end{variable}
 %
 % \begin{variable}{\l_text_expand_exclude_tl}
-%   Commands which need not to expand.
+%   Commands which need not to expand. We start with a somewhat historical
+%   list, and tidy up if possible.
 %    \begin{macrocode}
 \tl_new:N \l_text_expand_exclude_tl
 \tl_set:Nn \l_text_expand_exclude_tl
   { \begin \cite \end \label \ref }
+\bool_lazy_and:nnT
+  { \str_if_eq_p:Vn \fmtname { LaTeX2e } }
+  { \tl_if_exist_p:N \@expl at finalise@setup@@@@ }
+  {
+    \tl_gput_right:Nn \@expl at finalise@setup@@@@
+      {
+        \tl_gput_right:Nn \@kernel at after@begindocument
+          {
+            \group_begin:
+              \cs_set_protected:Npn \@@_tmp:w #1
+                {
+                  \tl_clear:N \l_text_expand_exclude_tl
+                  \tl_map_inline:nn {#1}
+                    {
+                      \bool_lazy_any:nF
+                        {
+                          { \token_if_protected_macro_p:N ##1 }
+                          { \token_if_protected_long_macro_p:N ##1 }
+                          {
+                            \str_if_eq_p:ee
+                              { \cs_replacement_spec:N ##1 }
+                              { \exp_not:n { \protect ##1 } \c_space_tl }
+                          }
+                        }
+                        { \tl_put_right:Nn \l_text_expand_exclude_tl {##1} }
+                    }
+                }
+              \exp_args:NV \@@_tmp:w \l_text_expand_exclude_tl
+            \exp_args:NNNV \group_end:
+            \tl_set:Nn \l_text_expand_exclude_tl \l_text_expand_exclude_tl
+          }
+      }
+  }
 %    \end{macrocode}
 % \end{variable}
 %





More information about the latex3-commits mailing list.