Repository navigation
Conversation
There was a problem hiding this comment.
No issues found across 4 files
Shadow auto-approve: would auto-approve. Bug fix in HTML parsing: previously dropped <details>/<summary> content is now extracted, with tests pinned; low-risk mapping change.
Re-trigger cubic
7b06863 to
67191e5
Compare
|
High — a leading image or block wrapper makes a
Please add summary-specific traversal that preserves the title role for the summary label across leading images and ordinary block wrappers, while keeping the details body and post-summary tail outside the title and avoiding a duplicate title for a nested heading. The regression should assert exact element types/order and two separate chunks; covering link/emphasis and page metadata on the label would also protect the annotations carried by this path. (authored by codex) |
67191e5 to
51dabe8
Compare
|
Good catch, thanks. Fixed in 51dabe8, and rebased onto main since the branch had gone stale.
New tests assert the exact element types and order plus two separate chunks for the icon case, and cover the |
cragwolfe
left a comment
There was a problem hiding this comment.
Finding
- [P1] Preserve heading hierarchy for summary-generated Titles —
unstructured/partition/html/parser.py:475-483.Summary._iter_label_elements()now emits every summary run asTitle, but_ElementAccumulator._category_depth()maps a non-h1–h6Title to depth 0. The sharedset_element_hierarchy()stack then treats each summary as a top-level heading. I reproduced this on the exact head51dabe8436708a28cb1713a90ad7ca00f78805b9:<h2>FAQ</h2><details><summary>Q1</summary><p>A1</p></details><h2>Shipping</h2><p>x</p>produces Q1 withparent_id=Noneinstead of FAQ, and incorrectly assigns Shipping under Q1; nested Outer/Inner summaries are also siblings instead of parent/child. This silently regressesparent_id/section hierarchy for existing headings and affects downstream HTML/ontology/RAG consumers.
Please fix the hierarchy semantics for summary-derived Titles, preserving real heading levels and making nested details/summary relationships explicit, then add regression assertions for parent IDs and category depths (including a heading after a details block and nested details). The current extraction and focused text/type tests do not catch this.
Verification: uv run --locked reproduction against the exact PR head confirmed the incorrect parent IDs; all reported exact-head CI checks were green, but CI does not cover this hierarchy case.
(authored by codex)
## 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. -->
Both tags were mapped to `RemovedBlock`, so `partition_html()` dropped every disclosure widget along with everything inside it. Pages that build their FAQ or documentation out of accordions lost all of their questions and answers, and the caller got a shorter element list rather than an error. `<details>` is an ordinary block container, so it becomes `Flow` like `<div>`. `<summary>` is the widget's heading -- the spec calls it "a summary, caption, or legend for the rest of the contents" -- so it becomes `Heading` and emits a `Title`. That is what the reporter asked for, and it is what makes the fix useful downstream: `chunk_by_title()` opens a new section at each `Title`, so a question stays attached to its own answer instead of blending into its neighbours. `<summary>` was listed twice, under both phrasing and the removed-form group; there is now a single mapping. Resolves Unstructured-IO#3919. Signed-off-by: Rohit Behera <126186063+r0h1tb@users.noreply.github.com>
…pper A <summary> whose label followed an <img> (an expand/collapse chevron) or sat inside a <p> or <div> came out as Text or NarrativeText, because Heading only applies Title to its leading text. chunk_by_title() then saw no boundary and merged that entry into the previous one. Give <summary> its own element class that makes every run of label text a Title, descending into plain wrappers while images, nested headings and the like keep their own types.
A <summary> label is a Title with no heading tag, so it got category_depth 0 and was treated as a top-level heading: it lost the heading above it as its parent, the next h2 was nested under it, and a nested <details> label became its sibling. Place the label one level below h6, plus one per enclosing <details>, so it nests under whatever heading precedes it and ends at the next heading of any level.
51dabe8 to
fbd8e9b
Compare
|
Fixed in fbd8e9b. A summary label now gets One thing I left alone here: a leading Also rebased on main, now 0.27.19. |
cragwolfe
left a comment
There was a problem hiding this comment.
Reviewed 84928e8d367df30c16d936e6e43fa3a15f7f00ec against live main 8150372fc92b771e97b47f1d7c6af00743829972 with GPT Pro, including the complete diff, surrounding code/tests, and author replies. The earlier direct-icon label, plain-wrapper, and simple summary-depth cases are repaired. Three concrete issues remain; this is a nonblocking comment review, not an approval.
[P1] Keep existing later-page text visible in HTML export — unstructured/partition/html/parser.py:1268–1270, with common/metadata.py:122–124 and html/convert.py:263–277.
A page-1 <details><summary>Question?</summary><p>Answer.</p></details> followed by a page-2 paragraph now gives that outside paragraph the summary’s parent_id. Default elements_to_html() groups by page before resolving parents. On page 2 the summary is absent, and the converter excludes children with a non-null parent instead of rendering them as roots. The previously visible outside paragraph disappears; the base discarded the disclosure and exported that paragraph as a root. Both Text and NarrativeText follow this failure path.
Preserve elements whose parents are outside the page-local export set, including their local descendants. Add partition-to-export tests for outside text and answers spanning pages, both ID modes, exact-once output, and unchanged input metadata. The exporter repair in open #4503 is not present here and cannot be assumed landed.
[P1] Preserve the heading chain across a summary icon — unstructured/partition/html/parser.py:503–514, with common/metadata.py:58–81,151–176.
For <h1>FAQ</h1><details><summary><img src="/chevron.svg" alt="">Question?</summary><p>Answer.</p></details><h2>Shipping</h2>, the emitted Image is not an allowed Title child. It pops FAQ from the hierarchy stack. Both the question and the existing Shipping heading become roots; Shipping correctly belonged to FAQ on the base. The depth repair cannot restore an ancestor already discarded by the icon. The author acknowledged this dependency, but #4503 remains open.
Carry an ownership or hierarchy repair in the actual branch/integration. Assert question → FAQ, answer → question, and Shipping → FAQ, including nested icon-led disclosures and both ID modes. If using shared hierarchy rules, assess the effects on other partitioners explicitly.
[P2] Keep the Title boundary when the icon is inside a heading-wrapped label — unstructured/partition/html/parser.py:510–513, with :396–407,1138–1155.
For a second FAQ using <summary><h3><img src="/chevron.svg" alt="">Second question?</h3></summary>, Summary delegates to ordinary Heading traversal. Its initial text run is empty; after the image, the question is processed through the generic tail classifier without Title. That classifier can return Text or NarrativeText, but never Title. The second FAQ therefore supplies no title boundary, and chunk_by_title(..., max_characters=200, combine_text_under_n_chars=0) can combine it with a preceding short FAQ. The separate direct-icon and plain nested-heading tests do not cover their combination.
Preserve the label’s title role through that interruption without duplicating ordinary nested headings or promoting body text. Add exact type/order and two-FAQ chunk assertions, plus page/link/emphasis metadata coverage. Repairing Image hierarchy alone does not fix this missing Title.
Separate maintainer compatibility decision: default extraction now includes open and closed disclosures, shifts later deterministic element IDs, introduces synthetic summary depths of 6 and above, and keeps hierarchy scope until the next heading rather than restoring it on closing a disclosure. Please explicitly accept or revise those public-output policies. #4503 supplies neither implementation nor approval to this branch; any combined head needs review and regression coverage.
All 52 reported checks for this head and the CI, benchmark, CodeQL, and Security workflows succeeded at observation. That is head-only evidence, not execution of an integration with later main. No local tests or reproductions were run; findings are verified source traces. uv.lock and CHANGELOG.md were excluded from review context; release-managed files match the reviewed live main.
(authored by codex)
Signed-off-by: Rohit Behera <126186063+r0h1tb@users.noreply.github.com>
`<summary><h3><img ...>Question?</h3></summary>` was handed to ordinary heading traversal, which classifies text after a nested block without `Title`, so the label became `Text` and `chunk_by_title()` saw no new section. The label traversal now descends into a heading wrapper as it does into a `<p>` or `<div>`. Also add regression tests for the heading chain across a summary icon and for exporting disclosure content whose children are on a later page. Both pass with the hierarchy and export changes from Unstructured-IO#4566 that this branch now merges. Signed-off-by: Rohit Behera <126186063+r0h1tb@users.noreply.github.com>
|
Merged current main and fixed the remaining finding.
The compatibility points are listed under "Output changes" in the description so they can be accepted or revised. |
Problem
<details>and<summary>were both mapped toRemovedBlock, sopartition_html()discarded the whole subtree. On the FAQ page from the issue, every question and answer disappears and the caller gets a shorter element list rather than an error:Fix
<details>is an ordinary block container, so it becomesFlow, like<div>.<summary>gets its ownHeadingsubclass. Its label is emitted as aTitle, including when it follows an expand/collapse icon or sits in a<p>,<div>or<h3>wrapper (also with the icon inside the wrapper), sochunk_by_title()opens a new section at each question and the question stays with its own answer.The label has no heading level of its own, so its
category_depthis one belowh6, plus one per enclosing<details>. That nests it under whatever heading precedes it, ends it at the next heading of any level, and nests an inner<details>label under its parent's.<summary>was also listed twice, under both phrasing and the removed-form group; there is now one mapping.An icon before a label no longer drops the heading before it, and page-grouped HTML export keeps a later page's children of a summary. Both come from #4566, which is on main and merged here.
Output changes
category_depthof 6 and above.</details>. Text after a disclosure therefore has the label as its parent.Tests
New tests in
test_partition.pycover extraction, chunk sections, a<details>with no summary, nesting, icon-led labels (directly and inside an<h3>), wrapper-led labels, annotations and page number on the label, andparent_id/category_depthfor a heading before and after a<details>and for nested<details>. Two more, in both id modes, check the heading chain across icons in nested disclosures (question → FAQ, answer → question, Shipping → FAQ) and that answers and later text on page two export exactly once with unchanged metadata. The<h3>icon cases fail without the last parser change; the heading-chain and export tests fail without #4566.HTML, metadata, chunking, documents, staging, md and docx tests: 1,392 passed before the last change, 1,398 after, with the same 1 failure and 5 collection errors (optional extras not installed here). Ruff lint and format pass.
Codex and Claude Code assisted with implementation and verification.