#format python # -*- coding: iso-8859-1 -*- """ MoinMoin processor for bibtex entries. Copyright (C) 2004 Alexandre Duret-Lutz This module is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This module will run bibtex blocks such as the following through bibtex2html. {{{#!bibtex @Book{ aho.74, author = {Alfred V. Aho and John E. Hopcroft and Jeffrey D. Ullman}, title = {The Design and Analysis of Computer Algorithms}, publisher = {Addison-Wesley}, year = {1974}, series = {Addison-Wesley Series in Computer Science and Information Processing} } }}} Several bibtex entries can be listed into the same block (and they can \cite each other). The 'comment' element can be used to display a comment below each entry. If your wiki contains a page named HlinsDatabase, then hlins will be run on the result of bibtex2html, using the contents of HlinsDatabase as input (make sure you write this page with the correct syntax). bibtex2html: http://www.lri.fr/~filliatr/bibtex2html/ hlins: http://www.lsv.ens-cachan.fr/~treinen/hlins/ Example of use of this processor: http://spot.lip6.fr/wiki/SpotReferences """ Dependencies = [] import os from MoinMoin.Page import Page class Parser: """ Send IRC logs in a table """ extensions = ['.bib'] def __init__(self, raw, request, **kw): self.raw = raw self.request = request self.form = request.form self._ = request.getText self.out = kw.get('out', request) def format(self, formatter): lines = self.raw.split('\n') del lines[0] out='' try: all = '\n'.join(lines).strip() (pin, pout) = os.popen2('bibtex2html --quiet -noheader -nofooter -nobibsource -nodoc -note comment --dl -i -s alpha') pin.write(all) pin.close() out = '\n'.join(pout.readlines()) pout.close() except IOError, (errno, strerror): pin.close() pout.close() # Use hlins if HlinsDatabase exists. page = Page(self.request, 'HlinsDatabase') pagefile, rev, exists = page.get_rev() if exists: try: (pin, pout) = os.popen2('hlins -q -db ' + os.path.abspath(pagefile), 1) pin.write(out) pin.close() out = '\n'.join(pout.readlines()) pout.close() except IOError, (errno, strerror): pin.close() pout.close() # To please Springer-Verlag. out = out.replace('Springer-Verlag', '©Springer-Verlag') self.request.write(formatter.rawHTML(out))