BibKeys

# BibKeys.py

# Copyright (C) 2004 Jamie Lawrence
# http://jamie.ideasasylum.com
#        
# This program 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 
# of the License, or (at your option) any later version.
#   
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details. 
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.

'''
Extract all the references from a bibtex file and insert them as wikinames into a page
'''

__author__  =    '''Jamie Lawrence (http://jamie.ideasasylum.com)'''
__version__ =    '''0.0.1'''

import string, sys, bibfile, bibgrammar
#from bibstyle import BibStyle

# Edit this line to point to your BibTeX file
file = '/usr/home/tom/references/refs.bib'

def execute(macro, arg):
    # open the bib file
    try :
        src = open(file).read()
    except :
        return 'No BibTeX file: %s' % bibfile

    bfile = bibfile.BibFile()
    bibgrammar.Parse(src, bfile)
    
    links = []
    for entry in bfile.entries:
        links.append(macro.formatter.pagelink(None, entry.citekey))
    return '<br/>\n'.join(['%s' % (entry) for entry in links])

MoinMoin: MacroMarket/BibKeys (last edited 2007-10-29 19:19:36 by localhost)