Skip to content

skatsubo/bbl2bib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Bibitem to bib converter

It extracts fields from unstructured \bibitem content by pattern matching (based on GROK regex library) and then saves them in bibtex format.

Use it when a document has citations without using BibTex but just old style thebibliography environment and \bibitem's. The script translates \bibitem entries and puts them into BibTex format.

Installation

Install dependencies with

pip install -r requirements.txt

or

pip3 install pygrok ply

How to run

Run it and save its output to a file:

python3 bbl2bib.py samples/bibitem-medium.tex > bibitem.bib

Run with verbose debug output:

python3 bbl2bib.py samples/bibitem.tex -d

How to develop

You can test your grok patterns at https://grokdebug.herokuapp.com/.

See the list of available default grok patterns: https://grokdebug.herokuapp.com/patterns or https://github.com/garyelephant/pygrok/tree/master/pygrok/patterns.

Sources and documentation for pygrok: https://github.com/garyelephant/pygrok.

Issues

Both pygrok and py3grok have their limitations.

Alternatives

convertbiblio

Run as

python3 convertbiblio.py ref.tex

Uses online database.

curl -L -o bbl2bib.pl https://raw.githubusercontent.com/borisveytsman/crossrefware/master/bbl2bib.pl
sudo cpan install BibTeX::Parser
perl bbl2bib.pl bibitem.tex

text2bib

docker run -it --rm -v $(pwd):/srv --entrypoint sh php:5.6-alpine
cd /srv
php -f convert.php bibitem2.tex
#docker run -it --rm -v $(pwd):/srv php:5.6-alpine -f /srv/convert.php /srv/bbl.tex

Remove square brackets []

gsed -E 's \[\{ { ; s \}\] } ' bibitem.tex > bibitem2.tex

perl

https://ctan.org/tex-archive/biblio/bibtex/utils/tex2bib https://sites.ualberta.ca/afs/ualberta.ca/sunsite/ftp/pub/Mirror/CTAN/help/Catalogue/entries/tex2bib.html

/CTAN/biblio/bibtex/utils/tex2bib/

sudo cpan notest install Perl4::CoreLibs

perl tex2bib.pl -i bibitem.tex

About

Grok-based bibliography converter experiment: bibitem BBL to BIB

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages