[latex3-commits] [git/LaTeX3-latex3-pdfresources] master: working on link and destination code (3b4cffe)

Ulrike Fischer fischer at troubleshooting-tex.de
Fri Mar 20 00:45:52 CET 2020


Repository : https://github.com/latex3/pdfresources
On branch  : master
Link       : https://github.com/latex3/pdfresources/commit/3b4cffe58223ec4b1d38d5c6a31540553d5ef718

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

commit 3b4cffe58223ec4b1d38d5c6a31540553d5ef718
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Fri Mar 20 00:45:52 2020 +0100

    working on link and destination code


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

3b4cffe58223ec4b1d38d5c6a31540553d5ef718
 hgeneric-experimental.def | 91 +++++++++++++++++++++++++----------------------
 hyperreflinktypes.tex     |  6 ++--
 2 files changed, 51 insertions(+), 46 deletions(-)

diff --git a/hgeneric-experimental.def b/hgeneric-experimental.def
index bb0e7ab..1257412 100644
--- a/hgeneric-experimental.def
+++ b/hgeneric-experimental.def
@@ -36,6 +36,13 @@
   { pdfa-no-reset-button }
   { PDF/A:~Reset~action~is~prohibited }
 
+\msg_new:nnn
+  { hyp }
+  { empty-destination-name }
+  {
+    Empty~destination~name,\\
+            using~`#1'
+  }
 %% I require the bookmark package to get rid of some of the bookmarks code.
 % but the testing code doesn't work.
 % !!!!!!!!!!!!!!!!!!!!! to do !!!!!!!!!!!!!!!!!!!!!
@@ -300,17 +307,16 @@
     \char_set_catcode_active:N \~
     \sys_if_engine_pdftex:TF
       { %pdftex. Should we assume utf8 or allow other input encodings?
-        \exp_args:NNx % or only o?
-          \str_gset_convert:Nnnn \g_tmpa_str {#2}{utf8}{utf8/string} %utf8 because of hyperref
+        \str_gset_convert:Nnnn \g_tmpa_str {#2}{utf8}{utf8/string} %utf8 because of hyperref
       }
       { %luatex,xetex
-        \exp_args:NNx % or only o?
-          \str_gset_convert:Nnnn \g_tmpa_str {#2}{}{utf8/string} %utf8 because of hyperref
+        \str_gset_convert:Nnnn \g_tmpa_str {#2}{}{utf8/string} %utf8 because of hyperref
       }
     \group_end:
     \str_set_eq:NN#1 \g_tmpa_str
   }
-\cs_set_eq:NN\Hy at pstringdef \__hyp_pstringdef:Nn
+\cs_generate_variant:Nn \__hyp_pstringdef:Nn {No,Nx}
+\cs_set_eq:NN\Hy at pstringdef \__hyp_pstringdef:Nx
 \ExplSyntaxOff
 
 
@@ -478,21 +484,18 @@
 
 \ExplSyntaxOn
 \newcommand\Hy at pstringDest{}
+\tl_new:N \__hyp_pdfstring_tmp_tl
 
-\Hy at WrapperDef\new at pdflink#1{% #1 is a destination name.
-  \ifhmode
-    \@savsf\spacefactor
-  \fi
-  \Hy at SaveLastskip
-  \Hy at VerboseAnchor{#1}%
-  \Hy at pstringdef\Hy at pstringDest{\HyperDestNameFilter{#1}}%
-  %\Hy at DestName\Hy at pstringDest\@pdfview
-  \pdf_destination:nf { \Hy at pstringDest } { \@pdfview } %types??
-  \Hy at RestoreLastskip
-  \ifhmode
-    \spacefactor\@savsf
-  \fi
-}
+\Hy at WrapperDef\new at pdflink#1 % #1 is a destination name.
+  {
+    \mode_if_horizontal:T { \@savsf\spacefactor }
+    \Hy at SaveLastskip      %defined in hyperref
+    \Hy at VerboseAnchor{#1} %define in hyperref, for debugging
+    \__hyp_pstringdef:Nx  \__hyp_pdfstring_tmp_tl { \HyperDestNameFilter{#1} } %
+    \exp_args:NV \pdf_destination:nf { \__hyp_pdfstring_tmp_tl } { \@pdfview } %
+    \Hy at RestoreLastskip
+    \mode_if_horizontal:T { \spacefactor\@savsf }
+  }
 \let\pdf at endanchor\@empty
 
 \ExplSyntaxOff
@@ -503,33 +506,35 @@
 %    \pdf_destination:nf {#1}{#2}
 %  }
 
-\ExplSyntaxOff
-\def\Hy at undefinedname{UNDEFINED}
-\def\find at pdflink#1#2{%
-  \leavevmode
-  \protected at edef\Hy at testname{#2}%
-  \ifx\Hy at testname\@empty
-    \Hy at Warning{%
-      Empty destination name,\MessageBreak
-      using `\Hy at undefinedname'%
-    }%
-    \let\Hy at testname\Hy at undefinedname
-  \else
-    \Hy at pstringdef\Hy at testname{%
-      \expandafter\HyperDestNameFilter\expandafter{\Hy at testname}%
-    }%
-  \fi
-  \Hy at StartlinkName{}%
-  \Hy at testname
-  \expandafter\Hy at colorlink\csname @linkcolor\endcsname
-}
+%\ExplSyntaxOff
+\tl_const:Nn \c__hyp_destname_undefined_tl {UNDEFINED}
+\tl_new:N \l__hyp_destname_tmpa_tl
 
-\ExplSyntaxOn
-\cs_new_protected:Npn \Hy at StartlinkName #1 #2
-  {
-    \pdf_link_begin_goto:nnw { link } { #2 }
+\def\find at pdflink#1#2
+  {%
+    \mode_leave_vertical:
+    \protected at edef\l__hyp_destname_tmpa_tl {#2}
+    \tl_if_empty:NTF \l__hyp_destname_tmpa_tl
+      {
+        \msg_warning:nnx { hyp } { empty-destination-name } { \c__hyp_destname_undefined_tl }
+        \tl_set_eq:NN \l__hyp_destname_tmpa_tl \c__hyp_destname_undefined_tl
+      }
+      { %I hope this is right ...
+        \__hyp_pstringdef:Nx \l__hyp_destname_tmpa_tl
+          {
+            \exp_args:No \HyperDestNameFilter { \l__hyp_destname_tmpa_tl }
+          }
+    %\Hy at pstringdef\Hy at testname{%
+    %  \expandafter\HyperDestNameFilter\expandafter{\Hy at testname}%
+    %}%
+     }
+     \exp_args:Nno
+       \pdf_link_begin_goto:nnw { link } { \l__hyp_destname_tmpa_tl }
+         \Hy at colorlink\@linkcolor
   }
 
+\ExplSyntaxOn
+
 %experiment end link code
 \cs_new_protected:Npn \close at EXPpdflink #1
   {
diff --git a/hyperreflinktypes.tex b/hyperreflinktypes.tex
index e31ed91..36f8d5f 100644
--- a/hyperreflinktypes.tex
+++ b/hyperreflinktypes.tex
@@ -34,12 +34,12 @@ Internal links
   used in hyperref.sty
   one argument: destination name
   
+  \hyper at anchor assumes that the outside caller correctly sets \anchor at spot (and the outside callers assume that \hyper at anchor set \anchor at spot.) 
+  
   Uses
   \hyper at anchorstart{Doc-Start}\hyper at anchorend
   \hyper at anchorstart{\@currentHref}\hyper at anchorend in \hyper at refstepcounter and various environments
-  inside the definition of \hyper@@anchor: \hyper@@anchor is used in various environments where text is involved and
-  typically in combination with nesting. (Very) old version of hyperref.dtx suggest that anchorcolor which does nothing
-  now was involved here.
+  inside the definition of \hyper@@anchor: \hyper@@anchor (defined in hyperref) is used in various environments where text is involved and typically in combination with nesting. (Very) old version of hyperref.dtx suggests that anchorcolor which does nothing now was involved here.
   \def\hypertarget#1#2{%
   \ifHy at nesting
     \hyper@@anchor{#1}{#2}%





More information about the latex3-commits mailing list.