[latex3-commits] [git/LaTeX3-latex3-pdfresources] testlinkstuff: first testing of endlink hook (a31740b)

Ulrike Fischer fischer at troubleshooting-tex.de
Wed Mar 13 00:25:31 CET 2019


Repository : https://github.com/latex3/pdfresources
On branch  : testlinkstuff
Link       : https://github.com/latex3/pdfresources/commit/a31740b3b5ccda07dd858322076167b707250fca

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

commit a31740b3b5ccda07dd858322076167b707250fca
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Wed Mar 13 00:25:31 2019 +0100

    first testing of endlink hook


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

a31740b3b5ccda07dd858322076167b707250fca
 hluatex-experimental.def |   10 +++-
 pdfresources.dtx         |   12 ++--
 test-tagpdf-link.tex     |  144 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 159 insertions(+), 7 deletions(-)

diff --git a/hluatex-experimental.def b/hluatex-experimental.def
index cd00164..1f347f6 100644
--- a/hluatex-experimental.def
+++ b/hluatex-experimental.def
@@ -442,11 +442,15 @@
 \def\Hy at StartlinkName#1#2{%
   \pdfstartlink attr{#1}goto name{#2}\relax
 }
-\def\close at pdflink{%
+
+\ExplSyntaxOn
+\def\close at EXPpdflink#1{%
   \Hy at endcolorlink
   \Hy at VerboseLinkStop
-  \pdfendlink
+  \pdf_endlink:n { #1 }
 }
+
+\ExplSyntaxOff
 \def\hyper at anchor#1{%
   \new at pdflink{#1}\anchor at spot\pdf at endanchor
 }
@@ -500,7 +504,7 @@
        >>
     }
     \Hy at colorlink\@urlcolor#1\Hy at xspace@end
-    \close at pdflink
+    \close at EXPpdflink { url }
   \endgroup
 }
 \ExplSyntaxOff
diff --git a/pdfresources.dtx b/pdfresources.dtx
index 266b65e..1d6e7d6 100644
--- a/pdfresources.dtx
+++ b/pdfresources.dtx
@@ -188,15 +188,19 @@
 %
 % \subsubsection{Endlink}
 % tagpdf needs to execute code at the end of the link to store the object reference etc.
-% So we need a hook. Is a hook a tl or a cs??
+% So we need a hook. For now the hook is a seq: This will perhaps allows a system to
+% add and remove hooks by index. The hook depends on the type.
 %    \begin{macrocode}
-\cs_new_protected:Nn \pdf_endlink:
+\seq_new:N \l__pdf_endlink_url_hook_seq
+\seq_new:N \l__pdf_endlink_run_hook_seq
+\seq_new:N \l__pdf_endlink_file_hook_seq
+
+\cs_new_protected:Nn \pdf_endlink:n %#1 type, e.g. url
  {
   \driver_pdf_endlink:
-  \g__pdf_endlink_hook_tl % or \__pdf_endlink_hook: ???
+  \seq_use:cn { l__pdf_endlink_#1_hook_seq }{}
  }
 
 
-
 %    \end{macrocode}
 % \PrintIndex
diff --git a/test-tagpdf-link.tex b/test-tagpdf-link.tex
new file mode 100644
index 0000000..f2e23b9
--- /dev/null
+++ b/test-tagpdf-link.tex
@@ -0,0 +1,144 @@
+% !Mode:: "TeX:DE:UTF-8:Main"
+
+% GRRRRRR. Why do the validators report that the link is not tagged????
+% Damn I forgot that objects must go in the parent tree too ...
+
+\RequirePackage{ifluatex}
+\ifluatex
+\pdfvariable minorversion 7
+\pdfvariable majorversion 1
+\else
+\pdfminorversion 7
+\fi
+
+\documentclass{article}
+
+\usepackage{tagpdf}
+\tagpdfsetup{
+ activate-all,
+ uncompress,
+ tabsorder=structure,
+ interwordspace=true,
+ %show-spaces
+ }
+%metadata
+%\tagpdfsetup{add-new-tag = Link/Link}
+\ifluatex
+\pdfextension catalog{/Lang (en-UK)}
+\else
+\pdfcatalog {/Lang (en-UK)}
+\fi
+
+%very bad hack to input the dtx directly ....
+\def\documentclass#1\end#2{}
+
+\makeatletter\ExplSyntaxOn
+\input{pdfresources.dtx}
+\makeatother\ExplSyntaxOff
+
+\usepackage[customdriver=hluatex-experimental]{hyperref}
+\hypersetup{urlcolor=red,pdfborder={1 1 1}}
+\hypupdateattribute
+
+%add hooks:
+\ExplSyntaxOn\makeatletter
+\pdf_startlink_add_attr:nnn {url}{/StructParent}{\int_use:N\c at g__uftag_parenttree_obj_int}
+\seq_put_right:Nn \l__pdf_endlink_url_hook_seq {\__uftag_struct_finish_link:}
+\ExplSyntaxOff
+\begin{document}
+\tagstructbegin{tag=Document}
+\leavevmode
+\tagstructbegin{tag=P}
+\tagmcbegin{tag=P}
+abc
+\tagmcend
+\tagmcbegin{tag=P}
+abc
+\tagmcend
+\tagstructbegin{tag=Link}
+\tagmcbegin{tag=Span}
+\href{www.dante.de}{link linkl}
+\tagmcend
+\tagstructend
+
+\tagstructbegin{tag=Link}
+\tagmcbegin{tag=Span}
+\ExplSyntaxOn\makeatletter
+
+blb
+%\int_gincr:N\g__uftag_abspage_int
+\__uftag_pdf_startlink:
+    attr {/Border[0~0~1]}
+    user {
+          /Subtype/Link%
+          /A
+           <<
+            /Type/Action
+            /S/URI
+            /URI(http://www.dante.de)
+           >>
+         \c_space_tl
+         /StructParent \c_space_tl \int_use:N\c at g__uftag_parenttree_obj_int
+         }
+    This is a link. a long link a long link a long link a long line
+\__uftag_pdf_endlink:
+\__uftag_struct_finish_link:
+
+\ExplSyntaxOff
+\tagmcend
+\tagstructend
+
+\tagstructbegin{tag=Link}
+\tagmcbegin{tag=Span}
+\ExplSyntaxOn\makeatletter
+blb
+%\int_gincr:N\g__uftag_abspage_int
+\__uftag_pdf_startlink:
+    attr {/Border[0~0~1]}
+    user {
+          /Subtype/Link%
+          /A
+           <<
+            /Type/Action
+            /S/URI
+            /URI(http://www.dante.de)
+           >>
+         \c_space_tl
+         /StructParent \c_space_tl \int_use:N\c at g__uftag_parenttree_obj_int
+         }
+    This is a another link.
+\__uftag_pdf_endlink:
+
+%get the number of the parent link structure:
+\seq_get:NNF
+    \g__uftag_struct_stack_seq
+    \l__uftag_struct_stack_parent_tmp_tl
+    {
+     \msg_error:nn { uftag } { struct-faulty-nesting }
+    }
+% put the obj number of link annot in the kid entry:
+\__uftag_struct_kid_link_gput_right:nx
+ {
+  \l__uftag_struct_stack_parent_tmp_tl
+ }
+ {
+  \int_use:N\__uftag_pdf_lastlink:
+ }
+% add the parent obj number to the parent tree:
+ \__uftag_parenttree_add_objr:nn
+ {
+  \int_use:N\c at g__uftag_parenttree_obj_int
+ }
+ {
+  \prop_item:cn{ g__uftag_struct_\l__uftag_struct_stack_parent_tmp_tl _prop }
+  { objnum }
+ }
+% increase the int:
+\stepcounter{ g__uftag_parenttree_obj_int }
+
+\ExplSyntaxOff
+\tagmcend
+\tagstructend
+\tagstructend
+\tagstructend
+\end{document} 
\ No newline at end of file





More information about the latex3-commits mailing list