A simple and maintainable parser for the BibTeX language using pyparsing.
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.
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.
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'}]
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