10 print 'usage: %s [-s style] [-o <outfile>] BIBFILES...';
14 (options, files) = getopt.getopt(sys.argv[1:], 's:o:', [])
19 if o == '-h' or o == '--help':
22 elif o == '-s' or o == '--style':
24 elif o == '-o' or o == '--output':
27 raise 'unknown opt ', o
30 if style not in ['alpha','index','long','longp','long-pario','short','short-pario','split']:
31 sys.stderr.write ("Unknown style \`%s'\n" % style)
33 tempfile = tempfile.mktemp ('bib2html')
40 def strip_extension (f, ext):
41 (p, e) = os.path.splitext (f)
48 nf.append (strip_extension(f, '.bib'))
50 files = string.join (nf,',')
52 open(tempfile + '.aux', 'w').write (r'''
55 \bibstyle{html-%(style)s}
56 \bibdata{%(files)s}''' % vars ())
58 cmd = "bibtex %s" % tempfile;
60 sys.stdout.write ("Invoking `%s'\n" % 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)