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

Wrong numbering in markdown export of nested ordered lists #189

Open
ceberam opened this issue Mar 13, 2025 · 0 comments
Open

Wrong numbering in markdown export of nested ordered lists #189

ceberam opened this issue Mar 13, 2025 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@ceberam
Copy link
Collaborator

ceberam commented Mar 13, 2025

Nested ordered lists are exported in markdown with a wrong number sequence.
After an inner list, the next item of the outer list does not show the right number in its marker.

To reproduce the issue, run the following snippet with the current docling-core version 2.22.0.

from docling_core.types.doc.document import DoclingDocument, DocItemLabel, GroupLabel

doc = DoclingDocument(name="file")
parent = doc.add_text(parent=None, label=DocItemLabel.TITLE, text="Test")
parent_A = doc.add_group(parent=parent, name="list A", label=GroupLabel.ORDERED_LIST)
doc.add_list_item(text="Item 1 in A", enumerated=True, parent=parent_A)
doc.add_list_item(text="Item 2 in A", enumerated=True, parent=parent_A)
item_A_3 = doc.add_list_item(text="Item 3 in A", enumerated=True, parent=parent_A) 

parent_B= doc.add_group(parent=item_A_3, name="list B", label=GroupLabel.ORDERED_LIST)
doc.add_list_item(text="Item 1 in B", enumerated=True, parent=parent_B)
doc.add_list_item(text="Item 2 in B", enumerated=True, parent=parent_B)

doc.add_list_item(text="Item 4 in A", enumerated=True, parent=parent_A) 
print(doc.export_to_markdown())

The print command shows:

# Test

1. Item 1 in A
2. Item 2 in A
3. Item 3 in A
    1. Item 1 in B
    2. Item 2 in B
5. Item 4 in A

while the correct output should be:

# Test

1. Item 1 in A
2. Item 2 in A
3. Item 3 in A
    1. Item 1 in B
    2. Item 2 in B
4. Item 4 in A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants