fix(html): extract <details>/<summary> content instead of discarding it

R0
11d ago
+273-6

Problem

<details> and <summary> were both mapped to RemovedBlock, so partition_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:

>>> partition_html(text="<h1>Support FAQ</h1>"
...   "<details><summary>Which Bluetooth profiles are supported?</summary>"
...   "<p>Your device supports A2DP and HFP profiles.</p></details>")
[<Title 'Support FAQ'>]          # both the question and the answer are gone

Fix

<details> is an ordinary block container, so it becomes Flow, like <div>.

<summary> gets its own Heading subclass. Its label is emitted as a Title, including when it follows an expand/collapse icon or sits in a <p>/<div> wrapper, so chunk_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_depth is one below h6, 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.

Tests

New tests in test_partition.py cover extraction, chunk sections, a <details> with no summary, nesting, icon- and wrapper-led labels, annotations and page number on the label, and parent_id/category_depth for a heading before and after a <details> and for nested <details>. The hierarchy tests fail without the depth change (parent_id is None).

partition/html, partition/common, documents and chunking: 1114 passed before, 1117 after, 40 skipped both times. test_common.py and chunking/test_basic.py can't be collected here without the extras, same on main. Ruff is clean.

Rebased on main, version 0.27.19.