Differences between revisions 1 and 2
Revision 1 as of 2004-12-08 18:41:36
Size: 3051
Editor: ID00243
Comment:
Revision 2 as of 2008-10-03 20:20:36
Size: 3051
Editor: localhost
Comment: converted to 1.6 markup
No differences found!
   1 """
   2 MoinMoin processor for bibtex entries.
   3 
   4 Copyright (C) 2004  Alexandre Duret-Lutz <adl@gnu.org>
   5 
   6 This module is free software; you can redistribute it and/or modify
   7 it under the terms of the GNU General Public License as published by
   8 the Free Software Foundation; either version 2, or (at your option)
   9 any later version.
  10 
  11 
  12   This module will run bibtex blocks such as the following through
  13   bibtex2html.
  14 
  15   {{{#!bibtex
  16   @Book{            aho.74,
  17     author        = {Alfred V. Aho and John E. Hopcroft and Jeffrey D. Ullman},
  18     title         = {The Design and Analysis of Computer Algorithms},
  19     publisher     = {Addison-Wesley},
  20     year          = {1974},
  21     series        = {Addison-Wesley Series in Computer Science and Information
  22                     Processing}
  23   }
  24   }}}
  25 
  26   Several bibtex entries can be listed into the same block (and they can
  27   \cite each other).  The 'comment' element can be used to display a comment
  28   below each entry.
  29 
  30   If your wiki contains a page named HlinsDatabase, then hlins will be
  31   run on the result of bibtex2html, using the contents of HlinsDatabase
  32   as input (make sure you write this page with the correct syntax).
  33 
  34   bibtex2html: http://www.lri.fr/~filliatr/bibtex2html/
  35   hlins:       http://www.lsv.ens-cachan.fr/~treinen/hlins/
  36 
  37   Example of use of this processor:
  38                http://spot.lip6.fr/wiki/SpotReferences
  39 
  40 """
  41 
  42 Dependencies = []
  43 
  44 import os
  45 from MoinMoin.Page import Page
  46 
  47 class Parser:
  48     """
  49         Send IRC logs in a table
  50     """
  51     extensions = ['.bib']
  52 
  53     def __init__(self, raw, request, **kw):
  54         self.raw = raw
  55         self.request = request
  56         self.form = request.form
  57         self._ = request.getText
  58         self.out = kw.get('out', request)
  59 
  60     def format(self, formatter):
  61 
  62         lines = self.raw.split('\n')
  63         del lines[0]
  64         out=''
  65 
  66         try:
  67             all = '\n'.join(lines).strip()
  68             (pin, pout) = os.popen2('bibtex2html --quiet -noheader -nofooter -nobibsource -nodoc -note comment --dl -i -s alpha')
  69             pin.write(all)
  70             pin.close()
  71             out = '\n'.join(pout.readlines())
  72             pout.close()
  73         except IOError, (errno, strerror):
  74             pin.close()
  75             pout.close()
  76 
  77         # Use hlins if HlinsDatabase exists.
  78         page = Page(self.request, 'HlinsDatabase')
  79         pagefile, rev, exists = page.get_rev()
  80         if exists:
  81 	    try:
  82                (pin, pout) = os.popen2('hlins -q -db ' + os.path.abspath(pagefile), 1)
  83                pin.write(out)
  84                pin.close()
  85                out = '\n'.join(pout.readlines())
  86                pout.close()
  87             except IOError, (errno, strerror):
  88                pin.close()
  89                pout.close()
  90  
  91 
  92         # To please Springer-Verlag.
  93         out = out.replace('Springer-Verlag', '&copy;Springer-Verlag')
  94 
  95         self.request.write(formatter.rawHTML(out))

JunHu: bibtex.py (last edited 2008-10-03 20:20:36 by localhost)