Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Move footnote check to separate function
  • Loading branch information
kthoden committed Sep 4, 2020
1 parent 724f9ee commit b3f37c8
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions src/eoatex2imxml.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8; mode: python -*-
# Time-stamp: <2020-09-03 15:57:40 (kthoden)>
# Time-stamp: <2020-09-04 13:46:35 (kthoden)>

"""
Converts Latex files into a customized DocBook XML file.
Expand Down Expand Up @@ -1104,6 +1104,23 @@ def make_indices_child_of_div0():
parent_div.append(section)
# def make_indices_child_of_div0 ends here

def check_footnote_paragraphs():
"""Check if footnotes contain more than one paragraph"""

grep_command = "grep -A1 -B2 'argument of \\\EOAfn' {}".format(
LOG_DIR / SCRIPT_NAME / (INPUT_PATH.stem + "-tralics.log")
)
grep_command_arguments = shlex.split(grep_command)
grep_result = subprocess.Popen(grep_command_arguments, stdout=subprocess.PIPE)
grep_output = grep_result.stdout.read()
if len(grep_output) > 0:
logging.warning("\n===\nFootnotes with paragraphs were found. They have to be replaced by the \EOAfnpar command.\n")
logging.warning(grep_output.decode("utf-8"))
logging.warning("===\n")
else:
logging.inf("Footnote check found no errors")
# def check_footnote_paragraphs ends here

##############################################################
# Preparing the Bibliography #
##############################################################
Expand Down Expand Up @@ -1878,16 +1895,7 @@ def add_bibliography_to_xml(
# Pickle the 'data' dictionary using the highest protocol available.
pickle.dump(data_to_pickle, f, pickle.HIGHEST_PROTOCOL)

grep_command = "grep -A1 -B2 'argument of \\\EOAfn' {}".format(
LOG_DIR / SCRIPT_NAME / (INPUT_PATH.stem + "-tralics.log")
)
grep_command_arguments = shlex.split(grep_command)
grep_result = subprocess.Popen(grep_command_arguments, stdout=subprocess.PIPE)
grep_output = grep_result.stdout.read()
if len(grep_output) > 0:
logging.info("\n===\nFootnotes with paragraphs were found. They have to be replaced by the \EOAfnpar command.\n")
logging.info(grep_output.decode("utf-8"))
logging.info("===\n")
check_footnote_paragraphs()

logging.info("Removing temporary files.")
cleanup()
Expand Down

0 comments on commit b3f37c8

Please sign in to comment.