diff --git a/src/eoatex2imxml.py b/src/eoatex2imxml.py index e188c18..9c0f759 100755 --- a/src/eoatex2imxml.py +++ b/src/eoatex2imxml.py @@ -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 @@ -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": @@ -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: @@ -1026,6 +1034,7 @@ def number_footnotes( xmlChapters ): intNoteNumber += 1 return dictFootnotes + def number_lists( xmlChapters ): dictLists = {} for xmlChapter in xmlChapters: