[latex3-commits] [git/LaTeX3-latex3-pdfresources] main: rename name-convert command (c00f537)

Ulrike Fischer fischer at troubleshooting-tex.de
Sun Feb 14 18:34:14 CET 2021


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

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

commit c00f537a1f2c327bd5272b7939ad8017e7cfe563
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Sun Feb 14 18:34:14 2021 +0100

    rename name-convert command


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

c00f537a1f2c327bd5272b7939ad8017e7cfe563
 hyperref-generic.dtx       |  7 ++--
 l3pdffile.dtx              |  2 +-
 l3pdftools.dtx             | 91 ++++++++++++++++------------------------------
 testfiles/infodict-new.pvt |  1 +
 4 files changed, 37 insertions(+), 64 deletions(-)

diff --git a/hyperref-generic.dtx b/hyperref-generic.dtx
index 07ad64c..1873e35 100644
--- a/hyperref-generic.dtx
+++ b/hyperref-generic.dtx
@@ -1952,7 +1952,7 @@
            {
              \mode_leave_vertical:
              \pdfdict_put:nnx {l_hyp/annot/A/Named}{N}
-               {\pdf_text_convert:nn{name-print}{#1}}
+               {\pdf_name_from_unicode_e:n{#1}}
              \tl_if_empty:NF \Hy at href@nextactionraw
                {
                  \str_remove_once:Nn \Hy at href@nextactionraw {/Next}
@@ -3457,9 +3457,8 @@
             \@@_text_pdfstring_info:nN {##1}\l_@@_tmpa_str
             \str_if_eq:VnF\l_@@_tmpa_str{<FEFF>}
               {
-                \exp_args:Nnx
-                  \pdfmanagement_add:nnx {Info}
-                    {\pdf_text_convert:nV {name }\l_keys_key_str}{\l_@@_tmpa_str}
+                \pdfmanagement_add:nVx {Info}
+                    \l_keys_key_str {\l_@@_tmpa_str}
               }
          }
       }
diff --git a/l3pdffile.dtx b/l3pdffile.dtx
index da5a0ed..9fc7b00 100644
--- a/l3pdffile.dtx
+++ b/l3pdffile.dtx
@@ -525,7 +525,7 @@
               \l_@@_ext_str
               \l_@@_tmpb_tl
               {
-                \tl_set:Nx #2 {/Subtype~\pdf_text_convert:nV {name-print} \l_@@_tmpb_tl}
+                \tl_set:Nx #2 {/Subtype~\pdf_name_from_unicode_e:V \l_@@_tmpb_tl}
               }
               {
                 \msg_warning:nnx { pdffile }{ mimetype-missing} {#1}
diff --git a/l3pdftools.dtx b/l3pdftools.dtx
index 6d8e98d..3ffbe74 100644
--- a/l3pdftools.dtx
+++ b/l3pdftools.dtx
@@ -68,10 +68,25 @@
 %      then escape it in the way needed in a PDF Name with
 %      \cs{str_convert_pdfname:e}.
 %     \item[name-print] This does the same as the \texttt{name} format, but also
-%     adds a slash before, so |\pdf_text_convert:nn{name-print}{abc}| will
+%     adds a slash before, so
+%      |\pdf_text_convert:nn{name-print}{abc}| will
 %     output \texttt{/abc}.
 %   \end{description}
 % \end{function}
+% \begin{function}[EXP,added=2021-02-14]
+%   {\pdf_name_from_unicode_e:n}
+%  \begin{syntax}
+%   \cs{\pdf_name_from_unicode_e:n}  \Arg{content}
+%  \end{syntax}
+%  This converts \meta{content} to a format suitable for a PDF Name.
+%  It will first expand the content with \cs{text_expand:n} and
+%  then escape it in the way needed in a PDF Name with
+%  \cs{str_convert_pdfname:e}, and at last prepend a slash before.
+%  Typically such names use only ascii,
+%  but non-ascii is supported, but should be utf8 encoded. For example\\
+%  |\pdf_name_from_unicode_e:n {A~B\c_percent_str C\c_hash_str D€}}|\\
+%   will    output |/A#20B#25C#23D#E2#82#AC|}.
+% \end{function}
 % \begin{function}[added=2020-07-04]
 %   {\pdf_text_convert:nnN}
 %  \begin{syntax}
@@ -82,8 +97,6 @@
 %  Non-ascii input should be utf8 encoded.
 %  Currently the following formats exist:
 %  \begin{description}
-%     \item[name] see above
-%     \item[name-print] see above
 %     \item[utf8/string]
 %      this converts with \cs{str_set_convert:Nnnn} into utf8/string.
 %     \item[utf8/string-print]
@@ -228,75 +241,23 @@
 %<@@=pdf>
 %    \end{macrocode}
 % \subsection{Conversions and export functions}
-% \begin{macro}{\pdf_text_convert:nn,\pdf_text_convert:nV}
-% \begin{macro}{\pdf_text_convert:nnN}
-% \begin{macro}{\@@_text_convert_name:n}
-% \begin{macro}{\@@_text_convert_name:nN}
-% \begin{macro}{\@@_text_convert_name-print:n}
-% \begin{macro}{\@@_text_convert_name-print:n}
+% \begin{macro}{\pdf_name_from_unicode_e:n,\pdf_name_from_unicode_e:V}
 %    \begin{macrocode}
-
-\cs_new:Npn \pdf_text_convert:nn #1 #2
-  {
-    \cs_if_exist_use:cF { @@_text_convert_#1:n }
-      {
-        \__kernel_msg_error:nnn { pdf } { unknown-exp-convert } {#1}
-        \use_none:n
-      }
-    { #2 }
-  }
-\cs_generate_variant:Nn \pdf_text_convert:nn {nV}
-
-\cs_new:Npn \pdf_text_convert:nnN #1 #2 #3
-  {
-    \cs_if_exist_use:cF { @@_text_convert_#1:nN }
-      {
-        \__kernel_msg_error:nnn { pdf } { unknown-convert } {#1}
-        \use_none:nn
-      }
-    { #2 } #3
-  }
-
-\cs_generate_variant:Nn \pdf_text_convert:nnN {nVN}
-%% tool command escape name
-%% commands in the argument are expanded if possible
-%% with \text_expand:n
-%% name: only name,
-%% name_print: with / before, see also string naming
-
 \cs_generate_variant:Nn \str_convert_pdfname:n { e }
 
-\cs_new:Npn \@@_text_convert_name:n #1
-  {
-    \str_convert_pdfname:e { \text_expand:n { #1 } }
-  }
-
-\cs_new_protected:Npn \@@_text_convert_name:nN #1 #2
-  {
-    \tl_set:Nx #2 {\@@_text_convert_name:n {#1} }
-  }
-
-\cs_new:cpn { @@_text_convert_name-print:n } #1
+\cs_new:Npn \pdf_name_from_unicode_e:n #1
   {
     / \str_convert_pdfname:e { \text_expand:n { #1 } }
   }
 
-\cs_new_protected:cpn { @@_text_convert_name-print:nN } #1 #2
-  {
-    \tl_set:Nx #2 {\use:c { @@_text_convert_name-print:n } {#1} }
-  }
-
+\cs_generate_variant:Nn \pdf_name_from_unicode_e:n {V}
 %    \end{macrocode}
 % \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
-% \end{macro}
 %
 % The convert command must use a different value the source encoding
 % depending on the engines. Until the PR in str-convert is active we add the alias here
 % too
+% \begin{macro}{\pdf_text_convert:nnN}
 %    \begin{macrocode}
 \bool_lazy_any:nTF
   {
@@ -309,7 +270,19 @@
   {
     \prop_gput:Nnn \g__str_alias_prop { default } { utf8 }
   }
+\cs_new:Npn \pdf_text_convert:nnN #1 #2 #3
+  {
+    \cs_if_exist_use:cF { @@_text_convert_#1:nN }
+      {
+        \__kernel_msg_error:nnn { pdf } { unknown-convert } {#1}
+        \use_none:nn
+      }
+    { #2 } #3
+  }
+
+\cs_generate_variant:Nn \pdf_text_convert:nnN {nVN}
 %    \end{macrocode}
+% \end{macro}
 % Most converter are simply wrapper around the str-convert commands and so
 % use the same name.
 % The exception is the one for url's: it reverts most of the percent encodings
diff --git a/testfiles/infodict-new.pvt b/testfiles/infodict-new.pvt
index ab4440c..e365593 100644
--- a/testfiles/infodict-new.pvt
+++ b/testfiles/infodict-new.pvt
@@ -8,5 +8,6 @@
 \hypersetup{pdfsubject={🦆},pdfinfo={Title={grüße$\int=a$}, Author=blub, Xy Z=ups}}
 
 \begin{document}
+
 xxx
 \end{document} 
\ No newline at end of file





More information about the latex3-commits mailing list.