summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/tugboat/tugboat.bst
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2023-01-17 03:01:49 +0000
committerNorbert Preining <norbert@preining.info>2023-01-17 03:01:49 +0000
commit3ee7e859ef35ea92821f3be74a8d758f5f653fbe (patch)
treef503263ff511ad2c0c03e8eb907091efa072baba /macros/latex/contrib/tugboat/tugboat.bst
parent6f9e1680085e7bb4d258f6f8116369d122e196e1 (diff)
CTAN sync 202301170301
Diffstat (limited to 'macros/latex/contrib/tugboat/tugboat.bst')
-rw-r--r--macros/latex/contrib/tugboat/tugboat.bst100
1 files changed, 85 insertions, 15 deletions
diff --git a/macros/latex/contrib/tugboat/tugboat.bst b/macros/latex/contrib/tugboat/tugboat.bst
index 1e28f2d8dd..a64d28fd17 100644
--- a/macros/latex/contrib/tugboat/tugboat.bst
+++ b/macros/latex/contrib/tugboat/tugboat.bst
@@ -1,4 +1,4 @@
-%%% $Id: tugboat.bst 410 2021-11-24 17:46:03Z karl $
+%%% $Id: tugboat.bst 457 2023-01-16 18:43:54Z karl $
%%% TUGboat changes are public domain.
%%%
%%% Modified for TUGboat from abbrvurl.bst:
@@ -13,8 +13,12 @@
%%% Output "Ph.D." rather than "PhD".
%%% Output "No." and "no." for number field.
%%% Omit spaces between author initials, like "A.B. Smith".
-%%% Set urlintro="" and onlinestring="".
+%%% Set urlintro="" and onlinestring="" to omit labels from output.
+%%% Use \url instead of \href, so we don't require hyperref.
%%% Always use https://doi.org/ for the doi url; omit "doi:" from output.
+%%% If doi or howpublished is present, omit url, since in practice
+%%% they are usually all the same thing. Should check if
+%%% howpublished is in fact a url, though.
%%% Truncate long author lists in format.names (max.names, trunc.num);
%%% omit "and" from author lists, per Oren P.
%%% Use \emph instead of \em so we get automatic italic corrections.
@@ -25,7 +29,6 @@
%%% "prebibitem" - material output before \bibitem, with newline appended
%%% (for example, section headings).
%%% "urlnewline" - force line break before url value;
-%%%
%%% --karl, originally created 24jul18.
%%%
%%% Modification of BibTeX style file /usr/local/texlive/2009/texmf-dist/bibtex/bst/base/abbrv.bst
@@ -434,6 +437,7 @@ FUNCTION {emphasize}
if$
}
+% emacs-page
%%% from trunc-auth.bst:
%%% There are two constants that allow for the truncation of a list of author
%%% (or editor) names -- max.names and trunc.num. And here's how they work:
@@ -871,7 +875,7 @@ FUNCTION {format.incoll.inproc.crossref}
" \cite{" * crossref * "}" *
}
-% urlbst...
+% emacs-page urlbst...
% Functions for making hypertext links.
% In all cases, the stack has (link-text href-url)
%
@@ -887,10 +891,12 @@ FUNCTION {make.href.hypertex}
swap$ * quote$ * "> }" * swap$ *
"\special {html:</a>}" *
}
-% make hyperref specials
+% make hyperref specials. Use \url rather than \href so that we don't
+% require loading hyperref (ltugboat provides \url in all cases),
+% thus we ignore one of the arguments.
FUNCTION {make.href.hyperref}
{
- "\href{" swap$ * "}{\path{" * swap$ * "}}" *
+ "\url{" swap$ * "}" * swap$ pop$
}
FUNCTION {make.href}
{ hrefform #2 =
@@ -906,7 +912,7 @@ FUNCTION {make.href}
% If inlinelinks is true, then format.url should be a no-op, since it's
% (a) redundant, and (b) could end up as a link-within-a-link.
% Likewise if the url is empty.
-% Likewise if doi is present, on the assumption that
+% Likewise if doi or howpublished is present, on the assumption that
% url most likely redundantly specifies the same info as those fields; this
% seems to be what people do in practice.
FUNCTION {format.url}
@@ -945,17 +951,78 @@ FUNCTION {format.eprint}
if$
}
-FUNCTION {format.doi}
-{ doi empty$
+FUNCTION {format.pubmed}
+{ pubmed empty$
{ "" }
- { doiprefix doi * doiurl doi * make.href }
+ { pubmedprefix pubmed * pubmedurl pubmed * make.href }
if$
}
-FUNCTION {format.pubmed}
-{ pubmed empty$
+% The original definition, left here for comparison.
+%FUNCTION {format.doi.orig}
+%{ doi empty$
+% { "" }
+% { doiprefix doi * doiurl doi * make.href }
+% if$
+%}
+
+% For the doi, sometimes people write doi = "10.x/y"
+% and sometimes they write doi ="https://doi.org/10.x/y".
+% So we check if the doi string starts with https://doi.org
+% (aka the doiurl variable), and only add it if needed.
+%
+% This code is from https://tex.stackexchange.com/questions/119237
+% (thank you, mafp).
+%
+% The "X Y contains" function checks if string Y is contained in X.
+% Although we only need to check if Y is at the beginning of X,
+% it makes no practical difference, so just use it as-is.
+%
+INTEGERS { strl }
+FUNCTION { string.length }
+{
+ #1 'strl :=
+ {duplicate$ duplicate$ #1 strl substring$ = not}
+ { strl #1 + 'strl :=}
+ while$
+ pop$ strl
+}
+
+INTEGERS {find.length search.start search.end done}
+STRINGS {find.string find.pattern}
+FUNCTION {contains}
+{
+ 'find.pattern :=
+ 'find.string :=
+ find.pattern string.length 'find.length :=
+ #1 'search.start :=
+ find.string string.length find.length - #2 + 'search.end :=
+ #0 'done :=
+ { search.start search.end < }
+ {
+ find.string search.start find.length substring$ find.pattern =
+ {
+ #1 'done :=
+ search.end 'search.start :=%% stop searching
+ }
+ { #1 search.start + 'search.start := }
+ if$
+ }
+ while$
+ done
+}
+
+FUNCTION {format.doi}
+{ doi empty$
{ "" }
- { pubmedprefix pubmed * pubmedurl pubmed * make.href }
+ { doiprefix doi *
+ doi doiurl contains
+ { "" }
+ { doiurl }
+ if$
+ doi *
+ make.href
+ }
if$
}
@@ -1035,6 +1102,7 @@ FUNCTION {fin.entry}
if$
}
+% emacs-page
% Webpage entry type.
% Title and url fields required;
% author, note, year, month, and lastchecked fields optional
@@ -1428,9 +1496,9 @@ FUNCTION {ctan}
new.block
format.title "title" output.check
format.version output
- format.date.direct "date" output.check
+ format.date.direct output
new.block
- note "note" output.check
+ note output
fin.entry
}
@@ -1505,6 +1573,8 @@ READ
EXECUTE {init.and.check.trunc.consts} % from trunc-auth.bst
+% emacs-page
+
FUNCTION {sortify}
{ purify$
"l" change.case$