[latex3-commits] [git/LaTeX3-latex3-pdfresources] testlink: experiments (9793307)

Ulrike Fischer fischer at troubleshooting-tex.de
Mon Mar 15 19:48:59 CET 2021


Repository : https://github.com/latex3/pdfresources
On branch  : testlink
Link       : https://github.com/latex3/pdfresources/commit/97933073bc8b2b0b82fa128ae6ab9688fe62dc83

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

commit 97933073bc8b2b0b82fa128ae6ab9688fe62dc83
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Mon Mar 15 19:48:59 2021 +0100

    experiments


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

97933073bc8b2b0b82fa128ae6ab9688fe62dc83
 experiments/linkinput.tex   | 91 +++++++++++++++++++++++++++++++++++----------
 experiments/testfileenc.tex | 42 +++++++++++++++++++++
 2 files changed, 114 insertions(+), 19 deletions(-)

diff --git a/experiments/linkinput.tex b/experiments/linkinput.tex
index 8a46ddd..a5c3fa2 100644
--- a/experiments/linkinput.tex
+++ b/experiments/linkinput.tex
@@ -11,15 +11,13 @@
 \newcommand\cs[1]{\texttt{\textbackslash #1}}
 
 \makeatletter
-
-
-\ExplSyntaxOn
-
-\ExplSyntaxOff
-
+{\catcode`\%=12 \gdef\hyper at space{%20}}
+ \let\hyperspace\hyper at space
+% \let\ \hyper at space
 \makeatother
 \begin{document}
 
+
 %\href[encode]{www.öäü%§(.de}{blblbl}
 %
 %%\hypersetup{encode}
@@ -28,32 +26,87 @@
 %
 %\href[encode=false]{www.abc%25(xxx.de}{seöäüß}
 
-\href[encode]{www.%.de}{abc}   %-> www.%25.de
-\href{www.%.de}{abc}           %-> www.%.de
-\href[encode]{www.grüße.de}{abc} %-> www.gr%C3%BC%C3%9Fe.de
-% \href{www.grüße.de}{abc} % error
-\href[encode]{grüße}{abc} %-> (gr\303\274\303\237e.pdf)
-
-\href{filexxx}{seöäüß}
-\end{document}
-\section{Some background about URL's with hyperref}
+%\href[encode]{www.%.de}{abc}   %-> www.%25.de
+%\href{www.%.de}{abc}           %-> www.%.de
+%\href[encode]{www.grüße.de}{abc} %-> www.gr%C3%BC%C3%9Fe.de
+%% \href{www.grüße.de}{abc} % error
+%\href[encode]{grüße}{abc} %-> (gr\303\274\303\237e.pdf)
+%
+%\href{filexxx}{seöäüß}
+%\end{document}
+\section{Some background about URL's and file references with hyperref}
 
-hyperref has three commands related to URL: \cs{url},
+hyperref has three commands related to URL and file references: \cs{url},
 \cs{nolinkurl} and \cs{href}. The first two take one argument,
 while the last has two, the url and some free text.
 
 
 \cs{url} and \cs{href} create link annotations. \cs{url} creates always an URI
-type, \cs{href} create URI, GoToR and Launch depending on the structure of the argument.
+type, \cs{href} creates URI, GoToR and Launch depending on the structure of the argument.
 
 \cs{href} has to create a (in the PDF) valid url or file name from its first argument.
-\cs{url} has to create a (in the PDF) valid url from its only argument and has to print
+\cs{url} has to create a (in the PDF) valid url from its only argument and has also to print
 this argument as url. \cs{nolinkurl} only prints the url.
 
 For the printing \cs{url} and \cs{nolinkurl} rely on the url package and its \cs{Url} command.
 
-(Expandable) commands are expanded and special chars can also be input by commands but beside this no conversion is done: for all input hyperref basically assumes that the input is already a valid percent encoded url or a valid file name.
+(Expandable) commands are expanded and special chars can also be input by commands but 
+beside this no conversion is done: for all input hyperref basically assumes that 
+the input is already a valid percent encoded url or a valid file name. hyperref also
+doesn't extend or add protocols.
+
+As nowadays everyone is used to copy and paste links with all sorts of unicode into a browser and
+they work the hyperref input is clearly rather restricted. 
+
+
+With \cs{href} it is possible to extend the input methods and to allow unicode input which is then
+percent encoded by the code. 
+
+But extending the \emph{print} options for \cs{url} and \cs{nolinkurl}
+is hard to impossible in pdf\LaTeX{} due to the way the url package works. 
+Some chars can be added with the help of \cs{UrlSpecial} (at the cost of warnings)
+but it doesn't work for every input and documenting and explaining all the edge cases is no joy.
+
+\subsection{Links to files}
+
+When a file is linked with \cs{href} than normally it is added as URI link. The exceptions are PDF's, 
+for them PDF has the special type GoToR which allows also to link to a destination or a special page.
+
+The rules here are 
+\begin{itemize}
+\item GoToR links to PDF's with ascii names in the same folder or relative pathes normally works.
+\item URI links to PDF's with ascii names in the same folder or relative pathes normally works.
+\item Everything else works only sometimes in some PDF viewer.
+\end{itemize}
+
+\href{pdfa-test.pdf}{test-ascii}
+
+\ExplSyntaxOn
+\tl_set:Nn \l__hyp_text_enc_file_print_tl {utf8/URI}
+\ExplSyntaxOff
+\href[urlencode]{grüßpdf.pdf}{test utf8/URI}
+
+\ExplSyntaxOn
+\tl_set:Nn \l__hyp_text_enc_file_print_tl {utf8/string}
+\ExplSyntaxOff
+\href[urlencode]{grüßpdf.pdf}{test utf8/string}
+
+
+\ExplSyntaxOn
+\tl_set:Nn \l__hyp_text_enc_file_print_tl {utf16/string}
+\ExplSyntaxOff
+\href[urlencode]{grüßpdf.pdf}{test utf16/string}
+
+
+\ExplSyntaxOn
+\tl_set:Nn \l__hyp_text_enc_file_print_tl {utf16/hex}
+\ExplSyntaxOff
+\href[urlencode]{grüßpdf.pdf}{test utf16/hex}
+
+
+\hrefurl[urlencode]{grüßpdf.pdf}{test as URI}
 
+\href[urlencode]{grüße.txt}{test} %URI, WORKS
 
 \href{https://www.abc(blub).de}{xxx}
 \end{document}
diff --git a/experiments/testfileenc.tex b/experiments/testfileenc.tex
new file mode 100644
index 0000000..60c6e97
--- /dev/null
+++ b/experiments/testfileenc.tex
@@ -0,0 +1,42 @@
+% !Mode:: "TeX:DE:UTF-8:Main"
+\RequirePackage{pdfmanagement-testphase}
+\DeclareDocumentMetadata{uncompress}
+
+\documentclass{article}
+\usepackage{hyperref}
+\begin{document}
+\parskip1cm
+
+%\ExplSyntaxOn
+%\tl_set:Nn \l__hyp_text_enc_file_print_tl {utf8/string}
+%\ExplSyntaxOff
+%\href{test_~abc.pdf}{test ascii utf8/string}
+
+
+\ExplSyntaxOn
+\tl_set:Nn \l__hyp_text_enc_file_print_tl {utf8/URI}
+\ExplSyntaxOff
+\href[urlencode]{grüßpdf.pdf}{test utf8/URI}
+
+\ExplSyntaxOn
+\tl_set:Nn \l__hyp_text_enc_file_print_tl {utf8/string}
+\ExplSyntaxOff
+\href[urlencode]{grüßpdf.pdf}{test utf8/string}
+
+
+\ExplSyntaxOn
+\tl_set:Nn \l__hyp_text_enc_file_print_tl {utf16/string}
+\ExplSyntaxOff
+\href[urlencode]{grüßpdf.pdf}{test utf16/string}
+
+
+\ExplSyntaxOn
+\tl_set:Nn \l__hyp_text_enc_file_print_tl {utf16/hex}
+\ExplSyntaxOff
+\href[urlencode]{grüßpdf.pdf}{test utf16/hex}
+
+
+\hrefurl[urlencode]{grüßpdf.pdf}{test as URI}
+
+
+\end{document}





More information about the latex3-commits mailing list.