The last attempt at adding hyperref support for DOIs worked, but it
broke things when the hyperref package isn't loaded. This commit fixes
it by conditionally defining a no-op \href in the absense of the
hyperref package.
Now that I understand what's going on a little bit better, I was also
able to eliminate some of the urlbst boilerplate.
{ label }
STRINGS { doiprefix doiurl }
{ label }
STRINGS { doiprefix doiurl }
FUNCTION {init.doi.variables}
{
"http://dx.doi.org/" 'doiurl := % prefix to make URL from DOI
"doi:" 'doiprefix := % text prefix printed before DOI ref
FUNCTION {init.doi.variables}
{
"http://dx.doi.org/" 'doiurl := % prefix to make URL from DOI
"doi:" 'doiprefix := % text prefix printed before DOI ref
- #2 'hrefform := % 0=no crossrefs; 1=hypertex xrefs; 2=hyperref refs
}
INTEGERS { output.state before.all mid.sentence after.sentence after.block }
FUNCTION {init.state.consts}
}
INTEGERS { output.state before.all mid.sentence after.sentence after.block }
FUNCTION {init.state.consts}
-FUNCTION {make.href.null}
-{
- pop$
-}
-
-FUNCTION {make.href.hypertex}
-{
- "\special {html:<a href=" quote$ *
- swap$ * quote$ * "> }" * swap$ *
- "\special {html:</a>}" *
-}
-
-FUNCTION {make.href.hyperref}
-{
- "\href {" swap$ * "} {\path{" * swap$ * "}}" *
-}
-
-{ hrefform #2 =
- 'make.href.hyperref % hrefform = 2
- { hrefform #1 =
- 'make.href.hypertex % hrefform = 1
- 'make.href.null % hrefform = 0 (or anything else)
- if$
- }
- if$
-}
+{ "\href {" swap$ * "} {\path{" * swap$ * "}}" * }
FUNCTION {format.doi}
{ doi empty$
FUNCTION {format.doi}
{ doi empty$
write$ newline$
" \providecommand{\doi}{doi:\discretionary{}{}{}\begingroup \urlstyle{rm}\Url}\fi"
write$ newline$
write$ newline$
" \providecommand{\doi}{doi:\discretionary{}{}{}\begingroup \urlstyle{rm}\Url}\fi"
write$ newline$
+ "\expandafter\ifx\csname href\endcsname\relax"
+ write$ newline$
+ " \def\href#1#2{#2} \def\path#1{#1}\fi"
+ write$ newline$
}
EXECUTE {begin.bib}
EXECUTE {init.doi.variables}
}
EXECUTE {begin.bib}
EXECUTE {init.doi.variables}