From 66f6e60b6dc60cc08482030b92df223b6a51b15f Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Sun, 29 Aug 2021 03:02:07 +0000 Subject: CTAN sync 202108290302 --- .../pdfmanagement-testphase/hyperref-generic.dtx | 205 +++++++++++++++------ 1 file changed, 144 insertions(+), 61 deletions(-) (limited to 'macros/latex/contrib/pdfmanagement-testphase/hyperref-generic.dtx') diff --git a/macros/latex/contrib/pdfmanagement-testphase/hyperref-generic.dtx b/macros/latex/contrib/pdfmanagement-testphase/hyperref-generic.dtx index 4e0296c641..24f129b8ff 100644 --- a/macros/latex/contrib/pdfmanagement-testphase/hyperref-generic.dtx +++ b/macros/latex/contrib/pdfmanagement-testphase/hyperref-generic.dtx @@ -86,7 +86,7 @@ % }^^A % } % -% \date{Version 0.95h, released 2021-07-31} +% \date{Version 0.95i, released 2021-08-28} % % \maketitle % \begin{documentation} @@ -357,8 +357,12 @@ % Some main changes are % \begin{itemize} % \item The default colors have been changed. -% \item |citecolor| is no longer set with |allcolors| and it is not part of the -% color scheme, it is only supported for compability. +% \item Citations have by default no special color, they are +% colored like other internal links. You can use |citecolor| and |citebordercolor| to +% assign them a special color. This color is not reset if you use |allcolors| or +% switch to another color scheme. If you want the colors to follow |linkcolor| again +% you should remove the label |hyp/cite| and/or |hyp/citeborder| +% from the hook |hyp/link/cite|. % \item a number of color schemes have been predefined. % \end{itemize} % @@ -438,7 +442,7 @@ % % The new key |colorscheme| allows to switch the colors (both for text and borders) % with a key word. It takes one of the values -% |orginal| (the colors as \pkg{hyperref} uses normally), |phelype|, |daleif|, +% |primary-colors| (the colors as \pkg{hyperref} uses normally), |phelype|, |daleif|, % |szabolcsA|, |szabolcsB|, |tivv|, |julian|, |henryford|. % % The names refer to the authors in answers and comments in @@ -758,6 +762,34 @@ % \end{itemize} % \end{itemize} % +% \subsection{Names of destinations} +% hyperref creates two types of destination names: For numbered structures +% (so when the anchor is set by \cs{refstepcounter}) it builds the name +% from the counter name and the \cs{theH...} representation: |.\theH|. +% +% For unnumbered structures, e.g. starred chapters or anchors created with \cs{phantomsection} +% it uses names like |section*.| and |chapter*.|. +% +% Typically the name of destination can be retrieved by setting a label, this works also +% with unnumbered sections. +% The anchor and also the page can be retrieve in an expandable way +% with the help of commands from the +% \pkg{refcount} package which is loaded by hyperref. For example with the +% following commands it is possible to use the label to create a bookmark: +% +% \begin{verbatim} +% \bookmark[dest=\getrefbykeydefault{label}{anchor}{Doc-Start}]{my bookmark} +% \bookmark[dest=page.\getrefbykeydefault{label}{page}{Doc-Start}]{my bookmark} +% \end{verbatim} +% +% If a \cs{HyperDestNameFilter} is defined, this must be added around the definition, +% so actually the full code has to look like this +% \begin{verbatim} +% \bookmark[dest= +% \HyperDestNameFilter{\getrefbykeydefault{label}{anchor}{Doc-Start}}]{mysection} +% \end{verbatim} +% To simplify this hyperref provides |\hyperget{anchor}{label}| and +% |\hyperget{pageanchor}{label}| % %\section{Assorted key descriptions}\label{sec:keydesc} %The following gives a few details to some keys that are perhaps not @@ -910,6 +942,7 @@ % %^^A %% \l_@@_dest_pdfview_tl %^^A %% list of commands which probably will have to change +%^^A TODO: move hrefurl, hrefrun, hrefpdf into hyperref. They should also work % \end{documentation} % \begin{implementation} % \part{\pkg{hyperref-generic} driver implementation} @@ -918,7 +951,7 @@ %<@@=hyp> % \end{macrocode} % \begin{macrocode} -\ProvidesFile{hgeneric-testphase.def}[2021-07-31 v0.95h % +\ProvidesFile{hgeneric-testphase.def}[2021-08-28 v0.95i % generic Hyperref driver for the LaTeX PDF management testphase bundle] \RequirePackage{etoolbox} %why? @@ -1091,6 +1124,16 @@ No~value~is~equivalent~to~using~`true`. } % \end{macrocode} +% A message for creator and producer which can't be removed. +% \begin{macrocode} +\msg_new:nnn + { hyp } + { empty-info-value } + { + Empty~value~for~key~#1.\\ + This~isn't~honored~by~all~backends. + } +% \end{macrocode} % \section{Variants} % \begin{macrocode} \cs_generate_variant:Nn\pdf_destination:nn {nf} @@ -1164,6 +1207,21 @@ } } % \end{macrocode} +% +% Hyperref creates a number of destinations automatically. E.g. in unnumbered +% chapters and sections and with \cs{phantomsection}. The following key allows +% to force a specific name for the destination so that it can be used by bookmarks. +% \begin{macrocode} +\keys_define:nn { hyp / setup } + { + next-anchor .code:n = + { + \AddToHookNext{__hyp/dest/make} + {\Hy@MakeCurrentHref{#1}} + } + } +% \end{macrocode} +% % Allow non-ascii in href, and add more href versions. % We add a few new keys: % |urlencode| to force percent encoding (\cs{hrefurl}, \cs{href}) @@ -1179,13 +1237,13 @@ \tl_new:N \l_@@_href_pdf_destination_tl \tl_new:N \l_@@_href_pdf_page_tl \tl_new:N \l_@@_href_run_parameter_tl -\cs_new_protected:Npn \@@_href_url_format {\begingroup\Url} +\cs_new_protected:Npn \@@_href_url_format: {\begingroup\Url} \keys_define:nn { hyp / href } { ,urlencode .bool_set:N = \l_@@_href_url_encode_bool - ,format .code:n = { \cs_set_eq:NN \@@_href_url_format #1 }, + ,format .code:n = { \cs_set:Nn \@@_href_url_format: {#1} }, ,protocol .tl_set:N = \l_@@_href_url_protocol_tl ,destination .tl_set:N = \l_@@_href_pdf_destination_tl ,pdfremotestartview .code:n = @@ -1227,7 +1285,7 @@ ,href / urlencode .initial:n = {false} ,href / protocol .tl_set:N = \l_@@_href_url_protocol_tl ,href / destination .tl_set:N = \l_@@_href_pdf_destination_tl - ,href / format .code:n = { \cs_set_eq:NN \@@_href_url_format #1 } + ,href / format .code:n = { \cs_set:Nn \@@_href_url_format:{#1} } } \hook_new_pair:nn{cmd/href/before}{cmd/href/after} @@ -1343,7 +1401,7 @@ \cs_new_protected:Npn \@@_href_url_aux:n #1 { \exp_args:Nno - \hyper@linkurl{\@@_href_url_format {#1}} + \hyper@linkurl{\@@_href_url_format: {#1}} {\l_@@_href_url_protocol_tl#1} \group_end: \hook_use:n{cmd/url/after} @@ -1386,22 +1444,37 @@ % % \begin{macrocode} \hook_new:n{hyp/link/cite} -\color_set:nnn {hyp/color/cite}{HTML}{2E7E2A} -\color_set:nn {hyp/color/citeborder}{hyp/color/cite!60!white} +%\color_set:nnn {hyp/color/cite}{HTML}{2E7E2A} +%\color_set:nn {hyp/color/citeborder}{hyp/color/cite!60!white} \keys_define:nn { hyp / setup } { - ,citecolor .code:n = {\@@_color_set:ne {hyp/color/cite}{#1}} + ,citecolor .code:n = {\@@_color_set:ne {hyp/color/cite}{#1}\@@_citecolor_hook_init:} ,citebordercolor - .code:n = {\@@_color_set:ne {hyp/color/citeborder}{#1}} + .code:n = {\@@_color_set:ne {hyp/color/citeborder}{#1}\@@_citebordercolor_hook_init:} } -\hook_gput_code:nnn { hyp/link/cite }{hyp/cite} - { - \keys_set:nn { hyp / setup } - { - ,linkbordercolor= hyp/color/citeborder - ,linkcolor = hyp/color/cite - } +\cs_new_protected:Npn \@@_citecolor_hook_init: + { + \hook_gput_code:nnn { hyp/link/cite }{hyp/cite} + { + \keys_set:nn { hyp / setup } + { + linkcolor = hyp/color/cite + } + } + \cs_gset_eq:NN \@@_citecolor_hook_init: \prg_do_nothing: } +\cs_new_protected:Npn \@@_citebordercolor_hook_init: + { + \hook_gput_code:nnn { hyp/link/cite }{hyp/citeborder} + { + \keys_set:nn { hyp / setup } + { + linkbordercolor = hyp/color/citeborder + } + } + \cs_gset_eq:NN \@@_citebordercolor_hook_init: \prg_do_nothing: + } + % \end{macrocode} % \section{Checks} % The driver can not work properly if the pdfmanagement is not active, @@ -1416,11 +1489,27 @@ { \msg_error:nn { hyp}{ missing-resource-management } } % \end{macrocode} % Outlines/bookmarks require the bookmark package. -% TODO check pdfpagemode if booksmarks are suppressed. +% TODO check pdfpagemode if bookmarks are suppressed. +% TODO We overwrite the color key here for now, but this should be moved to bookmark +% % \begin{macrocode} +\AddToHook { package / after / bookmark} + { + \define@key{BKM}{color} + { + \__hyp_color_set:ne {__hyp/tmpa}{#1} + \color_export:nVN + {__hyp/tmpa} + \g__hyp_bordercolormodel_str + \BKM@color + } + } \legacy_if:nT { Hy@bookmarks } { - \AddToHook{begindocument/before}[hyperref/bookmark]{\RequirePackage{bookmark}} + \AddToHook{begindocument/before}[hyperref/bookmark] + { + \RequirePackage{bookmark} + } } \legacy_if:nT {Hy@draft} { @@ -2332,43 +2421,17 @@ % \section{Link decorations} % \subsection{Functions to export and select colors} % We support two input syntax: color expressions and model with values. -% \begin{function}{\@@_color_export:nnN} -% \begin{syntax} -% \cs{@@_color_export:nnN} \Arg{color} \Arg{export format} \meta{tlvar} -% \end{syntax} -% This exports a color as space separated numbers as needed in in |/C|. -% \Arg{color} should have either the format |[model]{value}| or be a color expression. -% For examples: |[rgb]{1,0,.5}| or |red!50!blue|. The export format is either -% |space-sep-cmyk| or |space-sep-rgb|. -% \end{function} -% \begin{macro}{\@@_color_export:nnN,\@@_color_export_aux:wnnN} -% Color keys need to parse color expressions. Two input types are supported: -% |color=[rgb]{1,0,.5}| and |color=red!50!blue|. The colors are exported -% to PDF syntax (space separated numbers). +% Exporting can be done by first setting the color with \cs{@@_color_set:nn} +% (if needed to a temporary color name) +% and then using \cs{color_export:nnN}. But we need a variant as the export +% format |space-sep-cmyk| or |space-sep-rgb| is stored in a tl. % \begin{macrocode} -\cs_new_protected:Npn \@@_color_export:nnN #1 #2 #3 - { - \tl_if_head_eq_charcode:nNTF {#1}[ %] - { - \@@_color_export_aux:wnnN #1 {#2} #3 - } - { - \color_export:nnN {#1} {#2} #3 - } - } - -\cs_new_protected:Npn \@@_color_export_aux:wnnN [#1] #2 #3 #4 - { - \color_export:nnnN {#1}{#2}{#3}#4 - } - -\cs_generate_variant:Nn \@@_color_export:nnN {xVN} +\cs_generate_variant:Nn \color_export:nnN {nVN} % \end{macrocode} -% \end{macro} % % \begin{function}{\@@_color_select:n} % \begin{syntax} -% \cs{@@_color_select:nN} \Arg{color} \\ +% \cs{@@_color_select:n} \Arg{color} \\ % \end{syntax} % These commands select a (text) color. % \Arg{color} should have either the format |[model]{value}| or be a color expression. @@ -2400,7 +2463,7 @@ % % \begin{function}{\@@_color_set:nn} % \begin{syntax} -% \cs{@@_color_set:nN} \Arg{ name } \Arg{color} \\ +% \cs{@@_color_set:nn} \Arg{ name } \Arg{color} \\ % \end{syntax} % These commands store the color in \Arg{name}. % \Arg{color} should have either the format |[model]{value}| or be a color expression. @@ -2535,7 +2598,11 @@ { C } } { - \@@_color_export:xVN {##1}\g_@@_bordercolormodel_str \l_@@_tmpa_tl + \@@_color_set:ne {hyp/color/#1border}{##1} + \color_export:nVN + {hyp/color/#1border} + \g_@@_bordercolormodel_str + \l_@@_tmpa_tl \pdfannot_dict_put:nnx {link/#2} { C } @@ -3763,7 +3830,8 @@ % \subsubsection{\enquote{info keys}} % \begin{hypkey}{pdfauthor,pdftitle,pdfcreator,pdfsubject,pdfproducer,pdfkeywords} % The keys store their value also in the metadate container, so that hyperxmp can -% use them. +% use them. Creator and Producer can't be removed with the pdfmanagement, +% but we allow to set an empty value. % \begin{macrocode} \cs_new_protected:Npn \@@_setup_info_key:nn #1 #2 { @@ -3773,7 +3841,22 @@ { \tl_if_blank:nTF {##1} { - \pdfmanagement_remove:nn {Info}{#2} + \str_case:nnF { #1 } + { + {creator} + { + \msg_info:nnn { hyp }{ empty-info-value } { pdfcreator } + \pdfmanagement_add:nnx {Info}{Creator}{()} + } + {producer} + { + \msg_info:nnn { hyp }{ empty-info-value } { pdfproducer } + \pdfmanagement_add:nnx {Info}{Producer}{()} + } + } + { + \pdfmanagement_remove:nn {Info}{#2} + } } { \@@_text_pdfstring_info:nN {##1}\l_@@_tmpa_str @@ -3838,7 +3921,7 @@ \pdfmanagement_remove:nn {Info}{#2} } { - \pdfmanagement_add:nnx {Info}{#2}{(\tl_to_str:n {##1})} + \pdfmanagement_add:nnx {Info}{#2}{(##1)} } \@@_store_metadata:nn {pdf#1}{##1} } @@ -3852,7 +3935,7 @@ \pdfmanagement_remove:nn {Info}{#2} } { - \pdfmanagement_add:nnx {Info}{#2}{(\tl_to_str:n {##1})} + \pdfmanagement_add:nnx {Info}{#2}{(##1)} } \exp_args:Nx \@@_store_metadata:nn {pdf\str_lowercase:n{#1}}{##1} } @@ -5312,7 +5395,7 @@ %,menubordercolor= %,runbordercolor= -\prop_const_from_keyval:Nn \c_@@_colorscheme_original_prop +\prop_const_from_keyval:cn { c_@@_colorscheme_primary-colors_prop } { linkcolor = [rgb]{1,0,0}, %red filecolor = [rgb]{0,1,1}, %cyan -- cgit v1.2.3