From 7e07d13df54d716230b45149dd001bba2bd12fd9 Mon Sep 17 00:00:00 2001 From: Klaus Thoden Date: Mon, 22 Jan 2018 18:58:24 +0100 Subject: [PATCH] Ongoing work --- eoaconvert.py | 39 +++++++++++++++++++++++++++++++++------ 1 file changed, 33 insertions(+), 6 deletions(-) diff --git a/eoaconvert.py b/eoaconvert.py index f303492..fc7c493 100755 --- a/eoaconvert.py +++ b/eoaconvert.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -*- coding: utf-8; mode: python -*- -# Time-stamp: <2018-01-22 16:59:11 (kthoden)> +# Time-stamp: <2018-01-22 18:57:49 (kthoden)> # license? __version__= "1.0" @@ -964,11 +964,10 @@ def cleanup(): citeproc_process = subprocess.Popen(citeproc_arguments, stdout=subprocess.PIPE) citeproc_json = citeproc_process.stdout.read() -jsonObj = json.loads(citeproc_json) - -for x in jsonObj: - print(x["title"]) +citations_json = json.loads(citeproc_json) +# for x in citations_json: +# print(x["title"]) #################### # the old solution # @@ -1057,6 +1056,30 @@ def cleanup(): xmlBibliography.tag = "div" xmlBibliography.getparent().tag = "div" #xmlBibliography.addnext(xmlBibliographyDiv) + + ############### + # new version # + ############### + + formatted_references = libeoaconvert.format_citations(set_citations, bib_database + ".bib")[0] + + # to check: is the order correct? + entries = formatted_references.findall(".//div") + + for entry in entries: + entry_id = entry.get("id") + entry.set("class", "bibliography") + etree.strip_tags(entry, "p") + entry.tag = "p" + xmlBibliography.append(entry) + + ###################### + # end of new version # + ###################### + + ############### + # old version # + ############### xmlEntries = xmlBibTree.findall(".//entry") intNumberOfEntry = 0 for xmlEntry in xmlEntries: @@ -1080,9 +1103,13 @@ def cleanup(): print("a new entry", strNewentry) xmlNew = etree.fromstring(strNewentry) - xmlBibliography.append(xmlNew) + # xmlBibliography.append(xmlNew) intNumberOfEntry += 1 + ###################### + # end of old version # + ###################### + # If Bibliography-Type is anthology search for EOAbibliography and make one per chapter if xmlTree.find(".//EOAbibliographytype").text == "anthology":