-
Notifications
You must be signed in to change notification settings - Fork 9
/
mla.bbx
147 lines (144 loc) · 6.98 KB
/
mla.bbx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
% These sourcemap declarations allow for .bib file oddities. Additionally, to comport with MLA expectations, they modify strings in publisher fields, drop unneeded parts of URLs, and look for patterns in a URL field to fill in missing eprint fields. If the choices here seem to do too much, use "style=mla-strict", which makes fewer accommodations and more exactly prints entries as they're defined in a given bibtex file.
\ProvidesFile{mla.bbx}[2022/02/22 v2.1a biblatex bibliography style]
\RequireBibliographyStyle{mla-strict}
\DeclareStyleSourcemap{
\maps[datatype=bibtex]{
\map[overwrite=true]{% Convert non-integer year field to addendum field
\step[fieldsource=year, match=\regexp{[a-zA-Z]}, final]
\step[fieldsource=year, match=\regexp{(.+)}, final]
\step[fieldset=addendum, fieldvalue=\regexp{$1}]
\step[fieldset=year, null]
}
\map{% Convert unpublished booktitle to title, with entrysubtype "book"
\pertype{unpublished}
\step[notfield=title, final]
\step[fieldsource=booktitle, match=\regexp{(.+)}, final]
\step[fieldset=title, fieldvalue=\regexp{$1}, final]
\step[fieldset=booktitle, null]
\step[fieldset=entrysubtype, fieldvalue={book}]
}
\map{% Add italics to app names for videos, movies, music, audio
\pertype{video}
\step[fieldsource=addendum, notmatch=\regexp{mkbibemph}, final]
\step[fieldsource=addendum, match=\regexp{(.+)\s+app$}, replace={\\mkbibemph\{$1\} app}]
}
\map{% Add italics to app names for videos, movies, music, audio
\pertype{movie}
\step[fieldsource=addendum, notmatch=\regexp{mkbibemph}, final]
\step[fieldsource=addendum, match=\regexp{(.+)\s+app$}, replace={\\mkbibemph\{$1\} app}]
}
\map{% Add italics to app names for videos, movies, music, audio
\pertype{music}
\step[fieldsource=addendum, notmatch=\regexp{mkbibemph}, final]
\step[fieldsource=addendum, match=\regexp{(.+)\s+app$}, replace={\\mkbibemph\{$1\} app}]
}
\map{% Add italics to app names for videos, movies, music, audio
\pertype{audio}
\step[fieldsource=addendum, notmatch=\regexp{mkbibemph}, final]
\step[fieldsource=addendum, match=\regexp{(.+)\s+app$}, replace={\\mkbibemph\{$1\} app}]
}
\map{% Add italics to app names for software
\pertype{software}
\step[fieldsource=maintitle, notmatch=\regexp{mkbibemph}, final]
\step[fieldsource=maintitle, match=\regexp{(.+)\s+app$}, replace={$1 \\mkbibemph\{app\}}]
}
\map{% Accommodate music albums defined simply
\pertype{music}
\step[notfield=title, final]
\step[fieldsource=booktitle, match=\regexp{(.+)}, final]
\step[fieldset=title, fieldvalue=\regexp{$1}, final]
\step[fieldset=booktitle, null]
\step[fieldset=entrysubtype, fieldvalue={album}]
}
\map{% Fill in missing publisher for US patents
\pertype{patent}
\step[notfield=publisher, final]
\step[fieldsource=type, match=\regexp{patentus}, final]
\step[fieldset=publisher, fieldvalue={United States Patent and Trademark Office}]
}
\map[overwrite=true]{% force consistent abbreviations for editions
\step[fieldsource=edition, match={edition}, replace={ed.}]
}
\map[overwrite=true]{% drop unnecessary elements of company names ("and" suggests list)
\step[fieldsource=publisher, match={and Company}, replace={}]
\step[fieldsource=publisher, match={and Co.}, replace={}]
}
\map{% abbreviate and drop unneeded parts of publisher names
\step[fieldsource=publisher, match={University Press}, replace={UP}]
\step[fieldsource=publisher, match={University}, replace={U}]
\step[fieldsource=publisher, match=\regexp{Press\b}, replace={P}]
\step[fieldsource=publisher, match=\regexp{Corporation|Corp.|Incorporated|Inc.|Limited|Ltd.}, replace={}]
% \step[fieldsource=url, match=\regexp{http(s)?://}, replace={}]
}
\map{% abbreviate and drop unneeded parts of institutions
\step[fieldsource=institution, match={University}, replace={U}]
\step[fieldsource=school, match={University}, replace={U}]
}
\map{% JSTOR url to eprint
\step[fieldsource=url, match={jstor.org}, final]
\step[fieldset=eprint, fieldvalue={JSTOR}]
% \step[fieldset=urldate, null]
}
\map{% Project Muse url to eprint
\step[fieldsource=url, match={muse.jhu.edu}, final]
\step[fieldset=eprint, fieldvalue={Project Muse}]
% \step[fieldset=urldate, null]
}
\map{% Adelaide eBooks url to eprint
\step[fieldsource=url, match={ebooks.adelaide.edu.au}, final]
\step[fieldset=eprint, origfieldval]
\step[fieldset=eprinttype, fieldvalue={adelaide}]
% \step[fieldset=urldate, null]
}
\map{% Google Books url to eprint
\step[fieldsource=url, match={books.google}, final]
\step[fieldset=eprint, fieldvalue={Google Books}]
% \step[fieldset=urldate, null]
}
\map{% EBSCO - Academic Search Complete url to eprint
\step[fieldsource=url, match={db=a9h}, final]
\step[fieldset=eprint, fieldvalue={Academic Search Complete}]
% \step[fieldset=urldate, null]
}
\map{% EBSCO - LexisNexis Academic url to eprint
\step[fieldsource=url, match={db=fdcaae48}, final]
\step[fieldset=eprint, fieldvalue={LexisNexis Academic}]
% \step[fieldset=urldate, null]
}
\map{% EBSCO - MLA Database url to eprint
\step[fieldsource=url, match={db=mzh}, final]
\step[fieldset=eprint, fieldvalue={MLA International Bibliography}]
% \step[fieldset=urldate, null]
}
\map{% USPTO url to eprint
\step[fieldsource=url, match={patft.uspto.gov}, final]
\step[fieldset=eprint, fieldvalue={USPTO Patent Full-Text and Image Database}]
}
\map{% DOI url to doi
\step[fieldsource=url, match=\regexp{dx.doi.org/(.+)}, fieldtarget=doi]
\step[fieldsource=doi, match=\regexp{http(s)?://dx.doi.org/(.+)}, replace=\regexp{$1}]
\step[fieldsource=doi, match=\regexp{dx.doi.org/(.+)}, replace=\regexp{$1}]
}
% \map{% doi to url when eprinttype set and url empty
% \step[notfield=url, final]
% \step[field=eprinttype, final]
% \step[field=doi, final]
% \step[fieldsource=doi, fieldtarget=url]
% \step[fieldsource=url, match=\regexp{(.+)}, replace=\regexp{https://doi.org/$1}]
% \step[fieldset=doi, null]
% }
\map{ % remove isbns from Works Cited
\step[fieldsource=isbn, final]
\step[fieldset=isbn, null]
}
\map{ % remove url + urldate field from all entries that have a doi field
\step[fieldsource=doi, final]
\step[fieldset=url, null]
\step[fieldset=urldate, null]
}
\map[overwrite]{ % clean url + urldate field from all entries that have a doi field
\step[fieldsource=url, match=\regexp{http(s)?://}, replace={}]
}
}
}
\endinput