Skip to content

Commit

Permalink
Insert bibliography where PI is, don't add extra chapter
Browse files Browse the repository at this point in the history
  • Loading branch information
kthoden committed Mar 4, 2020
1 parent decf367 commit 52d087b
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions src/tei2imxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -1441,13 +1441,23 @@ def update_ids(xml_tree, ignore_ref_errors):
def add_bibliography_monograph(xml_tree, refs_for_bib_chapter):
"""Add another chapter containing the bibliography."""

root_element = xml_tree.getroot()
# root_element = xml_tree.getroot()

xml_chapters = root_element.xpath("//div1")
number_of_chapters = len(xml_chapters)
bibliography_chapter = etree.Element("div1", rend="nonumber", language="english")
# xml_chapters = root_element.xpath("//div1")
# number_of_chapters = len(xml_chapters)
# bibliography_chapter = etree.Element("div1", rend="nonumber", language="english")
# this needs to be configurable by language
bib_head = etree.SubElement(bibliography_chapter, "head").text = "Bibliography"
# bib_head = etree.SubElement(bibliography_chapter, "head").text = "Bibliography"

eoa_pis = xml_tree.xpath("//div1//processing-instruction('eoa')")
for eoa_pi in eoa_pis:
if eoa_pi.text == "printbibliography":
bibliography_parent = eoa_pi.getparent()
bibliography_parent.tag = "tagtobestripped"
bibliography_chapter = eoa_pi.xpath("ancestor-or-self::div1[1]")[0]

print(bibliography_chapter)

bib_div_1 = etree.SubElement(bibliography_chapter, "div")
bib_div_2 = etree.SubElement(bib_div_1, "div")

Expand All @@ -1464,9 +1474,9 @@ def add_bibliography_monograph(xml_tree, refs_for_bib_chapter):

bib_div_2.append(entry)

root_element.insert(number_of_chapters + 1, bibliography_chapter)
# root_element.insert(number_of_chapters + 1, bibliography_chapter)

return root_element
return xml_tree
# def add_bibliography_monograph ends here

def add_bibliography_anthology(xml_tree, formatted_references_dict):
Expand Down

0 comments on commit 52d087b

Please sign in to comment.