From aa2aea0e796d6f6b495a23c0fc4d5c66967948ba Mon Sep 17 00:00:00 2001 From: Fred Drake Date: Wed, 27 Jan 1999 17:37:36 +0000 Subject: \py@linkToName: New macro to consolidate support for most internal hyperlinking in the PDF version. This also allows many of the macros that do this stuff to be a good bit more readable. Takes the target name and link content as parameters. Use \py@linkToName for all internal links. --- Doc/texinputs/python.sty | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/Doc/texinputs/python.sty b/Doc/texinputs/python.sty index 8f95764..3ed1255 100644 --- a/Doc/texinputs/python.sty +++ b/Doc/texinputs/python.sty @@ -37,15 +37,21 @@ % active links. Some work, some don't. % \let\py@OldContentsline=\contentsline + % + % Macro that takes two args: the name to link to and the content of + % the link. This takes care of the PDF magic, getting the colors + % the same for each link, and avoids having lots of garbage all over + % this style file. + \newcommand{\py@linkToName}[2]{% + \pdfannotlink attr{/Border [0 0 0]} goto name{#1}% + \py@LinkColor#2\py@NormalColor% + \pdfendlink% + } % Compute the padded page number separately since we end up with a pair of % \relax tokens; this gets the right string computed and works. \renewcommand{\contentsline}[3]{% \def\my@pageno{\py@targetno{#3}}% - \py@OldContentsline{#1}{% - \pdfannotlink attr{/Border [0 0 0]} goto name{page\my@pageno}% - \py@LinkColor#2\py@NormalColor% - \pdfendlink% - }{#3}% + \py@OldContentsline{#1}{\py@linkToName{page\my@pageno}{#2}}{#3}% } \AtEndDocument{ \InputIfFileExists{\jobname.bkm}{\pdfcatalog{/PageMode /UseOutlines}}{} @@ -232,12 +238,10 @@ % name, at least if we're building PDF: \@ifundefined{pdfannotlink}{% \newcommand{\refmodule}[2][\py@modulebadkey]{\module{#2}} -}{\newcommand{\refmodule}[2][\py@modulebadkey]{% +}{% + \newcommand{\refmodule}[2][\py@modulebadkey]{% \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi% - {\pdfannotlink attr{/Border [0 0 0]} goto name{label-module-\py@modulekey}% - \py@LinkColor\module{#2}\py@NormalColor% - \pdfendlink% - }% + \py@linkToName{label-module-\py@modulekey}{\module{#2}}% } } @@ -362,10 +366,9 @@ \@ifundefined{pdfoutput}{ \newcommand{\py@ModSynopsisSummary}[4]{\bfcode{#2} & #4\\} }{ - \newcommand{\py@ModSynopsisSummary}[4]{ - {\pdfannotlink attr{/Border [0 0 0]} goto name{label-module-#1} - \py@LinkColor \bfcode{#2} \py@NormalColor - \pdfendlink}& #4\\} + \newcommand{\py@ModSynopsisSummary}[4]{% + \py@linkToName{label-module-#1}{\bfcode{#2}} & #4\\ + } } \newenvironment{synopsistable}{ % key, name, type, synopsis @@ -807,10 +810,7 @@ \par% \ifx\py@modulebadkey#1\def\py@modulekey{#2}\else\def\py@modulekey{#1}\fi% \ref{module-\py@modulekey}:\quad % - {\pdfannotlink attr{/Border [0 0 0]} goto name{label-module-\py@modulekey}% - \py@LinkColor Module \module{#2} \py@NormalColor% - \pdfendlink% - }% + \py@linkToName{label-module-\py@modulekey}{ Module \module{#2} } \quad (#3)% } } -- cgit v0.12