From 4e5cb02ecfe62152cf68ce69e36e2a158b35ccfc Mon Sep 17 00:00:00 2001
From: Karl Berry <karl@freefriends.org>
Date: Sat, 28 Aug 2021 20:41:07 +0000
Subject: pdfmanagement-testphase (28aug21)

git-svn-id: svn://tug.org/texlive/trunk@60347 c570f23f-e606-0410-a88d-b1316a301751
---
 .../pdfmanagement-testphase/hgeneric-testphase.def | 121 ++++++++++++++-------
 1 file changed, 83 insertions(+), 38 deletions(-)

(limited to 'Master/texmf-dist/tex/latex/pdfmanagement-testphase/hgeneric-testphase.def')

diff --git a/Master/texmf-dist/tex/latex/pdfmanagement-testphase/hgeneric-testphase.def b/Master/texmf-dist/tex/latex/pdfmanagement-testphase/hgeneric-testphase.def
index fd3ad3b4cb0..bb3bc091051 100644
--- a/Master/texmf-dist/tex/latex/pdfmanagement-testphase/hgeneric-testphase.def
+++ b/Master/texmf-dist/tex/latex/pdfmanagement-testphase/hgeneric-testphase.def
@@ -19,7 +19,7 @@
 %% and all files in that bundle must be distributed together.
 %% 
 %% File: hyperref-generic.dtx
-\ProvidesFile{hgeneric-testphase.def}[2021-07-31 v0.95h %
+\ProvidesFile{hgeneric-testphase.def}[2021-08-28 v0.95i %
   generic Hyperref driver for the LaTeX PDF management testphase bundle]
 
 \RequirePackage{etoolbox} %why?
@@ -150,6 +150,13 @@
     *~and~an~empty~value~which~removes~the~setting.\\
     No~value~is~equivalent~to~using~`true`.
   }
+\msg_new:nnn
+  { hyp }
+  { empty-info-value }
+  {
+    Empty~value~for~key~#1.\\
+    This~isn't~honored~by~all~backends.
+  }
 \cs_generate_variant:Nn\pdf_destination:nn {nf}
 \cs_generate_variant:Nn\pdf_object_ref:n {e}
 \chardef\Hy@VersionChecked=1 %don't check the version!
@@ -182,6 +189,14 @@
       { hyp~/~setup }{ \l_keys_key_str } { #1 }
     }
   }
+\keys_define:nn { hyp / setup }
+  {
+    next-anchor .code:n =
+    {
+      \AddToHookNext{__hyp/dest/make}
+       {\Hy@MakeCurrentHref{#1}}
+    }
+  }
 
 \bool_new:N \l__hyp_href_url_encode_bool
 \bool_new:N \l__hyp_href_url_ismap_bool
@@ -189,12 +204,12 @@
 \tl_new:N   \l__hyp_href_pdf_destination_tl
 \tl_new:N   \l__hyp_href_pdf_page_tl
 \tl_new:N   \l__hyp_href_run_parameter_tl
-\cs_new_protected:Npn \__hyp_href_url_format {\begingroup\Url}
+\cs_new_protected:Npn \__hyp_href_url_format: {\begingroup\Url}
 
 \keys_define:nn { hyp / href }
   {
     ,urlencode  .bool_set:N =  \l__hyp_href_url_encode_bool
-    ,format     .code:n = { \cs_set_eq:NN \__hyp_href_url_format #1 },
+    ,format     .code:n = { \cs_set:Nn \__hyp_href_url_format: {#1} },
     ,protocol  .tl_set:N   =  \l__hyp_href_url_protocol_tl
     ,destination .tl_set:N = \l__hyp_href_pdf_destination_tl
     ,pdfremotestartview .code:n =
@@ -236,7 +251,7 @@
     ,href / urlencode .initial:n  = {false}
     ,href / protocol  .tl_set:N   =   \l__hyp_href_url_protocol_tl
     ,href / destination .tl_set:N = \l__hyp_href_pdf_destination_tl
-    ,href / format  .code:n = { \cs_set_eq:NN \__hyp_href_url_format #1 }
+    ,href / format  .code:n = { \cs_set:Nn \__hyp_href_url_format:{#1} }
   }
 
 \hook_new_pair:nn{cmd/href/before}{cmd/href/after}
@@ -351,7 +366,7 @@
 \cs_new_protected:Npn \__hyp_href_url_aux:n #1
  {
    \exp_args:Nno
-     \hyper@linkurl{\__hyp_href_url_format {#1}}
+     \hyper@linkurl{\__hyp_href_url_format: {#1}}
      {\l__hyp_href_url_protocol_tl#1}
    \group_end:
    \hook_use:n{cmd/url/after}
@@ -375,28 +390,55 @@
   }
 \cs_generate_variant:Nn \__hyp_store_metadata:nn {xn,nx,xx}
 \hook_new:n{hyp/link/cite}
-\color_set:nnn {hyp/color/cite}{HTML}{2E7E2A}
-\color_set:nn  {hyp/color/citeborder}{hyp/color/cite!60!white}
 \keys_define:nn { hyp / setup }
   {
-    ,citecolor .code:n = {\__hyp_color_set:ne {hyp/color/cite}{#1}}
+    ,citecolor .code:n = {\__hyp_color_set:ne {hyp/color/cite}{#1}\__hyp_citecolor_hook_init:}
     ,citebordercolor
-      .code:n = {\__hyp_color_set:ne {hyp/color/citeborder}{#1}}
+      .code:n = {\__hyp_color_set:ne {hyp/color/citeborder}{#1}\__hyp_citebordercolor_hook_init:}
   }
-\hook_gput_code:nnn { hyp/link/cite }{hyp/cite}
-  {
-    \keys_set:nn { hyp / setup }
-      {
-        ,linkbordercolor= hyp/color/citeborder
-        ,linkcolor      = hyp/color/cite
-      }
+\cs_new_protected:Npn \__hyp_citecolor_hook_init:
+ {
+   \hook_gput_code:nnn { hyp/link/cite }{hyp/cite}
+     {
+       \keys_set:nn { hyp / setup }
+         {
+           linkcolor      = hyp/color/cite
+         }
+     }
+  \cs_gset_eq:NN \__hyp_citecolor_hook_init: \prg_do_nothing:
+  }
+\cs_new_protected:Npn \__hyp_citebordercolor_hook_init:
+ {
+   \hook_gput_code:nnn { hyp/link/cite }{hyp/citeborder}
+     {
+       \keys_set:nn { hyp / setup }
+         {
+           linkbordercolor      = hyp/color/citeborder
+         }
+     }
+  \cs_gset_eq:NN \__hyp_citebordercolor_hook_init: \prg_do_nothing:
   }
+
 \bool_lazy_and:nnF
   { \cs_if_exist_p:N \pdfmanagement_if_active_p: }{ \pdfmanagement_if_active_p: }
   { \msg_error:nn { hyp}{ missing-resource-management } }
+\AddToHook { package / after / bookmark}
+ {
+   \define@key{BKM}{color}
+     {
+       \__hyp_color_set:ne {__hyp/tmpa}{#1}
+       \color_export:nVN
+         {__hyp/tmpa}
+         \g__hyp_bordercolormodel_str
+         \BKM@color
+     }
+ }
 \legacy_if:nT { Hy@bookmarks }
   {
-    \AddToHook{begindocument/before}[hyperref/bookmark]{\RequirePackage{bookmark}}
+    \AddToHook{begindocument/before}[hyperref/bookmark]
+     {
+       \RequirePackage{bookmark}
+     }
   }
 \legacy_if:nT {Hy@draft}
   {
@@ -852,23 +894,7 @@
       {{\let\protect\relax#2}}
   }
 
-\cs_new_protected:Npn \__hyp_color_export:nnN #1  #2  #3
- {
-   \tl_if_head_eq_charcode:nNTF {#1}[ %]
-    {
-      \__hyp_color_export_aux:wnnN  #1 {#2} #3
-    }
-    {
-      \color_export:nnN {#1} {#2} #3
-    }
- }
-
-\cs_new_protected:Npn \__hyp_color_export_aux:wnnN  [#1] #2 #3 #4
-  {
-     \color_export:nnnN {#1}{#2}{#3}#4
-  }
-
-\cs_generate_variant:Nn \__hyp_color_export:nnN {xVN}
+\cs_generate_variant:Nn \color_export:nnN {nVN}
 \cs_new_protected:Npn \__hyp_color_select:n #1
  {
    \tl_if_head_eq_charcode:nNTF {#1}[ %]
@@ -980,7 +1006,11 @@
                   { C }
                }
                {
-                 \__hyp_color_export:xVN {##1}\g__hyp_bordercolormodel_str \l__hyp_tmpa_tl
+                 \__hyp_color_set:ne {hyp/color/#1border}{##1}
+                 \color_export:nVN
+                   {hyp/color/#1border}
+                   \g__hyp_bordercolormodel_str
+                   \l__hyp_tmpa_tl
                  \pdfannot_dict_put:nnx
                    {link/#2}
                    { C }
@@ -2104,7 +2134,22 @@
           {
             \tl_if_blank:nTF {##1}
               {
-                \pdfmanagement_remove:nn {Info}{#2}
+                \str_case:nnF { #1 }
+                 {
+                   {creator}
+                   {
+                     \msg_info:nnn { hyp }{ empty-info-value } { pdfcreator }
+                     \pdfmanagement_add:nnx {Info}{Creator}{()}
+                   }
+                   {producer}
+                   {
+                     \msg_info:nnn { hyp }{ empty-info-value } { pdfproducer }
+                     \pdfmanagement_add:nnx {Info}{Producer}{()}
+                   }
+                 }
+                 {
+                   \pdfmanagement_remove:nn {Info}{#2}
+                 }
               }
               {
                 \__hyp_text_pdfstring_info:nN {##1}\l__hyp_tmpa_str
@@ -2162,7 +2207,7 @@
                 \pdfmanagement_remove:nn {Info}{#2}
               }
               {
-                \pdfmanagement_add:nnx {Info}{#2}{(\tl_to_str:n {##1})}
+                \pdfmanagement_add:nnx {Info}{#2}{(##1)}
               }
              \__hyp_store_metadata:nn {pdf#1}{##1}
           }
@@ -2176,7 +2221,7 @@
                 \pdfmanagement_remove:nn {Info}{#2}
               }
               {
-                \pdfmanagement_add:nnx {Info}{#2}{(\tl_to_str:n {##1})}
+                \pdfmanagement_add:nnx {Info}{#2}{(##1)}
               }
             \exp_args:Nx \__hyp_store_metadata:nn {pdf\str_lowercase:n{#1}}{##1}
           }
-- 
cgit v1.2.3

