Skip to content

A simple, maintainable BibTeX parser using pyparsing

Notifications You must be signed in to change notification settings

frcl/python-bibtex

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BibTeX parser for Python

A simple and maintainable parser for the BibTeX language using pyparsing.

What to expect

This project is work in progress. The following versioning scheme tells you what you can expect from the current version.

  • Version 0.1: More or less just a skeleton and won't reliably produce a result.
  • Version 0.2: All the functions described below will be implemented, but not all edge cases will work.
  • Version 0.3: A full implementation of the bibtex language, including tags and comments. A strict mode. But no customisation.

If no major problems show up, I will release a stable Version 1.0 after that.

Installation

The easiest way to install python-bibtex is with the pip package manager.

git clone https://github.com/DrFrankeStein/python-bibtex
cd python-bibtex
pip install .

Sometime in the future it will also be available on pypi, but maybe under a different name.

Dependencies

Usage

As a python library

Simply import the load/loads and dump/dumps functions from the bibtex module, as in any other parser module.

They will return a list of dictionaries. Each dictionary represents a reference and will always contain a type and a id entry.

>>> import bibtex
>>> bibtex.loads("""
... @article{foo16,
...     author = "John Doe",
...     year = 2016,
...     title = "Foo and Bar"
... }""")
[{'author': 'John Doe',
  'id': 'foo16',
  'title': 'Foo and Bar',
  'type': 'article',
  'year': '2016'}]

As a command line tool

The commands

bib2json file.bib

or

bib2yaml file.bib

generate a file.json or file.yaml respectively.

A special use case is pandocs system for including references. This requires as certain structure that can be generated with the -p/--pandoc command line option.

bib2yaml -p file.bib

About

A simple, maintainable BibTeX parser using pyparsing

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published