[latex3-commits] [git/LaTeX3-latex3-latex3] master: Split link creation into begin/end functions (8b7eee2)

Joseph Wright joseph.wright at morningstar2.co.uk
Wed Apr 17 13:48:57 CEST 2019


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

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

commit 8b7eee2bc459263974c947401f0a6ce24b2a1d1a
Author: Joseph Wright <joseph.wright at morningstar2.co.uk>
Date:   Wed Apr 17 12:47:34 2019 +0100

    Split link creation into begin/end functions
    
    By using a box, we can keep the ability of hypdvips
    to allow breaking of \pdfmark, but avoid the issue with
    finding the end of the link.


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

8b7eee2bc459263974c947401f0a6ce24b2a1d1a
 l3kernel/l3drivers-pdf.dtx              |   79 ++++++++++++++++++++-----------
 l3kernel/l3drivers.dtx                  |   16 +++++--
 l3kernel/testfiles/m3expl001.luatex.tlg |    7 +--
 l3kernel/testfiles/m3expl001.ptex.tlg   |    7 +--
 l3kernel/testfiles/m3expl001.tlg        |    7 +--
 l3kernel/testfiles/m3expl001.uptex.tlg  |    7 +--
 l3kernel/testfiles/m3expl001.xetex.tlg  |    7 +--
 l3kernel/testfiles/m3expl003.luatex.tlg |    7 +--
 l3kernel/testfiles/m3expl003.ptex.tlg   |    7 +--
 l3kernel/testfiles/m3expl003.tlg        |    7 +--
 l3kernel/testfiles/m3expl003.uptex.tlg  |    7 +--
 l3kernel/testfiles/m3expl003.xetex.tlg  |    7 +--
 12 files changed, 103 insertions(+), 62 deletions(-)

diff --git a/l3kernel/l3drivers-pdf.dtx b/l3kernel/l3drivers-pdf.dtx
index 6869722..df76070 100644
--- a/l3kernel/l3drivers-pdf.dtx
+++ b/l3kernel/l3drivers-pdf.dtx
@@ -690,7 +690,14 @@
 %    \end{macrocode}
 % \end{variable}
 %
-% \begin{macro}{\driver_pdf_link_goto:nnn, \driver_pdf_link_user:nnn}
+% \begin{variable}{\g_@@_pdf_link_dict_tl}
+%   To pass information to the end-of-link function.
+%    \begin{macrocode}
+\int_new:N \g_@@_pdf_link_dict_tl
+%    \end{macrocode}
+% \end{variable}
+%
+% \begin{macro}{\driver_pdf_link_begin_goto:nnw, \driver_pdf_link_begin_user:nnw}
 % \begin{macro}{\@@_pdf_link:nnnn}
 % \begin{macro}{\@@_pdf_link_minima:}
 % \begin{macro}{\@@_pdf_link_outerbox:n}
@@ -706,7 +713,9 @@
 %     driver.baselineskip
 %   }
 %   Links are crated like annotations but with dedicated code to allow for
-%   adjusting the size of the rectangle.
+%   adjusting the size of the rectangle. In contrast to \pkg{hyperref}, we
+%   grab the link content as a box which can then unbox: this allows the same
+%   interface as for \pdfTeX{}.
 %
 %   Taking the idea of |evenboxes| from \pkg{hypdvips}, we implement a minimum
 %   box height and depth for link placement. This means that \enquote{underlining}
@@ -724,11 +733,11 @@
 %   Getting the outer dimensions of the text area may be better using a two-pass
 %   approach and |\tex_savepos:D|. That plus format mode are still to re-examine.
 %    \begin{macrocode}
-\cs_new_protected:Npn \driver_pdf_link_goto:nnn #1#2#3
-  { \@@_pdf_link:nnnn {#1} { /GoTo } {#2} {#3} }
-\cs_new_protected:Npn \driver_pdf_link_user:nnn #1#2#3
-  { \@@_pdf_link:nnnn {#1} { } {#2} {#3} }
-\cs_new_protected:Npn \@@_pdf_link:nnnn #1#2#3#4
+\cs_new_protected:Npn \driver_pdf_link_begin_goto:nnw #1#2
+  { \@@_pdf_link_begin:nnnw {#1} { /GoTo } {#2} }
+\cs_new_protected:Npn \driver_pdf_link_begin_user:nnw #1#2
+  { \@@_pdf_link_begin:nnnw {#1} { } {#2} }
+\cs_new_protected:Npn \@@_pdf_link_begin:nnnw #1#2#3
   {
     \@@_postscript:n
       { /driver.link.dict ( #1 ~ #2 ~ #3 ~ /Subtype /Link ) def }
@@ -742,7 +751,12 @@
           }
             def
       }
-    \hbox_set:Nn \l_@@_pdf_content_box {#4}
+    \tl_gset:Nn \g_@@_pdf_link_dict_tl { #1 ~ #2 ~ #3 }
+    \hbox_set:Nw \l_@@_pdf_content_box
+  }
+\cs_new_protected:Npn \driver_pdf_link_end:
+  {
+    \hbox_set_end:
     \@@_pdf_link_minima:
     \hbox_set:Nn \l_@@_pdf_model_box { Gg }
     \exp_args:Nx \@@_driver_link_outerbox:n
@@ -769,7 +783,7 @@
     \@@_postscript:x
       {
         mark
-        #1 #2 #3 /Subtype /Link ~
+        \g_@@_pdf_link_dict_tl /Subtype /Link ~
         driver.annotation.border
         /ANN ~ driver.pdfmark
       }
@@ -954,22 +968,26 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\driver_pdf_link_goto:nnn, \driver_pdf_link_user:nnn}
-% \begin{macro}{\@@_pdf_link:nnnn}
+% \begin{macro}
+%   {\driver_pdf_link_begin_goto:nnw, \driver_pdf_link_begin_user:nnw}
+% \begin{macro}{\@@_pdf_link_begin:nnnw}
+% \begin{macro}{\driver_pdf_link_end:}
 %   Links are all created using the same internals.
 %    \begin{macrocode}
-\cs_new_protected:Npn \driver_pdf_link_goto:nnn #1#2#3
-  { \@@_pdf_link_begin:nnnn {#1} { goto~name } {#2} {#3} }
-\cs_new_protected:Npn \driver_pdf_link_user:nnn #1#2#3
-  { \@@_pdf_link_begin:nnnn {#1} { user } {#2} {#3} }
-\cs_new_protected:Npx \@@_pdf_link_begin:nnnn #1#2#3#4
+\cs_new_protected:Npn \driver_pdf_link_begin_goto:nnw #1#2
+  { \@@_pdf_link_begin:nnnw {#1} { goto~name } {#2} }
+\cs_new_protected:Npn \driver_pdf_link_begin_user:nnw #1#2
+  { \@@_pdf_link_begin:nnnw {#1} { user } {#2} }
+\cs_new_protected:Npx \@@_pdf_link_begin:nnnw #1#2#3
   {
     \cs_if_exist:NTF \tex_pdfextension:D
       { \tex_pdfextension:D startlink ~ }
       { \tex_pdfstartlink:D }
-      attr {#1}
-      #2 { /Subtype /Link #3 }
-    #4
+        attr {#1}
+        #2 { /Subtype /Link #3 }
+  }
+\cs_new_protected:Npx \driver_pdf_link_end:
+  {
     \cs_if_exist:NTF \tex_pdfextension:D
       { \tex_pdfextension:D endlink \scan_stop: }
       { \tex_pdfendlink:D }
@@ -977,6 +995,7 @@
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
+% \end{macro}
 %
 % \begin{macro}{\driver_pdf_link_last:}
 %   Formatted for direct use.
@@ -1308,14 +1327,17 @@
 %    \end{macrocode}
 % \end{macro}
 %
-% \begin{macro}{\driver_pdf_link_goto:nnn, \driver_pdf_link_user:nnn}
-% \begin{macro}{\@@_pdf_link_begin:nnnn}
+% \begin{macro}
+%   {\driver_pdf_link_begin_goto:nnw, \driver_pdf_link_begin_user:nnw}
+% \begin{macro}{\driver_pdf_link_end:}
+% \begin{macro}{\@@_pdf_link_begin:nnn}
+%   All created using the same internals.
 %    \begin{macrocode}
-\cs_new_protected:Npn \driver_pdf_link_goto:nnn #1#2#3
-  { \@@_pdf_link:nnnn {#1} { /GoTo } {#2} {#3} }
-\cs_new_protected:Npn \driver_pdf_link_user:nnn #1#2#3
-  { \@@_pdf_link:nnnn {#1} { } {#2} {#3} }
-\cs_new_protected:Npn \@@_pdf_link:nnnn #1#2#3#4
+\cs_new_protected:Npn \driver_pdf_link_begin_goto:nnw #1#2
+  { \@@_pdf_link_begin:nnnw {#1} { /GoTo } {#2} }
+\cs_new_protected:Npn \driver_pdf_link_begin_user:nn #1#2
+  { \@@_pdf_link_begin:nnnw {#1} { } {#2} }
+\cs_new_protected:Npn \@@_pdf_link_begin:nnnw #1#2#3
   {
     \@@_pdf:n
       {
@@ -1326,12 +1348,13 @@
            #1 ~ #2 ~ #3
          >>
       }
-    #4
-    \@@_pdf:n { eann }
   }
+\cs_new_protected:Npn \driver_pdf_link_end:
+  { \@@_pdf:n { eann } }
 %    \end{macrocode}
 % \end{macro}
 % \end{macro}
+% \end{macro}
 %
 % \begin{macro}{\driver_pdf_link_last:}
 %   Data not available.
diff --git a/l3kernel/l3drivers.dtx b/l3kernel/l3drivers.dtx
index ded567b..d3518c3 100644
--- a/l3kernel/l3drivers.dtx
+++ b/l3kernel/l3drivers.dtx
@@ -482,14 +482,22 @@
 %   and \meta{depth} and featuring the \meta{dictionary}.
 % \end{function}
 %
-% \begin{function}[added = 2019-04-10]
-%   {\driver_pdf_link_goto:nnn, \driver_pdf_link_user:nnn}
+% \begin{function}[added = 2019-04-17]
+%   {
+%     \driver_pdf_link_begin_goto:nnw,
+%     \driver_pdf_link_begin_user:nnw,
+%     \driver_pdf_link_end:
+%   }
 %   \begin{syntax}
-%     \cs{driver_pdf_link_user:nnn} \Arg{attributes} \Arg{action} \Arg{content}
+%     \cs{driver_pdf_link_begin_user:nnw} \Arg{attributes} \Arg{action}
+%     \Arg{content}
+%     \cs{driver_pdf_link_end:}
 %   \end{syntax}
 %   Creates a link of the \meta{type} |goto| or |user| with the given
 %   \meta{attributes}, points toward the \meta{action} and surround the
-%   \TeX{} \meta{content}.
+%   \TeX{} \meta{content}. The |begin| and |end| functions must be given
+%   at the same box level. Depending upon the back-end in use, the
+%   \meta{content} may be placed in a hbox as part of processing.
 % \end{function}
 %
 % \begin{function}[EXP, added = 2019-04-09]{\driver_pdf_link_last:}
diff --git a/l3kernel/testfiles/m3expl001.luatex.tlg b/l3kernel/testfiles/m3expl001.luatex.tlg
index b88f0f3..1d95609 100644
--- a/l3kernel/testfiles/m3expl001.luatex.tlg
+++ b/l3kernel/testfiles/m3expl001.luatex.tlg
@@ -6464,9 +6464,10 @@ Defining \__driver_image_include_pdf:n on line ...
 Defining \__driver_image_include_png:n on line ...
 Defining \driver_annotation:nnnn on line ...
 Defining \driver_pdf_annotation_last: on line ...
-Defining \driver_pdf_link_goto:nnn on line ...
-Defining \driver_pdf_link_user:nnn on line ...
-Defining \__driver_pdf_link_begin:nnnn on line ...
+Defining \driver_pdf_link_begin_goto:nnw on line ...
+Defining \driver_pdf_link_begin_user:nnw on line ...
+Defining \__driver_pdf_link_begin:nnnw on line ...
+Defining \driver_pdf_link_end: on line ...
 Defining \driver_pdf_link_last: on line ...
 Defining \driver_pdf_link_margin:n on line ...
 Defining \g__driver_pdf_object_prop on line ...
diff --git a/l3kernel/testfiles/m3expl001.ptex.tlg b/l3kernel/testfiles/m3expl001.ptex.tlg
index be80382..dc70e95 100644
--- a/l3kernel/testfiles/m3expl001.ptex.tlg
+++ b/l3kernel/testfiles/m3expl001.ptex.tlg
@@ -6521,9 +6521,10 @@ Defining \__driver_pdf_object_write_stream:nnnn on line ...
 Defining \g__driver_pdf_annotation_int on line ...
 \g__driver_pdf_annotation_int=\count...
 Defining \driver_pdf_annotation:nnnn on line ...
-Defining \driver_pdf_link_goto:nnn on line ...
-Defining \driver_pdf_link_user:nnn on line ...
-Defining \__driver_pdf_link:nnnn on line ...
+Defining \driver_pdf_link_begin_goto:nnw on line ...
+Defining \driver_pdf_link_begin_user:nn on line ...
+Defining \__driver_pdf_link_begin:nnnw on line ...
+Defining \driver_pdf_link_end: on line ...
 Defining \driver_pdf_link_last: on line ...
 Defining \driver_pdf_link_margin:n on line ...
 Defining \driver_pdf_compresslevel:n on line ...
diff --git a/l3kernel/testfiles/m3expl001.tlg b/l3kernel/testfiles/m3expl001.tlg
index 6c90a4b..d4ce4b0 100644
--- a/l3kernel/testfiles/m3expl001.tlg
+++ b/l3kernel/testfiles/m3expl001.tlg
@@ -6805,9 +6805,10 @@ Defining \__driver_image_include_pdf:n on line ...
 Defining \__driver_image_include_png:n on line ...
 Defining \driver_annotation:nnnn on line ...
 Defining \driver_pdf_annotation_last: on line ...
-Defining \driver_pdf_link_goto:nnn on line ...
-Defining \driver_pdf_link_user:nnn on line ...
-Defining \__driver_pdf_link_begin:nnnn on line ...
+Defining \driver_pdf_link_begin_goto:nnw on line ...
+Defining \driver_pdf_link_begin_user:nnw on line ...
+Defining \__driver_pdf_link_begin:nnnw on line ...
+Defining \driver_pdf_link_end: on line ...
 Defining \driver_pdf_link_last: on line ...
 Defining \driver_pdf_link_margin:n on line ...
 Defining \g__driver_pdf_object_prop on line ...
diff --git a/l3kernel/testfiles/m3expl001.uptex.tlg b/l3kernel/testfiles/m3expl001.uptex.tlg
index 2c2aee5..e44c559 100644
--- a/l3kernel/testfiles/m3expl001.uptex.tlg
+++ b/l3kernel/testfiles/m3expl001.uptex.tlg
@@ -6818,9 +6818,10 @@ Defining \__driver_pdf_object_write_stream:nnnn on line ...
 Defining \g__driver_pdf_annotation_int on line ...
 \g__driver_pdf_annotation_int=\count...
 Defining \driver_pdf_annotation:nnnn on line ...
-Defining \driver_pdf_link_goto:nnn on line ...
-Defining \driver_pdf_link_user:nnn on line ...
-Defining \__driver_pdf_link:nnnn on line ...
+Defining \driver_pdf_link_begin_goto:nnw on line ...
+Defining \driver_pdf_link_begin_user:nn on line ...
+Defining \__driver_pdf_link_begin:nnnw on line ...
+Defining \driver_pdf_link_end: on line ...
 Defining \driver_pdf_link_last: on line ...
 Defining \driver_pdf_link_margin:n on line ...
 Defining \driver_pdf_compresslevel:n on line ...
diff --git a/l3kernel/testfiles/m3expl001.xetex.tlg b/l3kernel/testfiles/m3expl001.xetex.tlg
index dbe0206..b30a42e 100644
--- a/l3kernel/testfiles/m3expl001.xetex.tlg
+++ b/l3kernel/testfiles/m3expl001.xetex.tlg
@@ -6497,9 +6497,10 @@ Defining \__driver_pdf_object_write_stream:nnnn on line ...
 Defining \g__driver_pdf_annotation_int on line ...
 \g__driver_pdf_annotation_int=\count...
 Defining \driver_pdf_annotation:nnnn on line ...
-Defining \driver_pdf_link_goto:nnn on line ...
-Defining \driver_pdf_link_user:nnn on line ...
-Defining \__driver_pdf_link:nnnn on line ...
+Defining \driver_pdf_link_begin_goto:nnw on line ...
+Defining \driver_pdf_link_begin_user:nn on line ...
+Defining \__driver_pdf_link_begin:nnnw on line ...
+Defining \driver_pdf_link_end: on line ...
 Defining \driver_pdf_link_last: on line ...
 Defining \driver_pdf_link_margin:n on line ...
 Defining \driver_pdf_compresslevel:n on line ...
diff --git a/l3kernel/testfiles/m3expl003.luatex.tlg b/l3kernel/testfiles/m3expl003.luatex.tlg
index b88f0f3..1d95609 100644
--- a/l3kernel/testfiles/m3expl003.luatex.tlg
+++ b/l3kernel/testfiles/m3expl003.luatex.tlg
@@ -6464,9 +6464,10 @@ Defining \__driver_image_include_pdf:n on line ...
 Defining \__driver_image_include_png:n on line ...
 Defining \driver_annotation:nnnn on line ...
 Defining \driver_pdf_annotation_last: on line ...
-Defining \driver_pdf_link_goto:nnn on line ...
-Defining \driver_pdf_link_user:nnn on line ...
-Defining \__driver_pdf_link_begin:nnnn on line ...
+Defining \driver_pdf_link_begin_goto:nnw on line ...
+Defining \driver_pdf_link_begin_user:nnw on line ...
+Defining \__driver_pdf_link_begin:nnnw on line ...
+Defining \driver_pdf_link_end: on line ...
 Defining \driver_pdf_link_last: on line ...
 Defining \driver_pdf_link_margin:n on line ...
 Defining \g__driver_pdf_object_prop on line ...
diff --git a/l3kernel/testfiles/m3expl003.ptex.tlg b/l3kernel/testfiles/m3expl003.ptex.tlg
index be80382..dc70e95 100644
--- a/l3kernel/testfiles/m3expl003.ptex.tlg
+++ b/l3kernel/testfiles/m3expl003.ptex.tlg
@@ -6521,9 +6521,10 @@ Defining \__driver_pdf_object_write_stream:nnnn on line ...
 Defining \g__driver_pdf_annotation_int on line ...
 \g__driver_pdf_annotation_int=\count...
 Defining \driver_pdf_annotation:nnnn on line ...
-Defining \driver_pdf_link_goto:nnn on line ...
-Defining \driver_pdf_link_user:nnn on line ...
-Defining \__driver_pdf_link:nnnn on line ...
+Defining \driver_pdf_link_begin_goto:nnw on line ...
+Defining \driver_pdf_link_begin_user:nn on line ...
+Defining \__driver_pdf_link_begin:nnnw on line ...
+Defining \driver_pdf_link_end: on line ...
 Defining \driver_pdf_link_last: on line ...
 Defining \driver_pdf_link_margin:n on line ...
 Defining \driver_pdf_compresslevel:n on line ...
diff --git a/l3kernel/testfiles/m3expl003.tlg b/l3kernel/testfiles/m3expl003.tlg
index 6c90a4b..d4ce4b0 100644
--- a/l3kernel/testfiles/m3expl003.tlg
+++ b/l3kernel/testfiles/m3expl003.tlg
@@ -6805,9 +6805,10 @@ Defining \__driver_image_include_pdf:n on line ...
 Defining \__driver_image_include_png:n on line ...
 Defining \driver_annotation:nnnn on line ...
 Defining \driver_pdf_annotation_last: on line ...
-Defining \driver_pdf_link_goto:nnn on line ...
-Defining \driver_pdf_link_user:nnn on line ...
-Defining \__driver_pdf_link_begin:nnnn on line ...
+Defining \driver_pdf_link_begin_goto:nnw on line ...
+Defining \driver_pdf_link_begin_user:nnw on line ...
+Defining \__driver_pdf_link_begin:nnnw on line ...
+Defining \driver_pdf_link_end: on line ...
 Defining \driver_pdf_link_last: on line ...
 Defining \driver_pdf_link_margin:n on line ...
 Defining \g__driver_pdf_object_prop on line ...
diff --git a/l3kernel/testfiles/m3expl003.uptex.tlg b/l3kernel/testfiles/m3expl003.uptex.tlg
index 2c2aee5..e44c559 100644
--- a/l3kernel/testfiles/m3expl003.uptex.tlg
+++ b/l3kernel/testfiles/m3expl003.uptex.tlg
@@ -6818,9 +6818,10 @@ Defining \__driver_pdf_object_write_stream:nnnn on line ...
 Defining \g__driver_pdf_annotation_int on line ...
 \g__driver_pdf_annotation_int=\count...
 Defining \driver_pdf_annotation:nnnn on line ...
-Defining \driver_pdf_link_goto:nnn on line ...
-Defining \driver_pdf_link_user:nnn on line ...
-Defining \__driver_pdf_link:nnnn on line ...
+Defining \driver_pdf_link_begin_goto:nnw on line ...
+Defining \driver_pdf_link_begin_user:nn on line ...
+Defining \__driver_pdf_link_begin:nnnw on line ...
+Defining \driver_pdf_link_end: on line ...
 Defining \driver_pdf_link_last: on line ...
 Defining \driver_pdf_link_margin:n on line ...
 Defining \driver_pdf_compresslevel:n on line ...
diff --git a/l3kernel/testfiles/m3expl003.xetex.tlg b/l3kernel/testfiles/m3expl003.xetex.tlg
index dbe0206..b30a42e 100644
--- a/l3kernel/testfiles/m3expl003.xetex.tlg
+++ b/l3kernel/testfiles/m3expl003.xetex.tlg
@@ -6497,9 +6497,10 @@ Defining \__driver_pdf_object_write_stream:nnnn on line ...
 Defining \g__driver_pdf_annotation_int on line ...
 \g__driver_pdf_annotation_int=\count...
 Defining \driver_pdf_annotation:nnnn on line ...
-Defining \driver_pdf_link_goto:nnn on line ...
-Defining \driver_pdf_link_user:nnn on line ...
-Defining \__driver_pdf_link:nnnn on line ...
+Defining \driver_pdf_link_begin_goto:nnw on line ...
+Defining \driver_pdf_link_begin_user:nn on line ...
+Defining \__driver_pdf_link_begin:nnnw on line ...
+Defining \driver_pdf_link_end: on line ...
 Defining \driver_pdf_link_last: on line ...
 Defining \driver_pdf_link_margin:n on line ...
 Defining \driver_pdf_compresslevel:n on line ...





More information about the latex3-commits mailing list