Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional loading of hyperref #5

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions doi.sty
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,21 @@
%% https://doi.org/ URL but may be set to old http://dx.doi.org/
%%

%% Declare two complementary boolean options [no]hyperref that determine
%% if hyperref should be loaded in this package.
\newif\if@doihyperref\@doihyperreftrue
\DeclareOption{hyperref}{\@doihyperreftrue}
\DeclareOption{nohyperref}{\@doihyperreffalse}

%% Execute default options and process the options passed to the package.
\ExecuteOptions{hyperref} % default is the old behaviour, to load hyperref
\ProcessOptions\relax

%% We need hyperref, but you probably want to load hyperref
%% beforehand, or set some options later on.
\RequirePackage{hyperref}
\if@doihyperref
\RequirePackage{hyperref}
\fi

%% To change the default prefix, redefine this command within your own code.
%% It takes no argument, which is different from the doipubmed package.
Expand Down Expand Up @@ -88,7 +99,7 @@
\edef\_{_}%
\edef\textless{\@percentchar3C}% instead of {\string<} for Apple
\edef\textgreater{\@percentchar3E}% instead of {\sting>} for Apple
\edef\x{\toks2={\noexpand\href{\doiurl#1}}}%
\edef\x{\toks2={\ifdefined\href\noexpand\href{\doiurl#1}\fi}}%
\x
\edef\x{\endgroup\doitext\the\toks2 \the\toks0}%
\x
Expand Down