aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xwriteHTML.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/writeHTML.py b/writeHTML.py
index d03d76e..19a7c14 100755
--- a/writeHTML.py
+++ b/writeHTML.py
@@ -6,6 +6,7 @@
import sys
import re
import os
+import json
assert sys.version_info[:3] >= (2,2,0)
os.umask(022)
@@ -108,6 +109,14 @@ def writeHTML(f, sections, sectionType, fieldName, choices,
base_url=root)
print >>f, footer%fields
+def jsonDumper(obj):
+ if isinstance(obj, BibTeX.BibTeXEntry):
+ e = obj.entries.copy()
+ e['key'] = obj.key
+ return e
+ else:
+ raise TypeError("Do not know how to serialize %s"%(obj.__class,))
+
def writePageSet(config, bib, tag):
if tag:
bib_entries = [ b for b in bib.entries
@@ -218,6 +227,10 @@ def writePageSet(config, bib, tag):
print >>f, footer
f.close()
+ f = open(os.path.join(outdir,"bibtex.json"), 'w')
+ json.dump(entries, f, default=jsonDumper)
+ f.close()
+
if __name__ == '__main__':
if len(sys.argv) == 2: