HTML: lists, tables and images inside <dt> are dropped
Maintainers usually reply within 2 days
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 24/100
Research direction
Start in docling/backend/html_backend.py at the dt and dd handling branches, then compare how nested content is processed for dd and li. Add regression coverage in tests/test_backend_html.py for terms containing lists, tables, and images, including an image-only term. Done means those contents are preserved under the term and the existing dd behavior remains unchanged; the issue says the groundtruth does not need updating. A tested fix is already linked, so check with the maintainers before starting overlapping work.
Written by the indexing model from the issue text.
Description
Summary
The HTML backend drops all block content inside a description term (<dt>): lists, tables, images and nested <dl>. HTML allows flow content in <dt>, and pages use it for logo glossaries, spec sheets with a small table in the term, and FAQ markup.
The text of the term skips these blocks on purpose, but unlike the <dd> and <li> paths, no other step then adds them to the document. A term that holds only an image disappears completely, and its <dd> becomes a top-level item with no term. Nothing is logged.
Reproduction
Run on current main (0521b433):
from io import BytesIO
from docling.backend.html_backend import HTMLDocumentBackend
from docling.datamodel.base_models import InputFormat
from docling.datamodel.document import InputDocument
CASES = {
"dt_with_list": b"<dl><dt>Colors<ol><li>red</li><li>blue</li></ol></dt><dd>palette</dd></dl>",
"dt_with_table": b"<dl><dt>Sizes<table><tr><td>S</td><td>M</td></tr></table></dt><dd>shirts</dd></dl>",
"dt_image_only": b'<dl><dt><img src="a.png" alt="ACME logo"></dt><dd>ACME Corp</dd></dl>',
"dd_with_list_control": b"<dl><dt>T</dt><dd>D<ul><li>nested</li></ul></dd></dl>",
}
for name, src in CASES.items():
in_doc = InputDocument(path_or_stream=BytesIO(src), format=InputFormat.HTML,
backend=HTMLDocumentBackend, filename="t.html")
doc = HTMLDocumentBackend(in_doc=in_doc, path_or_stream=BytesIO(src)).convert()
print(name, [t.text for t in doc.texts], "tables:", len(doc.tables), "pictures:", len(doc.pictures))
Actual
dt_with_list ['Colors', 'palette'] tables: 0 pictures: 0
dt_with_table ['Sizes', 'shirts'] tables: 0 pictures: 0
dt_image_only ['ACME Corp'] tables: 0 pictures: 0
dd_with_list_control ['T', 'D', 'nested'] tables: 0 pictures: 0
Expected
dt_with_list:redandblueare kept, nested under the termColors.dt_with_table: one table.dt_image_only: one picture under a term item, withACME Corpnested under that term.dd_with_list_control: unchanged (the<dd>path already works).
Cause
In docling/backend/html_backend.py, the <dt> branch adds the term with _add_list_item_with_content. That helper leaves nested lists, tables and images out of the term text. The <dd> branch then calls _process_list_item_nested_content for those blocks, but the <dt> branch does not, so they are never added.
Proposed fix
After the term item is created, process the nested content of the <dt> the same way as for <dd>. When the term has no text but holds an image, table or list, create an empty term item to hold it, as the <li> path already does. The change is +14 lines in html_backend.py plus a regression test in tests/test_backend_html.py. The groundtruth for tests/data/html/html_description_list.html does not change.
I used an AI coding assistant (Claude) to find and analyse this; I reproduced it and checked the fix myself.
I've tested a fix with a regression test: https://github.com/chaitanya0305/docling/compare/main...chaitanya0305:docling:fix/html-dt-nested-content. If this is accepted, I'll open the PR straight away.
- Dominant language
- Python
- Stars
- 71k
- Forks
- 5.4k
- Avg merge
- 2d 22h
- Merged PRs (30d)
- 161
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from docling-project/docling
-
Difficulty 2/5 1-3 hours Newbie friendliness 69/100
docling-project/docling#5592 ·
Maintainers usually reply within 2 days
-
`api_image_request` logs and propagates the raw error response body, leaking the request's API key on 401Possibly taken @prassu017 claimed this 7 days ago. Openbug priority:critical
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
docling-project/docling#5486 · 1 comment · 1 reaction ·
Maintainers usually reply within 2 days
-
AFP: export_to_doctags() raises ZeroDivisionError because every page has size 0x0Possibly taken @Krushil-Dhankecha claimed this 12 days ago. Openbug priority:medium
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
docling-project/docling#5355 · 1 comment ·
Maintainers usually reply within 2 days
-
AsciiDoc: thematic breaks and page breaks are kept as text or turned into list itemsPossibly taken @sohailshk claimed this 12 days ago. Openasciidoc bug priority:low
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
docling-project/docling#5331 · 1 comment ·
Maintainers usually reply within 2 days
-
Merged paragraph across pages of different heights: continuation bbox uses the first page's heightPossibly taken @galer1us claimed this 15 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
docling-project/docling#5286 ·
Maintainers usually reply within 2 days
All issues in docling-project/docling
Similar issues
-
Task select patterns with uppercase letters never matchPossibly taken @manobhisriram claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
app: scripts status: backlog type: housekeeping
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
netbox-community/netbox-scripts#239 ·
Maintainers usually reply within 1 day
-
Lambda deploys fail once the bundle grows by about 254 KBPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
developmentseed/titiler-cmr#341 ·
Maintainers usually reply within 1 day
-
Card tables add "..." to every value in a DataFrame column when any value is longer than 30 charactersPossibly taken @omkarbandikatte claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day