summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/biblatex-contrib/biblatex-mla/mla.bbx
blob: 2ee9431d5768804711a4bb3b59b0fe8245c3279f (plain)
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
% 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}[2021/06/07 v2.0 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{% 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{% 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{ % 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]
          }
    }      
}

\endinput