[latex3-commits] [git/LaTeX3-latex3-latex3] master: Allow for full range of encodings when expanding text (see #671) (b99866a05)

Joseph Wright joseph.wright at morningstar2.co.uk
Mon Feb 10 17:49:10 CET 2020


Repository : https://github.com/latex3/latex3
On branch  : master
Link       : https://github.com/latex3/latex3/commit/b99866a054c52e022235c1f6697c25f60d6babad

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

commit b99866a054c52e022235c1f6697c25f60d6babad
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Mon Feb 10 16:49:10 2020 +0000

    Allow for full range of encodings when expanding text (see #671)


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

b99866a054c52e022235c1f6697c25f60d6babad
 l3kernel/CHANGELOG.md |  3 +++
 l3kernel/l3text.dtx   | 50 ++++++++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 49 insertions(+), 4 deletions(-)

diff --git a/l3kernel/CHANGELOG.md b/l3kernel/CHANGELOG.md
index 65317903f..b9dd5acdd 100644
--- a/l3kernel/CHANGELOG.md
+++ b/l3kernel/CHANGELOG.md
@@ -7,6 +7,9 @@ this project uses date-based 'snapshot' version identifiers.
 
 ## [Unreleased]
 
+### Fixed
+- Allow for full range of encodings when expanding text (issue #671)
+
 ## [2020-02-08]
 
 ### Added
diff --git a/l3kernel/l3text.dtx b/l3kernel/l3text.dtx
index 72f91af2f..9da9d8fa4 100644
--- a/l3kernel/l3text.dtx
+++ b/l3kernel/l3text.dtx
@@ -850,7 +850,12 @@
   {
     \str_if_eq:nnTF {#1} { \protect }
       { \@@_expand_protect:N }
-      { \@@_expand_replace:N #1 }
+%<*initex>
+      { \@@_expand_expand:N #1 }
+%</initex>
+%<*package>
+      { \@@_expand_encoding:N #1 }
+%</package>
   }
 \cs_new:Npn \@@_expand_protect:N #1
   {
@@ -871,6 +876,46 @@
     \@@_expand_loop:w
   }
 %    \end{macrocode}
+%   Deal with encoding-specific commands in package mode: at the end of
+%   the preamble, we tidy up as the data otherwise vanishes.
+%    \begin{macrocode}
+%<*package>
+\cs_new:Npn \@@_expand_encoding:N #1
+  {
+    \exp_after:wN \@@_expand_encoding:Nnnnn \exp_after:wN #1
+      \cdp at elt { \q_recursion_tail } { } { } { } \q_recursion_stop
+  }
+\cs_new:Npn \@@_expand_encoding:Nnnnn #1#2#3#4#5
+  {
+    \quark_if_recursion_tail_stop_do:nn {#2} { \@@_expand_replace:N #1 }
+    \str_if_eq:eeTF { \exp_not:N #1 } { \exp_not:c { #2 - cmd } }
+      { \@@_expand_loop:w \__text_expand_textcomp:NN #1 }
+      { \@@_expand_encoding:Nnnnn #1 }
+  }
+\cs_new:Npn \@@_expand_encoding:Nn #1#2
+  {
+    \quark_if_recursion_tail_stop_do:nn {#2} { \@@_expand_replace:N #1 }
+    \str_if_eq:eeTF { \exp_not:N #1 } { \exp_not:c { #2 - cmd } }
+      { \@@_expand_loop:w \__text_expand_textcomp:NN #1 }
+      { \@@_expand_encoding:Nnnnn #1 }
+  }
+\AtBeginDocument
+  {
+    \cs_set:Npn \@@_expand_cs:N #1
+      {
+        \str_if_eq:nnTF {#1} { \protect }
+          { \@@_expand_protect:N }
+          { \@@_expand_replace:N #1 }
+      }
+    \cs_set_protected:Npn \cdp at elt #1#2#3#4
+      {
+        \text_declare_expand_equivalent:cn { #1 -cmd }
+          { \@@_expand_textcomp:NN }
+      }
+    \cdp at list
+  }
+%</package>
+%    \end{macrocode}
 %   See if there is a dedicated replacement, and if there is, insert it.
 %    \begin{macrocode}
 \cs_new:Npn \@@_expand_replace:N #1
@@ -966,9 +1011,6 @@
 %<*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}





More information about the latex3-commits mailing list.