[latex3-commits] [git/LaTeX3-latex3-pdfresources] develop: add urldef definition to avoid error from optional argument (c230e20)

Ulrike Fischer fischer at troubleshooting-tex.de
Fri Apr 2 12:04:28 CEST 2021


Repository : https://github.com/latex3/pdfresources
On branch  : develop
Link       : https://github.com/latex3/pdfresources/commit/c230e206cc6c6fc802b928b7109de3b0bb5fbc45

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

commit c230e206cc6c6fc802b928b7109de3b0bb5fbc45
Author: Ulrike Fischer <fischer at troubleshooting-tex.de>
Date:   Fri Apr 2 12:04:28 2021 +0200

    add urldef definition to avoid error from optional argument


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

c230e206cc6c6fc802b928b7109de3b0bb5fbc45
 hyperref-generic.dtx | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/hyperref-generic.dtx b/hyperref-generic.dtx
index 1c5d46e..a1bed35 100644
--- a/hyperref-generic.dtx
+++ b/hyperref-generic.dtx
@@ -325,7 +325,8 @@
 % \subsection{Options}
 % All \cs{href} commands and \cs{url} have an option argument for keyval syntax.
 % It accepts the following keys. Not all keys make sense for all keys, but they don't
-% error, they are silently ignored.
+% error, they are silently ignored. The optional argument can currently not be used together
+% with the \cs{urldef} command.
 %
 % \begin{tabular}{llp{6cm}}
 % key & applicable commands  & note\\\hline
@@ -1329,7 +1330,20 @@
    \group_end:
  }
 
+%    \end{macrocode}
+% the \cs{urldef} command doesn't like the optional argument, so we overwrite
+% locally the \cs{url} command here:
+%    \begin{macrocode}
+
+\def\urldef#1#2{\begingroup\def\url{\hyper at normalise\url@}\setbox\z@\hbox\bgroup
+  \def\Url at HyperHook##1\endgroup{\Url at def{#1}{#2}}%
+  % Because hyperref breaks \urldef and does not define its own (Grrrr!)...
+  \def\url@##1{\egroup\endgroup\DeclareRobustCommand#1{#2{##1}}}%
+ #2}
 
+%    \end{macrocode}
+% make the new commands compatible with \cs{pdfstringdef}:
+%    \begin{macrocode}
 \NewExpandableDocumentCommand\@@_secondoftwowithopt:wnn {omm}{#3}
 \pdfstringdefDisableCommands{\let\hrefurl\@@_secondoftwowithopt:wnn}
 \pdfstringdefDisableCommands{\let\hrefpdf\@@_secondoftwowithopt:wnn}





More information about the latex3-commits mailing list.