9 print 'usage: %s [-s style] [-o <outfile>] BIBFILES...'
11 (options, files) = getopt.getopt (sys.argv[1:], 's:o:', [])
17 if o == '-h' or o == '--help':
20 elif o == '-s' or o == '--style':
22 elif o == '-o' or o == '--output':
25 raise Exception ('unknown option: %s' % o)
28 if style not in ['alpha','index','long','longp','long-pario','short','short-pario','split']:
29 sys.stderr.write ("Unknown style \`%s'\n" % style)
31 tempfile = tempfile.mktemp ('bib2html')
38 def strip_extension (f, ext):
39 (p, e) = os.path.splitext (f)
46 nf.append (strip_extension (f, '.bib'))
50 open (tempfile + '.aux', 'w').write (r'''
53 \bibstyle{html-%(style)s}
54 \bibdata{%(files)s}''' % vars ())
56 cmd = "bibtex %s" % tempfile
58 sys.stdout.write ("Invoking `%s'\n" % cmd)
59 stat = os.system (cmd)
64 #TODO: do tex -> html on output
66 bbl = open (tempfile + '.bbl').read ()
68 open (output, 'w').write (bbl)
71 def cleanup (tempfile):
72 for a in ['aux','bbl', 'blg']:
73 os.unlink (tempfile + '.' + a)