Skip to content

Commit

Permalink
Handle IndexError during TOC top level block creation
Browse files Browse the repository at this point in the history
  • Loading branch information
russellkan committed Sep 29, 2023
1 parent 38f1804 commit 8565017
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion n2y/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,17 @@ def get_children(self):
index += 1
subsections.append([header])
if header[0] > 1:
subsections[index].append(header)
try:
subsections[index].append(header)
except IndexError:
logger.warning(
f'Skipping out-of-order header "{header[1][0]}" in table of'
" contents for page named"
f" {self.page.title.to_plain_text()} ({self.page.notion_url})."
" Please create headers in sequence (i.e. proper document"
f" formatting dictates that an H1 should not be"
f" immediately followed by an H{header[0]}, but an H2)."
)
for subsection in subsections:
notion_data = self.generate_item_block(subsection)
children.append(
Expand Down

0 comments on commit 8565017

Please sign in to comment.