Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions jupyter_book_to_htmlbook/file_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,15 @@ def get_top_level_sections(soup):
all but bibliography sections
"""
section_wrappers = soup.find_all("article", attrs={"role": "main"})
top_level_sections = []

# test case for partial files, not expected in production
if len(section_wrappers) == 0:
sections = soup.find_all('section')

for section in sections:
if section.find_parent('section') is None:
top_level_sections.append(section)
elif len(section_wrappers) != 1:
article = soup.find('article', attrs={"role": "main"})
try:
Expand All @@ -156,16 +161,15 @@ def get_top_level_sections(soup):
return None, None
else:
main = section_wrappers[0]
sections = []

for element in main.children:
if (
element.name == "section" and
element.get('id') != "bibliography"
):
sections.append(element)
top_level_sections.append(element)

return sections
return top_level_sections


def get_main_section(soup):
Expand Down
Loading
Loading