From b7a47f29ed72d80121c7cd0c13a19bcdc7bdfbd8 Mon Sep 17 00:00:00 2001 From: Klaus Thoden Date: Thu, 5 Apr 2018 16:08:34 +0200 Subject: [PATCH] Formatted bibliographies can contain blank lines --- create_tmpbib.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/create_tmpbib.py b/create_tmpbib.py index 389050e..b89f11b 100644 --- a/create_tmpbib.py +++ b/create_tmpbib.py @@ -59,13 +59,19 @@ def tmp_citations(formatted_bibliography): citations = formbib.readlines() for citation in citations: - matches = re.match(authoryear_pattern, citation) - try: - tmp_citekey = "{}_{}".format(matches.group(1), matches.group(3)) - tmp_citekey_dict[tmp_citekey] = citation - except AttributeError: - tmp_citekey_dict["None_{:03d}".format(nonematcher)] = citation - nonematcher += 1 + print(len(citation)) + if len(citation) > 2: + logging.debug("Creating temporary citekey from %s." % citation) + matches = re.match(authoryear_pattern, citation) + try: + tmp_citekey = "{}_{}".format(matches.group(1), matches.group(3)) + 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 # def tmp_citations ends here