From 03c1a5d2f16472a100b0f7efd4c47fed406f8789 Mon Sep 17 00:00:00 2001 From: kthoden Date: Fri, 19 Jul 2019 16:55:34 +0200 Subject: [PATCH] Make tex4ht run optional --- tei2imxml.py | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/tei2imxml.py b/tei2imxml.py index bfa0d9f..4297040 100755 --- a/tei2imxml.py +++ b/tei2imxml.py @@ -1223,9 +1223,20 @@ def main(): action="store_true", help="In floats, only print number of figure, not chapter before." ) - - parser.add_argument("-d", "--pickleddata", default="./output/imxml/tmp_files/data.pickle", help="Pickled data file to be used.") - parser.add_argument("-him", "--hyperimage", action="store_true") + parser.add_argument( + "-d", "--pickleddata", + default="./output/imxml/tmp_files/data.pickle", + help="Pickled data file to be used." + ) + parser.add_argument( + "-him", "--hyperimage", + action="store_true" + ) + parser.add_argument( + "-n", "--no-bib4ht", + action="store_true", + help="Skip creation of bibliography, rely on already present HTML files." + ) args = parser.parse_args() config_file = args.CONFIG_FILE print("The config file is ", config_file) @@ -1279,7 +1290,13 @@ def main(): used_citekeys = get_all_citations(xml_tree) citations_filename_root = Path(TEMP_DIR, "formatted_citations_monograph") # citations_filename_html = make_bibliography_pandoc(used_citekeys, bib_data, citations_json, citations_filename_root, CSL_FILE) - citations_filename_html = make_bibliography_tex4ht(used_citekeys, bib_data, citations_filename_root, publication_language, TEMP_DIR, LOG_DIR) + + if args.no_bib4ht: + citations_filename_html = citations_filename_root.with_suffix(".html") + logging.info("Skipping creation of HTML bibliography files. Using the existing ones.") + else: + citations_filename_html = make_bibliography_tex4ht(used_citekeys, bib_data, citations_filename_root, publication_language, TEMP_DIR, LOG_DIR) + logging.info("Formatting citations now.") cited_dict = format_citations(used_citekeys, citations_dict, citations_filename_html) refs_for_bib_chapter = format_reference_list(used_citekeys, citations_filename_html) @@ -1298,7 +1315,11 @@ def main(): else: citations_filename_root = Path(TEMP_DIR, f"formatted_citations_{chapter_id}") # citations_filename_html_per_chapter = make_bibliography_pandoc(used_citekeys_per_chapter, bib_data, citations_json, citations_filename_root, CSL_FILE) - citations_filename_html_per_chapter = make_bibliography_tex4ht(used_citekeys_per_chapter, bib_data, citations_filename_root, publication_language, TEMP_DIR, LOG_DIR) + if args.no_bib4ht: + citations_filename_html_per_chapter = citations_filename_root.with_suffix(".html") + logging.info("Skipping creation of HTML bibliography files. Using the existing ones.") + else: + citations_filename_html_per_chapter = make_bibliography_tex4ht(used_citekeys_per_chapter, bib_data, citations_filename_root, publication_language, TEMP_DIR, LOG_DIR) logging.info("Formatting citations now.") cited_dict_per_chapter = format_citations(used_citekeys_per_chapter, citations_dict, citations_filename_html_per_chapter)