summaryrefslogtreecommitdiff
path: root/biblio/bibtex/contrib/urlbst/alphaurl.bst
diff options
context:
space:
mode:
Diffstat (limited to 'biblio/bibtex/contrib/urlbst/alphaurl.bst')
-rw-r--r--biblio/bibtex/contrib/urlbst/alphaurl.bst53
1 files changed, 37 insertions, 16 deletions
diff --git a/biblio/bibtex/contrib/urlbst/alphaurl.bst b/biblio/bibtex/contrib/urlbst/alphaurl.bst
index e4fc0af4eb..c72e293d4f 100644
--- a/biblio/bibtex/contrib/urlbst/alphaurl.bst
+++ b/biblio/bibtex/contrib/urlbst/alphaurl.bst
@@ -1,7 +1,7 @@
%%% Modification of BibTeX style file /usr/local/texlive/2022/texmf-dist/bibtex/bst/base/alpha.bst
-%%% ... by urlbst, version 0.9 (marked with "% urlbst")
+%%% ... by urlbst, version 0.9.1 (marked with "% urlbst")
%%% See <https://purl.org/nxg/dist/urlbst> and repository <https://heptapod.host/nxg/urlbst>
-%%% Modifications Copyright 2002-03, 2005-12, 2014, 2019, 2022, Norman Gray,
+%%% Modifications Copyright 2002–23, Norman Gray,
%%% and distributed under the terms of the LPPL; see README for discussion.
%%%
%%% Added webpage entry type, and url and lastchecked fields.
@@ -69,23 +69,23 @@ FUNCTION {init.urlbst.variables}
% The first set allow you to enable or disable certain functionality.
#1 'addeprints := % 0=no eprints; 1=include eprints
- #2 'hrefform := % 0=no crossrefs; 1=hypertex hrefs; 2=hyperref hrefs
#0 'inlinelinks := % 0=URLs explicit; 1=URLs attached to titles
+ #1 'addpubmed := % 0=no PUBMED resolver; 1=include it
#1 'adddoi := % 0=no DOI resolver; 1=include it
+ #2 'hrefform := % 0=no crossrefs; 1=hypertex hrefs; 2=hyperref hrefs
#0 'doiform := % 0=with href; 1=with \doi{}
- #1 'addpubmed := % 0=no PUBMED resolver; 1=include it
% String constants, which you _might_ want to tweak.
- "cited " 'citedstring := % label in "lastchecked" remark
- "URL: " 'urlintro := % text prefix before URL
- "[link]" 'linktextstring := % anonymous link text
+ "doi:" 'doiprefix := % printed text to introduce DOI
"arXiv:" 'eprintprefix := % text prefix printed before eprint ref
- "http://www.ncbi.nlm.nih.gov/pubmed/" 'pubmedurl := % prefix to make URL from PUBMED
"PMID:" 'pubmedprefix := % text prefix printed before PUBMED ref
- "online" 'onlinestring := % label that a resource is online
+ "[link]" 'linktextstring := % anonymous link text
+ "cited " 'citedstring := % label in "lastchecked" remark
+ "http://www.ncbi.nlm.nih.gov/pubmed/" 'pubmedurl := % prefix to make URL from PUBMED
"https://arxiv.org/abs/" 'eprinturl := % prefix to make URL from eprint ref
- "doi:" 'doiprefix := % printed text to introduce DOI
+ "online" 'onlinestring := % label that a resource is online
"https://doi.org/" 'doiurl := % prefix to make URL from DOI
+ "URL: " 'urlintro := % text prefix before URL
% The following are internal state variables, not configuration constants,
% so they shouldn't be fiddled with.
@@ -138,6 +138,19 @@ FUNCTION {output.nonnull.original}
}
% urlbst...
+% Minimal DOI parsing.
+% Given a DOI on the stack, check whether it starts with 'doiurl' or not.
+% In either case, leave on the stack first a DOI with, and then a DOI without, the URL prefix.
+FUNCTION {parse.doi}
+{
+ #1 doiurl text.length$ substring$
+ doiurl =
+ { doi
+ doi doiurl text.length$ #1 + #999 substring$ }
+ { doiurl doi *
+ doi }
+ if$
+}
% The following three functions are for handling inlinelink. They wrap
% a block of text which is potentially output with write$ by multiple
% other functions, so we don't know the content a priori.
@@ -164,7 +177,12 @@ FUNCTION {possibly.setup.inlinelink}
if$ }
{ pubmedurl pubmed * }
if$ }
- { doiurl doi * }
+% { doiurl doi * }
+ { doi empty$
+ { "XXX" }
+ { doi parse.doi pop$ }
+ if$
+ }
if$
% an appropriately-formatted URL is now on the stack
hrefform #1 = % hypertex
@@ -763,9 +781,11 @@ FUNCTION {format.eprint}
FUNCTION {format.doi}
{ doi empty$
{ "" }
- { doiform #1 =
- { "\doi{" doi * "}" * }
- { doiprefix doi * doiurl doi * make.href }
+ { doi parse.doi % leaves "https://doi.org/DOI" DOI on the stack
+ 's := 't :=
+ doiform #1 =
+ { "\doi{" s * "}" * }
+ { doiprefix s * t make.href }
if$
}
if$
@@ -799,10 +819,11 @@ FUNCTION {output.web.refs}
inlinelinks
'skip$ % links were inline -- don't repeat them
{ % If the generated DOI will be the same as the URL,
- % then don't print the URL (thanks to Joseph Wright for this code,
+ % then don't print the URL (thanks to Joseph Wright
+ % for (the original version of) this code,
% at http://tex.stackexchange.com/questions/5660)
adddoi
- doiurl doi empty$ { "X" } { doi } if$ * % DOI URL to be generated
+ doi empty$ { "X" } { doi parse.doi pop$ } if$ % DOI URL to be generated
url empty$ { "Y" } { url } if$ % the URL, or "Y" if empty
= % are the strings equal?
and