bib2html.py: Add support for patents
[shutils.git] / bib2html.py
index a595f420b9679ec6efb1107ed4af8ec182a0ab64..b1ba7613da248acabb9b84d5ca51cae378f143ab 100755 (executable)
@@ -124,6 +124,16 @@ def format_details_book(entry):
     line = filter(lambda l: l != "", line)
     return [", ".join(line)]
 
+def format_details_patent(entry):
+    line = []
+    line.append(format_field(entry, 'number', pre='Pat. '))
+    line.append(format_field(entry, 'month', post=' ') + \
+            format_field(entry, 'year'))
+    line.append(format_field(entry, 'note'))
+
+    line = filter(lambda l: l != "", line)
+    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>')
@@ -145,6 +155,8 @@ def format_entry(entry):
         lines.extend(format_details_inproceedings(entry))
     elif entry.type=='book':
         lines.extend(format_details_book(entry))
+    elif entry.type=='patent':
+        lines.extend(format_details_patent(entry))
     elif entry.type in ['mastersthesis', 'phdthesis']:
         lines.extend(format_details_thesis(entry))
     else:
@@ -252,10 +264,8 @@ if __name__ == "__main__":
                 continue
 
             print("<div class=bibentry>")
-            print("<a class=bibentry_key id=" + key + ">[" + key + "]</a><br/>")
-
+            print("<a class=bibentry_key id={}>[{}]</a><br/><span class=bibentry_type>{}</span><br/>".format(key, key, entry.type))
             e = format_entry(entry)
             print(e)
 
             print("</div>\n")
-