Skip to content

Commit

Permalink
Add chapter and section labels to respective dictionaries
Browse files Browse the repository at this point in the history
The ids of the elements themselves are deleted at a later step
  • Loading branch information
kthoden committed Jul 9, 2021
1 parent 806502f commit 4bcc901
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/eoatex2imxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,10 @@ def number_chapters( xmlChapters ):
for xmlChapter in xmlChapters:
if xmlChapter.get('rend') != "nonumber":
Chapteruid = xmlChapter.get('id')
following_anchor_id = xmlChapter.xpath(".//anchor[preceding-sibling::head]/@id")
dictChapters[Chapteruid] = str(Chapternumber)
if len(following_anchor_id) > 0:
dictChapters[following_anchor_id[0]] = str(Chapternumber)
Chapternumber += 1
return dictChapters

Expand Down Expand Up @@ -576,7 +579,6 @@ def process_equations( xmlChapters, dictChapters, strNumberingType, donotgenerat
tmpI = 0
# Insert Number of this Subequation into dictEquations
xmlAnchor = xmlDing.find(".//anchor")
logging.info(xmlAnchor)
if xmlChapter.get("rend") != "nonumber":
dictEquations[xmlAnchor.get('id')] = dictChapters[xmlChapter.get('id')] + "." + str(intEquationnumber)
if xmlChapter.get("rend") == "nonumber":
Expand Down Expand Up @@ -995,10 +997,16 @@ def number_sections( xmlChapters ):
if xmlSection.get("rend") == "nonumber":
continue
strUID = xmlSection.get("id")

following_anchor_id = xmlSection.xpath(".//anchor[preceding-sibling::head]/@id")
if xmlChapter.get("rend") != "nonumber":
dictSections[strUID] = str(intChapterNumber) + "." + str(intSectionNumber)
if xmlChapter.get("rend") == "nonumber":
if len(following_anchor_id) > 0:
dictSections[following_anchor_id[0]] = str(intChapterNumber) + "." + str(intSectionNumber)
else:
dictSections[strUID] = str(intSectionNumber)
if len(following_anchor_id) > 0:
dictSections[following_anchor_id[0]] = str(intSectionNumber)
xmlSubsections = xmlSection.findall("div3")
intSubsectionNumber = 1
for xmlSubsection in xmlSubsections:
Expand Down Expand Up @@ -1026,6 +1034,7 @@ def number_footnotes( xmlChapters ):
intNoteNumber += 1
return dictFootnotes


def number_lists( xmlChapters ):
dictLists = {}
for xmlChapter in xmlChapters:
Expand Down

0 comments on commit 4bcc901

Please sign in to comment.