gravatar
kpeter (Peter Kovacs)
kpeter@inf.elte.hu
Improve bib2dox.py using \section for entiries (#184)
0 1 0
default
1 file changed with 11 insertions and 11 deletions:
↑ Collapse diff ↑
Show white space 12 line context
... ...
@@ -83,12 +83,16 @@
83 83

	
84 84
field_rex = re.compile('\s*(\w*)\s*=\s*(.*)')
85 85
data_rex = re.compile('\s*(\w*)\s*=\s*([^,]*),?')
86 86

	
87 87
url_rex = re.compile('\\\url\{([^}]*)\}')
88 88

	
89
#
90
# styles for html formatting
91
#
92
divstyle = 'margin-top: -4ex; margin-left: 8em;'
89 93

	
90 94
#
91 95
# return the string parameter without braces
92 96
#
93 97
def transformurls(str):
94 98
    return url_rex.sub(r'<a href="\1">\1</a>', str)
... ...
@@ -281,13 +285,13 @@
281 285
        if pubtype_rex.match(line):
282 286
        # want @<alphanumeric chars><spaces>{<spaces><any chars>,
283 287
            entrycont = {}
284 288
            entry = []
285 289
            entrytype = pubtype_rex.sub('\g<1>',line)
286 290
            entrytype = string.lower(entrytype)
287
            # entryid   = pubtype_rex.sub('\g<2>', line)
291
            entryid   = pubtype_rex.sub('\g<2>', line)
288 292

	
289 293
        # end entry if just a }
290 294
        elif endtype_rex.match(line):
291 295
            # generate doxygen code for the entry
292 296

	
293 297
            # enty type related formattings
... ...
@@ -376,12 +380,13 @@
376 380
                sortkey += entrycont['title']
377 381
            if entrycont.has_key('key'):
378 382
                sortkey = entrycont['key'] + sortkey
379 383
                bibkey = entrycont['key']
380 384
            entry.insert(0, sortkey)
381 385
            entry.insert(1, bibkey)
386
            entry.insert(2, entryid)
382 387
           
383 388
            # add the entry to the file contents
384 389
            filecont.append(entry)
385 390

	
386 391
        else:
387 392
            # field, publication info
... ...
@@ -436,26 +441,25 @@
436 441
        counttable[bibkey] = 0
437 442
    
438 443
    # generate output
439 444
    for entry in filecont:
440 445
        # generate output key form the bibtex key
441 446
        bibkey = entry[1]
447
        entryid = entry[2]
442 448
        if keytable[bibkey] == 1:
443 449
            outkey = bibkey
444 450
        else:
445 451
            outkey = bibkey + chr(97 + counttable[bibkey])
446 452
        counttable[bibkey] += 1
447 453
        
448 454
        # append the entry code to the output
449
        file.append('<tr valign="top">\n' + \
450
                    '<td>[' + outkey + ']</td>')
451
        file.append('<td>')
452
        file.append('\\anchor ' + outkey)
453
        for line in entry[2:]:
455
        file.append('\\section ' + entryid + ' [' + outkey + ']')
456
        file.append('<div style="' + divstyle + '">')
457
        for line in entry[3:]:
454 458
            file.append(line)
455
        file.append('</td>\n</tr>')
459
        file.append('</div>')
456 460
        file.append('')
457 461

	
458 462
    return file
459 463

	
460 464

	
461 465
#
... ...
@@ -777,18 +781,14 @@
777 781
        print 'Could not open file:', filepath
778 782
    washeddata = bibtexwasher(filecont_source)
779 783
    outdata = bibtexdecoder(washeddata)
780 784
    print '/**'
781 785
    print '\page references References'
782 786
    print
783
    print '<table border="0" cellspacing="5px" width="100%">'
784
    print
785 787
    for line in outdata:
786 788
        print line
787
    print '</table>'
788
    print
789 789
    print '*/'
790 790

	
791 791

	
792 792
# main program
793 793

	
794 794
def main():
0 comments (0 inline)