Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Table number to tabdict and id handling
  • Loading branch information
Klaus Thoden committed Aug 31, 2018
1 parent 69bce60 commit f6fed94
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions tei2imxml.py
Expand Up @@ -662,6 +662,7 @@ def assign_ids(xml_tree, data):
equation_counter = 1
footnote_counter = 1
list_counter = 1
figure_counter = 1
section_counter = 1
table_counter = 1
theorem_counter = 1
Expand All @@ -671,7 +672,6 @@ def assign_ids(xml_tree, data):
chapterdict[chapter.get("id")] = str(chapter_counter)

figure_anchors = chapter.findall(".//EOAfigure/anchor")
figure_counter = 1
for anchor in figure_anchors:
figure_number = "%d.%d" % (chapter_counter, figure_counter)

Expand All @@ -687,7 +687,6 @@ def assign_ids(xml_tree, data):
fndict[footnote.get("id")] = footnote.get("n")

sections = chapter.findall(".//div2")
section_counter = 1
for section in sections:

if section.get('rend') != "nonumber":
Expand All @@ -705,6 +704,15 @@ def assign_ids(xml_tree, data):
subsection_counter += 1

section_counter += 1

tables = chapter.findall(".//EOAtable/table")
for table in tables:
table_number = "{}.{}".format(chapter_counter, table_counter)
table.attrib["id-text"] = table_number
# table.set("id-text", table_number)
table_counter += 1
tabdict[table.get("id")] = table_number

chapter_counter += 1

# not implemented yet: equation, list, pagelabel, tab, theorem
Expand All @@ -727,9 +735,6 @@ def update_ids(xml_tree):

xmlReferences = xml_tree.findall(".//EOAref")
logging.debug("Found %d references", len(xmlReferences))
all_ids = xml_tree.xpath('//*[@xml:id]')
for xmlid in all_ids:
print(xmlid, "all ids")

for xmlReference in xmlReferences:
eoa_reference = xmlReference.find("ref")
Expand Down

0 comments on commit f6fed94

Please sign in to comment.