def format_field(bibentry, field, pre='', post=''):
if field in bibentry.fields:
- return format_field_span(field, pre + bibentry.fields[field] + post)
+ if bibentry.fields[field] != "":
+ return format_field_span(field, pre + bibentry.fields[field] + post)
return ""
def format_author(a):
return [", ".join(line)]
def format_links(entry):
+ doi = format_field(entry, 'doi', pre='<a href="http://dx.doi.org/', post='">[DOI]</a>')
webpdf = format_field(entry, 'webpdf', pre='<a href="', post='">[PDF]</a>')
weblink = format_field(entry, 'weblink', pre='<a href="', post='">[link]</a>')
webslides = format_field(entry, 'webslides', pre='<a href="', post='">[slides]</a>')
weberrata = format_field(entry, 'weberrata', pre='<a href="',
post='">[errata]</a>')
- return " ".join([webpdf, weblink, webslides, weberrata])
+ return " ".join([doi, webpdf, weblink, webslides, weberrata])
def format_entry(entry):
lines = []
def toStr(e):
- month = { 'jan' : '01', 'feb' : '02', 'mar' : '03', \
+ month2num = { 'jan' : '01', 'feb' : '02', 'mar' : '03', \
'apr' : '04', 'may' : '05', 'jun' : '06', \
'jul' : '07', 'aug' : '08', 'sep' : '09', \
'oct' : '10', 'nov' : '11', 'dec' : '12'}
- return e.fields['year'] + "-" + month[e.fields['month'].lower()[0:3]]
+ month = e.fields['month'].lower()[0:3]
+ if month in month2num:
+ month = month2num[month]
+ else:
+ month = ""
+ return e.fields['year'] + "-" + month
return cmp(toStr(e1), toStr(e2))