Skip to content

Commit

Permalink
Fix #33
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnlentink committed Sep 23, 2024
1 parent 3db2f84 commit 203b51c
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions bible_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,23 @@ def download_bible_chapters(location, selected_bible_id, selected_bible_abbr, bi

def parse_chapter(parent, chapter):
chapter_num = chapter.attrib["data-usfm"].split(".")[-1]
SubElement(parent, 'chapter', number=chapter_num, style='c')

for el in chapter:
heading = el.xpath(".//*[contains(@class,'heading')]")
if len(heading) > 0:
parse_header(parent, heading)
else:
parse_paragraph(parent, el, "p")
try:
chapter_num = str(int(chapter_num))
except:
pass

if chapter_num.isnumeric():
SubElement(parent, 'chapter', number=chapter_num, style='c')

for el in chapter:
heading = el.xpath(".//*[contains(@class,'heading')]")
if len(heading) > 0:
parse_header(parent, heading)
else:
parse_paragraph(parent, el, "p")
else:
print(f"[SKIPPING CHAPTER] Bible chapter has invalid chapter number: {chapter_num}")

def parse_verse_numbers(verse_label: str, verse):
verse_input = verse_label.strip()
Expand Down

0 comments on commit 203b51c

Please sign in to comment.