def parse_bibfile(bib_path):
    """Read a bibtex file into a dictionary."""
    dct = {}
    with open(bib_path, 'r') as f:
        for line in f:
            line = line.strip()
            if line:
                if line.startswith('@'):
                    entries = {}
                    start = line.find('{')
                    end = line.find(',')
                    citekey = '\cite{%s}' % line[start+1:end]
                    while not line.startswith('}'):
                        line = next(f)
                        if ' = ' not in line:
                            continue
                        key, value = line.split(' = ')
                        key = key.strip()
                        value = value.strip()[1:-1].strip('{}')
                        entries[key] = value
                    dct[citekey] = entries
    return dct