def parse(string):
<EOL>bib = []<EOL>if not isinstance(string, six.text_type):<EOL><INDENT>string = string.decode('<STR_LIT:utf-8>')<EOL><DEDENT>for key, value in special_chars:<EOL><INDENT>string = string.replace(key, value)<EOL><DEDENT>string = re.sub(r'<STR_LIT>', r'<STR_LIT>', string)<EOL>entries = re.findall(<EOL>r'<STR_LIT>',<EOL>string)<EOL>for entry in entries:<EOL><INDENT>pairs = re.findall(r'<STR_LIT>', entry[<NUM_LIT:2>])<EOL>bib.append({'<STR_LIT:type>': entry[<NUM_LIT:0>].lower(), '<STR_LIT:key>': entry[<NUM_LIT:1>]})<EOL>for key, value in pairs:<EOL><INDENT>key = key.lower()<EOL>if value and value[<NUM_LIT:0>] == '<STR_LIT:">' and value[-<NUM_LIT:1>] == '<STR_LIT:">':<EOL><INDENT>value = value[<NUM_LIT:1>:-<NUM_LIT:1>]<EOL><DEDENT>if value and value[<NUM_LIT:0>] == '<STR_LIT:{>' and value[-<NUM_LIT:1>] == '<STR_LIT:}>':<EOL><INDENT>value = value[<NUM_LIT:1>:-<NUM_LIT:1>]<EOL><DEDENT>if key not in ['<STR_LIT>', '<STR_LIT:title>']:<EOL><INDENT>value = value.replace('<STR_LIT:}>', '<STR_LIT>').replace('<STR_LIT:{>', '<STR_LIT>')<EOL><DEDENT>else:<EOL><INDENT>if value.startswith('<STR_LIT:{>') and value.endswith('<STR_LIT:}>'):<EOL><INDENT>value = value[<NUM_LIT:1>:]<EOL>value = value[:-<NUM_LIT:1>]<EOL><DEDENT><DEDENT>value = value.strip()<EOL>value = re.sub(r'<STR_LIT>', '<STR_LIT:U+0020>', value)<EOL>bib[-<NUM_LIT:1>][key] = value<EOL><DEDENT><DEDENT>return bib<EOL>
Takes a string in BibTex format and returns a list of BibTex entries, where
each entry is a dictionary containing the entries' key-value pairs.

@type  string: string
@param string: bibliography in BibTex format

@rtype: list
@return: a list of dictionaries representing a bibliography