diff --git a/src/book.py b/src/book.py index f3d95a3..e340ad6 100644 --- a/src/book.py +++ b/src/book.py @@ -851,12 +851,15 @@ class Book: self.set_error_status() raise exc - # add is_introduction field if first chapter is Introduction - if not self.top_level_headers[0]['should_be_numbered']: - # title should be checked as after deleting content - # before toc, some chapters can be deleted - if self.top_level_headers[0]['title'] in json_strc[0].keys(): - json_strc[0]['is_introduction'] = True + # Add is_introduction field to json structure + # after deleting content before toc, some chapters can be deleted + same_first_titles = self.top_level_headers[0]['title'] in json_strc[0].keys() + is_first_header_introduction = not self.top_level_headers[0]['should_be_numbered'] + + if is_first_header_introduction and same_first_titles: + json_strc[0]['is_introduction'] = True + else: + json_strc[0]['is_introduction'] = False self.content_dict = { "content": json_strc,