unstructured
ddf44536 - fix(html): extract definition lists instead of discarding them (#4502)

Commit
9 days ago
fix(html): extract definition lists instead of discarding them (#4502) ## Problem `<dl>`, `<dt>` and `<dd>` are mapped to `RemovedBlock`, so `partition_html()` drops definition lists and everything inside them. Documentation gets hit hardest: Sphinx renders every documented function, class and attribute as a `<dl>`, so partitioning an API reference page returns the headings and nothing else. ```python partition_html(text=( '<h1>API reference</h1><dl class="py function"><dt>connect(host, port=5432)</dt>' "<dd><p>Open a connection to the database server.</p></dd></dl>" )) # [Title('API reference')] ``` Glossaries and key/value lists disappear the same way, with no error. ## Fix Map `<dl>` to `ListBlock` and `<dd>` to `ListItemBlock`, which the parser already anticipates: the `ListBlock` docstring says "maybe a `<dl>` element at some point", and the list-depth code already counts `dl` ancestors for `dd` items. `<dt>` becomes a plain `BlockItem`, so a term gets its type from its text like any paragraph. The v2 (ontology) parser already keeps definition lists. ## Tests Two new tests in `test_partition.py`: a glossary (exact element types, text and `category_depth`) and a nested Sphinx-style API reference (all text kept, in order). Without the fix they return `[('Title', 'Glossary', 1)]` and `['API reference']`. The html, chunking, documents, md, text and email tests go from 1201 passed on main to 1203, with no failures. This touches the same mapping table as #4451 (`<details>`/`<summary>`), so whichever lands second will need a small rebase. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/Unstructured-IO/unstructured/pull/4502?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="Review in cubic" src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
Author
Parents
Loading