From 022e8257913bd76293b73438ca74275e27676d1f Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Thu, 12 Jan 2017 13:17:48 -0500 Subject: [PATCH] Add hyperref DOI support to mjo.bst (based on the urlbst tool). --- mjo.bst | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-) diff --git a/mjo.bst b/mjo.bst index e35241d..105ec77 100644 --- a/mjo.bst +++ b/mjo.bst @@ -66,6 +66,15 @@ ENTRY } {} { label } + +STRINGS { doiprefix doiurl } +INTEGERS { hrefform } +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} { #0 'before.all := @@ -482,13 +491,38 @@ FUNCTION {format.issn} if$ } +FUNCTION {make.href.null} +{ + pop$ +} + +FUNCTION {make.href.hypertex} +{ + "\special {html: }" * swap$ * + "\special {html:}" * +} + +FUNCTION {make.href.hyperref} +{ + "\href {" swap$ * "} {\path{" * swap$ * "}}" * +} + +FUNCTION {make.href} +{ hrefform #2 = + 'make.href.hyperref % hrefform = 2 + { hrefform #1 = + 'make.href.hypertex % hrefform = 1 + 'make.href.null % hrefform = 0 (or anything else) + if$ + } + if$ +} + FUNCTION {format.doi} { doi empty$ { "" } - { - new.block - "\doi{" doi * "}" * - } + { doiprefix doi * doiurl doi * make.href } if$ } FUNCTION {format.note} @@ -1451,6 +1485,7 @@ FUNCTION {begin.bib} write$ newline$ } EXECUTE {begin.bib} +EXECUTE {init.doi.variables} EXECUTE {init.state.consts} ITERATE {call.type$} FUNCTION {end.bib} -- 2.44.2