• Stars
    star
    113
  • Rank 310,115 (Top 7 %)
  • Language
    Python
  • License
    MIT License
  • Created almost 11 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Simple, faithful BibTeX parser and algorithms for Python 3

Biblib provides a simple, standalone Python3 package for parsing BibTeX bibliographic databases, as well as algorithms for manipulating BibTeX entries in BibTeX-y ways.

There are a lot of BibTeX parsers out there. Most of them are complete nonsense based on some imaginary grammar made up by the module's author that is almost, but not quite, entirely unlike BibTeX's actual grammar. BibTeX has a grammar. It's even pretty simple, though it's probably not what you think it is. The hardest part of BibTeX's grammar is that it's only written down in one place: the BibTeX source code.

Biblib's parser is derived directly from the WEB source code for BibTeX and hence (barring bugs in translation) should be fully compatible with BibTeX's own parser.

Features

  • BibTeX-compatible .bib file parser

  • BibTeX-compatible name parser for fields like author

  • Crossref resolution

  • BibTeX-compatible title casing

  • Translator for common TeX markup (like accents) to Unicode (which can, in turn, be used in HTML and other formats).

Installation

Since biblib has no external dependencies or C modules, you can use biblib in your project by simply unpacking it under your source tree and adding

sys.path.append('biblib')

before importing it.

Biblib can also be installed system-wide with

python3 setup.py install

Examples

There are a few simple examples of biblib's use in examples/. To run these dircetly from the source tree, use, for example

PYTHONPATH=$PWD ./examples/bibparse test.bib

Recognized grammar

For reference, the .bib parser implements a grammar equivalent to the following PEG. All literals are matched case-insensitively.

bib_db = comment (command_or_entry comment)*

comment = [^@]*

ws = [ \t\n]*

ident = ![0-9] (![ \t"#%'(),={}] [\x20-\x7f])+

command_or_entry = '@' ws (comment / preamble / string / entry)

comment = 'comment'

preamble = 'preamble' ws ( '{' ws preamble_body ws '}'
                         / '(' ws preamble_body ws ')' )

preamble_body = value

string = 'string' ws ( '{' ws string_body ws '}'
                     / '(' ws string_body ws ')' )

string_body = ident ws '=' ws value

entry = ident ws ( '{' ws key ws entry_body? ws '}'
                 / '(' ws key_paren ws entry_body? ws ')' )

key = [^, \t}\n]*

key_paren = [^, \t\n]*

entry_body = (',' ws ident ws '=' ws value ws)* ','?

value = piece (ws '#' ws piece)*

piece
    = [0-9]+
    / '{' balanced* '}'
    / '"' (!'"' balanced)* '"'
    / ident

balanced
    = '{' balanced* '}'
    / [^{}]

More Repositories

1

latexrun

A 21st century LaTeX wrapper
Python
615
star
2

libelfin

C++11 ELF/DWARF parser
C++
311
star
3

go-misc

Miscellaneous Go hacks
Go
224
star
4

sv6

POSIX-like scalable multicore research OS kernel
C
181
star
5

perflock

Locking wrapper for running benchmarks on shared hosts
Go
147
star
6

go-perf

Go packages and tools for Linux perf
Go
142
star
7

mtrace

Memory access tracing QEMU
C
93
star
8

commuter

Automated multicore scalability testing tool
Python
87
star
9

go-moremath

An assortment of more specialized math routines for Go
Go
65
star
10

cpubars

Lightweight terminal-based multicore CPU usage monitor
C
58
star
11

go-gg

Plotting package for Go
Go
41
star
12

go-gcstats

Go runtime GC trace analysis and statistics tool
Go
35
star
13

go-obj

Object file abstractions in Go
Go
30
star
14

go-z3

Bindings for the Z3 SMT solver
Go
28
star
15

objbrowse

Interactive object file browser with symbol, source, assembly, and analysis
TypeScript
22
star
16

go-perf-v2

Work space for golang.org/x/perf version 2
Go
20
star
17

go-rabin

Rabin hashing and content-defined chunking for Go
Go
19
star
18

benchplot

Tool for plotting Go benchmark results
Go
14
star
19

go-perfevent

A Go API for perf_event_open
Go
14
star
20

notmuch

UNIX mail with full text search, tags, and global threading
C
11
star
21

go-gcpacing

Go concurrent GC pacing simulator
Python
11
star
22

memtrace

Pintool for logging memory writes
Go
11
star
23

quickfilter

Simple, lean, client-side JavaScript faceted search UI
JavaScript
7
star
24

my-bin

My random binaries
Python
6
star
25

go-gcbench

Benchmarks for the Go garbage collector
Go
5
star
26

my-dotfiles

My dotfiles
HTML
5
star
27

thesis

PhD dissertation on the scalable commutativity rule
C
5
star
28

shade

Program for modeling solar flux through the year
Go
3
star
29

my-hass

Custom Home Assistant components
Python
2
star
30

gotest

"go test" runner with nice output
Go
2
star
31

.emacs.d

My Emacs configuration
Emacs Lisp
1
star
32

jsjs

Toy JavaScript-to-JavaScript compiler
JavaScript
1
star
33

go-gc-efficiency

Go GC efficiency experiments support code
Go
1
star
34

ac

Basic architectural calculator
Go
1
star