Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Formatted bibliographies can contain blank lines
  • Loading branch information
Klaus Thoden committed Apr 5, 2018
1 parent 9bde75d commit b7a47f2
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions create_tmpbib.py
Expand Up @@ -59,13 +59,19 @@ def tmp_citations(formatted_bibliography):
citations = formbib.readlines() citations = formbib.readlines()


for citation in citations: for citation in citations:
matches = re.match(authoryear_pattern, citation) print(len(citation))
try: if len(citation) > 2:
tmp_citekey = "{}_{}".format(matches.group(1), matches.group(3)) logging.debug("Creating temporary citekey from %s." % citation)
tmp_citekey_dict[tmp_citekey] = citation matches = re.match(authoryear_pattern, citation)
except AttributeError: try:
tmp_citekey_dict["None_{:03d}".format(nonematcher)] = citation tmp_citekey = "{}_{}".format(matches.group(1), matches.group(3))
nonematcher += 1 tmp_citekey_dict[tmp_citekey] = citation
except AttributeError:
tmp_citekey_dict["None_{:03d}".format(nonematcher)] = citation
nonematcher += 1

else:
logging.debug("Skipping blank line")


return tmp_citekey_dict return tmp_citekey_dict
# def tmp_citations ends here # def tmp_citations ends here
Expand Down

0 comments on commit b7a47f2

Please sign in to comment.