Skip to content

Instantly share code, notes, and snippets.

@jmuhlich
Created October 27, 2022 15:25
Show Gist options
  • Save jmuhlich/f921c929668f4ead8383fd8ed6c83fe9 to your computer and use it in GitHub Desktop.
Save jmuhlich/f921c929668f4ead8383fd8ed6c83fe9 to your computer and use it in GitHub Desktop.
Quick script to convert .bib bibtex to yaml (in no particular schema)
import bibtexparser
from pylatexenc.latex2text import LatexNodes2Text
import sys
import yaml
lt = LatexNodes2Text()
with open(sys.argv[1]) as f:
db = bibtexparser.load(f)
for e in db.entries:
for k, v in e.items():
e[k] = lt.latex_to_text(v)
print(yaml.dump(db.entries, allow_unicode=True))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment