[latex3-commits] [git/LaTeX3-latex3-pdfresources] master: cleaning up code (15cef08)

Ulrike Fischer fischer at troubleshooting-tex.de
Thu Mar 19 00:06:42 CET 2020


Repository : https://github.com/latex3/pdfresources
On branch  : master
Link       : https://github.com/latex3/pdfresources/commit/15cef08f7c4b2623fedf7df574bf57865d683778

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

commit 15cef08f7c4b2623fedf7df574bf57865d683778
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Thu Mar 19 00:06:42 2020 +0100

    cleaning up code


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

15cef08f7c4b2623fedf7df574bf57865d683778
 hgeneric-experimental.def | 73 +++++++++++++++++++++--------------------------
 1 file changed, 32 insertions(+), 41 deletions(-)

diff --git a/hgeneric-experimental.def b/hgeneric-experimental.def
index 7d645ea..4bcdd9d 100644
--- a/hgeneric-experimental.def
+++ b/hgeneric-experimental.def
@@ -4,7 +4,7 @@
 %% meant to test the use of the commands
 %% from pdfresources.sty
 %%
-%% drivers are loaded in line 4745 in hyperref.sty.
+%% drivers are loaded in line 4745 in hyperref.sty in a \Hy at AtEndOfPackage command.
 \ProvidesFile{hgeneric-experimental.def}
   [2020/03/16 v0.5 %
   Hyperref driver for luaTeX]
@@ -63,6 +63,11 @@
 \Hy at unicodetrue
 \let\HyPsd at pdfencoding\HyPsd at pdfencoding@unicode
 
+% variants
+\cs_generate_variant:Nn \pdf_object_write:nn {nx}
+\cs_generate_variant:Nn \pdf_catalog_gput:nn {nx}
+
+
 %%% pdfa key:
 \bool_new:N \l__hyp_pdfa_bool
 \ifHy at pdfa
@@ -187,7 +192,7 @@
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
-\ExplSyntaxOff
+
 % page labels.
 %% current implemention in hyperref/hyperref drivers
 % xetex: hxetex line 80-110
@@ -213,8 +218,6 @@
 % (but it would be possible), we also don't test for empty \thepage, hyperref seems to
 % handle this fine and the pdf is valid.
 
-\ExplSyntaxOn
-
 % catalog mapped to expl3 command
 % \Hy at PutCatalog is used only in one place but we
 % we need this for the dvips/xetex route for the page labels.
@@ -236,61 +239,55 @@
   {
     \sys_if_output_pdf:TF
       { %pdflatex,lualatex
-        \def\HyPL at StorePageLabel#1
+        \cs_set_protected:Npn \HyPL at StorePageLabel #1
           {
-            \toks@\expandafter{\HyPL at Labels}
-            \xdef\HyPL at Labels
-              {
-                \the\toks@
-                \the\Hy at abspage<<#1>>
-              }
-            \pdf_catalog_gput:nx {PageLabels}{<</Nums[\HyPL at Labels]>>}
+            \tl_gput_right:Nx \HyPL at Labels { \the\Hy at abspage<<#1>> }
+            \pdf_catalog_gput:nx { PageLabels }{ <</Nums[\HyPL at Labels]>> }
           }
       }
       { %xetex, dvips, dvipdfmx
-        \def\HyPL at StorePageLabel#1
+        \cs_set_protected:Npn \HyPL at StorePageLabel #1
           {
             \legacy_if:nT { @filesw }
               {
-                \begingroup
-                \edef\Hy at tempa{\the\Hy at abspage<<#1>>}
-                \immediate\write\@mainaux
-                  {
-                    \string\HyPL at Entry{\Hy at tempa}
-                  }
-                \endgroup
+                 \iow_now:Nx\@mainaux
+                   {
+                      \exp_not:N \HyPL at Entry{\the\Hy at abspage<<#1>>}
+                   }
               }
           }
         \Hy at AtBeginDocument
           {
             \legacy_if:nT { @filesw }
               {
-                \immediate\write\@mainaux
+                \iow_now:Nn \@mainaux
                    {
-                     \string\providecommand\string*\string\HyPL at Entry[1]{}
+                      \providecommand*\HyPL at Entry[1]{}
                    }
               }
-            \ifx\HyPL at Labels\@empty
-              \Hy at WarningNoLine{Rerun to get /PageLabels entry}%
-            \else
-              \HyPL at SetPageLabels
-            \fi
-            \let\HyPL at Entry\@gobble
+            \tl_if_empty:NTF \HyPL at Labels
+              {
+                \Hy at WarningNoLine{Rerun~to~get~/PageLabels~entry}
+              }
+              {
+                \HyPL at SetPageLabels
+              }
+              \cs_set_eq:NN \HyPL at Entry \use_none:n
            }
-         \def\HyPL at Entry#1
+         \cs_set_protected:Npn \HyPL at Entry #1
            {
-             \expandafter\gdef\expandafter\HyPL at Labels\expandafter
-               {
-                  \HyPL at Labels
-                  #1
-               }
+              \tl_gset:No \HyPL at Labels
+                {
+                   \HyPL at Labels
+                   #1
+                }
            }
       }
   }
 \ExplSyntaxOff
 
 %UF replace Hy at pstringdef definition.
-
+%% !! check the conversion through the drivers!
 \ExplSyntaxOn
 \cs_new:Npn \__hyp_pstringdef:Nn #1 #2
   {
@@ -307,9 +304,6 @@
 \ExplSyntaxOff
 
 
-
-
-
 \ExplSyntaxOn
 \str_case:VnF \c_sys_backend_str
  {
@@ -356,9 +350,6 @@
 
 \Hy at DisableOption{pdfversion}%
 
-\cs_generate_variant:Nn \pdf_object_write:nn {nx}
-\cs_generate_variant:Nn \pdf_catalog_gput:nn {nx}
-
 %ocg colorlinks should be done as in ocgx. This here
 % are boxes ...
 \legacy_if:nTF {Hy at ocgcolorlinks}





More information about the latex3-commits mailing list.