Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TLDR-809 fix docx numeration bug #495

Merged
merged 1 commit into from
Sep 13, 2024
Merged
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
15 changes: 9 additions & 6 deletions dedoc/readers/docx_reader/numbering_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ def __get_list_item_text(self, ilvl: str, num_id: str) -> str:
if abstract_num_id in self.state.prev_ilvl_dict:
prev_ilvl = self.state.prev_ilvl_dict[abstract_num_id]

restarted = False
# startOverride:
if lvl_info.restart:
if abstract_num_id in self.state.prev_num_id_dict:
Expand All @@ -112,13 +113,15 @@ def __get_list_item_text(self, ilvl: str, num_id: str) -> str:
prev_num_id = None
if prev_num_id and prev_num_id != num_id:
self.state.numerations_dict[(abstract_num_id, ilvl)] = lvl_info.start
restarted = True

# it's a new deeper level
if prev_ilvl < ilvl and lvl_info.lvl_restart or (abstract_num_id, ilvl) not in self.state.numerations_dict:
self.state.numerations_dict[(abstract_num_id, ilvl)] = lvl_info.start
# it's a continue of the old level (current level <= previous level)
else:
self.state.numerations_dict[(abstract_num_id, ilvl)] += 1
if not restarted:
# it's a new deeper level
if prev_ilvl < ilvl and lvl_info.lvl_restart or (abstract_num_id, ilvl) not in self.state.numerations_dict:
self.state.numerations_dict[(abstract_num_id, ilvl)] = lvl_info.start
# it's a continue of the old level (current level <= previous level)
else:
self.state.numerations_dict[(abstract_num_id, ilvl)] += 1

# there isn't the information about this list
else:
Expand Down
Loading