X-Git-Url: http://git.sthu.org/?a=blobdiff_plain;ds=sidebyside;f=bib2html.py;h=111d1085db02106616cfcf92011846fab8c2f0f6;hb=ef9c73420677afec147aa259ff0439ac228b709d;hp=28abd58ecbfebd88bfcdc56099a1a33619139f13;hpb=3ac17777f987e1c78ea411f149e450015da3dfc4;p=shutils.git
diff --git a/bib2html.py b/bib2html.py
index 28abd58..111d108 100755
--- a/bib2html.py
+++ b/bib2html.py
@@ -42,7 +42,8 @@ def format_field_span(type, value):
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):
@@ -95,12 +96,13 @@ def format_details_book(entry):
return [", ".join(line)]
def format_links(entry):
+ doi = format_field(entry, 'doi', pre='[DOI]')
webpdf = format_field(entry, 'webpdf', pre='[PDF]')
weblink = format_field(entry, 'weblink', pre='[link]')
webslides = format_field(entry, 'webslides', pre='[slides]')
weberrata = format_field(entry, 'weberrata', pre='[errata]')
- return " ".join([webpdf, weblink, webslides, weberrata])
+ return " ".join([doi, webpdf, weblink, webslides, weberrata])
def format_entry(entry):
lines = []
@@ -131,11 +133,16 @@ def entryCompareDate(p1, p2):
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))