Пример #1
0
def html(bibfile):
    global str
    bib = BibTeX.BibTeX();
    bib.parseFile(bibfile);
                
    bib.resolveAbbrev();
    
    ## generate HTML
    append_nl( "<html>" );
    append_nl( "<head>" );
    append_nl( "  <title>Bibliography %s</title>" % ( bibfile,) );
    append_nl( """  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">""" );
    append_nl( "</head>" );
    append_nl( "<body>" );
    
    for be in bib:
        hb = HBibEntry(be);
        hb.display();
    
    if highlight:
        str = string.replace(str, highlight, """<font color="ff0000">%s</font>""" % highlight);
    
    append_nl( "<hr>" );
    append_nl( "<p>Generated by bib2html at %s.  bib2html by Peter Corke</p>" % time.asctime() );
    append_nl( "</body>" );
    append_nl( "</html>" );
    return str
Пример #2
0
def html(bibfile, keylist=None, rootdir=None):
    global str
    str = ''
    bib = BibTeX.BibTeX()
    bib.parseFile(bibfile)

    bib.resolveAbbrev()

    bibentries = []
    if keylist is not None:
        for key in keylist:
            try:
                bibentries.append(bib.__getitem__(key))
            except ValueError:
                pass
    else:
        bibentries = bib

    ## generate HTML
#    append_nl( "<html>" );
#    append_nl( "<head>" );
#    append_nl( "  <title>Bibliography %s</title>" % ( bibfile,) );
#    append_nl( """  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">""" );
#    append_nl( "</head>" );
#    append_nl( "<body>" );

    for be in bibentries:
        hb = HBibEntry(be, rootdir)
        hb.display()

    if highlight:
        str = string.replace(str, highlight,
                             """<font color="ff0000">%s</font>""" % highlight)

#    append_nl( "<hr>" );
#    append_nl( "<p>Generated by bib2html at %s.  bib2html by Peter Corke</p>" % time.asctime() );
#    append_nl( "</body>" );
#    append_nl( "</html>" );
    return str