mirror of
https://github.com/DS4SD/docling.git
synced 2025-12-11 22:28:31 +00:00
fix(docx): Missing list items after numbered header (#2665)
* fix #2250. list items after numbered headers Signed-off-by: Michele Dolfi <dol@zurich.ibm.com> * add test for new case Signed-off-by: Michele Dolfi <dol@zurich.ibm.com> * chore(docx): remove unnecessary check Remove 'current_parent is None' check in '_add_list_item' function since it will always be None. Signed-off-by: Cesar Berrospi Ramis <ceb@zurich.ibm.com> --------- Signed-off-by: Michele Dolfi <dol@zurich.ibm.com> Signed-off-by: Cesar Berrospi Ramis <ceb@zurich.ibm.com> Co-authored-by: Cesar Berrospi Ramis <ceb@zurich.ibm.com>
This commit is contained in:
@@ -1145,6 +1145,9 @@ class MsWordDocumentBackend(DeclarativeDocumentBackend):
|
||||
elem_ref: list[RefItem] = []
|
||||
# This should not happen by construction
|
||||
if not isinstance(self.parents[level], ListGroup):
|
||||
_log.warning(
|
||||
"Parent element of the list item is not a ListGroup. The list item will be ignored."
|
||||
)
|
||||
return elem_ref
|
||||
if not elements:
|
||||
return elem_ref
|
||||
@@ -1197,7 +1200,9 @@ class MsWordDocumentBackend(DeclarativeDocumentBackend):
|
||||
|
||||
level = self._get_level()
|
||||
prev_indent = self._prev_indent()
|
||||
if self._prev_numid() is None: # Open new list
|
||||
if self._prev_numid() is None or (
|
||||
self._prev_numid() == numid and self.level_at_new_list is None
|
||||
): # Open new list
|
||||
self.level_at_new_list = level
|
||||
|
||||
# Reset counters for the new numbering sequence
|
||||
@@ -1285,6 +1290,8 @@ class MsWordDocumentBackend(DeclarativeDocumentBackend):
|
||||
self._add_formatted_list_item(
|
||||
doc, elements, enum_marker, is_numbered, level - 1
|
||||
)
|
||||
else:
|
||||
_log.warning("List item not matching any insert condition.")
|
||||
return elem_ref
|
||||
|
||||
@staticmethod
|
||||
|
||||
Reference in New Issue
Block a user