Skip to content

fix(md): keep a list item that holds only a nested list - #5256

Open
prassu017 wants to merge 1 commit into
docling-project:mainfrom
prassu017:fix/5255-md-list-item-only-sublist
Open

prassu017 wants to merge 1 commit into
docling-project:mainfrom
prassu017:fix/5255-md-list-item-only-sublist

Conversation

@prassu017

Copy link
Copy Markdown
Contributor

In the Markdown backend, a list item is created only when its first child is a non-empty paragraph. An item with no text of its own whose first child is a sub-list (1. followed by 1. a) fell through: no ListItem was made, the sub-list was attached to the outer list group, and the next item was numbered as if the parent never existed.

Such an item is now created empty right away, as the inline-group path already does, so the existing child walk puts the sub-list under it and the counter stays right.

Issue resolved by this Pull Request:
Resolves #5255

Checklist:

  • Documentation has been updated, if necessary.
  • Examples have been added, if necessary.
  • Tests have been added, if necessary.

Review evidence:

  • Before (main 1005c8d), the issue's input 1.\n 1. Sub-item A\n 2. Sub-item B\n2. Second item exports 1. Sub-item A\n 2. Sub-item B\n1. Second item; the sub-list group's parent is the outer list group.
  • After: texts ['', 'Sub-item A', 'Sub-item B', 'Second item'] with markers 1., 1., 2., 2.; the sub-list group's parent is the empty outer item, and the export is 1. \n 1. Sub-item A\n 2. Sub-item B\n2. Second item.
  • New test_list_item_holding_only_a_nested_list_is_kept (ordered and bullet) fails on main and passes after.
  • pytest tests/test_backend_markdown.py: 94 passed (includes the tests/data/md ground-truth check, no reference data changed).
  • ruff format --check and ruff check clean on both files; mypy on md_backend.py reports the same 27 errors as main (run without the project config).
  • Not run: full test suite, pre-commit hooks.

Signed-off-by: Prasanna Jain <prassu017@gmail.com>
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

✅ DCO Check Passed

Thanks @prassu017, all your commits are properly signed off. 🎉

@mergify

mergify Bot commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🟢 Merge protection satisfied — ready to merge.

Show 1 satisfied protection

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?(!)?:

@github-actions github-actions Bot added ai:ci-safe AI triage found no CI-safety concern (advisory) bug Something isn't working markdown issue related to markdown backend labels Nov 9, 2026
@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

AI triage (advisory)

Checked commit 9dba76dc98. The analysis read the diff only. It did not run code from this pull request.

The PR fixes the Markdown backend so that a list item whose first child is a nested list is kept as an empty ListItem. The sub-list now sits under that item, and the numbering of the next item stays correct. The PR adds a parametrized test for ordered and bullet lists.

CI safety: no concern found. A maintainer must still approve CI.

The ai:* labels are advisory. They do not approve CI and they do not add tests:full. A new push runs this check again.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI first review (advisory): no blocker found

This review covers the full diff at d9765b7404. It read the code and did not run it.

I found no defect. In docling/backend/md_backend.py, the new branch creates the empty item and updates the counter and list_last_item_by_ref. The child walk then keeps the new item as parent_item for the sub-list, so the sub-list goes under it and the next item is numbered correctly.

A maintainer makes the merge decision. This review never approves the pull request.

@github-actions github-actions Bot added the ai:review-lgtm AI first review found no blocker or major issue (advisory) label Nov 9, 2026
@codecov

codecov Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@PeterStaar-IBM

Copy link
Copy Markdown
Member

Hi @prassu017, thank you for this pull request.

It has a merge conflict with main. Please rebase your branch on the latest main and resolve the conflict:

git fetch upstream
git rebase upstream/main
# resolve the conflicts, then:
git push --force-with-lease

We can continue with the review and CI after that.

@prassu017
prassu017 force-pushed the fix/5255-md-list-item-only-sublist branch from d9765b7 to 9dba76d Compare November 13, 2026 15:36
@github-actions github-actions Bot removed the ai:ci-safe AI triage found no CI-safety concern (advisory) label Nov 13, 2026
@prassu017

Copy link
Copy Markdown
Contributor Author

Rebased on main (31d14a7) and force-pushed 9dba76d. The only conflict was in tests/test_backend_markdown.py: both branches appended a test at the end of the file, so both are kept. md_backend.py applied cleanly and the diff is unchanged.

Locally, tests/test_backend_markdown.py has 90 passed, 5 failed. The same 5 tests also fail on an unmodified main checkout in my environment (test_convert_valid, test_inline_whitespace_round_trips_through_markdown x3, test_rich_table_cell_runs_keep_boundary_whitespace), so they are unrelated to this change. Ruff check and format pass. I did not run the full suite.

@github-actions github-actions Bot added ai:ci-safe AI triage found no CI-safety concern (advisory) and removed ai:review-lgtm AI first review found no blocker or major issue (advisory) labels Nov 13, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai:ci-safe AI triage found no CI-safety concern (advisory) bug Something isn't working markdown issue related to markdown backend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Markdown backend: a list item without text that holds only a nested list is dropped

2 participants