]> gitweb.michael.orlitzky.com - mjotex.git/blobdiff - mjo.bst
Fix the bibliography DOI output when the hyperref package is not loaded.
[mjotex.git] / mjo.bst
diff --git a/mjo.bst b/mjo.bst
index e35241dcea13cbf150fe8a9bee1e6e8bff75d844..5a09e3d0467c59b8f407273a735e24271f2201c9 100644 (file)
--- a/mjo.bst
+++ b/mjo.bst
@@ -66,6 +66,13 @@ ENTRY
   }
   {}
   { 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
+}
 INTEGERS { output.state before.all mid.sentence after.sentence after.block }
 FUNCTION {init.state.consts}
 { #0 'before.all :=
@@ -482,13 +489,13 @@ FUNCTION {format.issn}
   if$
 }
 
+FUNCTION {make.href}
+{ "\href {" swap$ * "} {\path{" * swap$ * "}}" * }
+
 FUNCTION {format.doi}
 { doi empty$
     { "" }
-    {
-      new.block
-      "\doi{" doi * "}" *
-    }
+    { doiprefix doi * doiurl doi * make.href }
   if$
 }
 FUNCTION {format.note}
@@ -1449,8 +1456,13 @@ FUNCTION {begin.bib}
   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 {init.state.consts}
 ITERATE {call.type$}
 FUNCTION {end.bib}