Repository navigation
feat: add native HWPX document backend - #3856
myeolinmalchi wants to merge 3 commits into
Conversation
Add HwpxDocumentBackend, a dependency-free backend for the Korean Hangul Word Processor XML format (HWPX / OWPML, KS X 6101). HWPX is a ZIP container of OWPML XML, analogous to DOCX, parsed natively with the standard-library zipfile plus the already-required lxml. The backend maps paragraphs (merged run text), outline headings, numbered/bulleted list items, tables with merged cells, embedded raster pictures, footnotes/endnotes, and Hancom equation scripts onto a DoclingDocument. The legacy binary .hwp (OLE/CFB) format is reported as unsupported. Register InputFormat.HWPX with its extension and mimetypes, add extension-first plus content-confirm (application/hwp+zip marker) detection, and wire the default format option into the converter and CLI. Signed-off-by: 강민석 <[email protected]>
Add tests for the HWPX backend: format detection (extension and content-confirm), an end-to-end groundtruth regression over all fixtures, and targeted assertions for paragraph text, heading levels, table grid dimensions with a merged-cell span, list items, footnotes, equation scripts, embedded pictures, and clean failure on non-HWPX inputs. Fixtures are real MIT-licensed HWPX documents from the rhwp sample corpus, one per exercised element class, plus a synthesised outline-heading fixture; provenance and licensing are recorded in tests/data/hwpx/SOURCES.md. Signed-off-by: 강민석 <[email protected]>
List HWPX in the supported input formats table and the What's new section. Signed-off-by: 강민석 <[email protected]>
|
✅ DCO Check Passed Thanks @myeolinmalchi, all your commits are properly signed off. 🎉 |
Merge Protections🔴 1 of 2 protections blocking · waiting on 👀 reviews
🔴 Require two reviewer for test updatesWaiting for
This rule is failing.When test data is updated, we require two reviewers
Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Merge Protections🔴 1 of 2 protections blocking · waiting on 👀 reviews
🔴 Require two reviewer for test updatesWaiting for
This rule is failing.When test data is updated, we require two reviewers
Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
1 similar comment
Merge Protections🔴 1 of 2 protections blocking · waiting on 👀 reviews
🔴 Require two reviewer for test updatesWaiting for
This rule is failing.When test data is updated, we require two reviewers
Show 1 satisfied protection🟢 Enforce conventional commitMake sure that we follow https://www.conventionalcommits.org/en/v1.0.0/
|
|
Thanks for splitting this up. HWPX first with zero new dependencies looks like the right first step. I maintain OpenDocKit, an MIT Python converter that reads HWP/HWPX, and most of what I know about the format came from files breaking. I read through 1. Inline elements inside <hp:t>성명<hp:tab/>홍길동<hp:lineBreak/>연락처</hp:t>comes out as 2. Deleted text from tracked changes is kept. Hangul leaves the deleted text in place between <hp:t>예산 <hp:deleteBegin Id="1"/>1,200<hp:deleteEnd Id="1"/>1,450 백만원</hp:t>becomes 3. Table and picture captions are lost. A caption is in 4. Nested tables are flattened into the parent cell. 5. Ruby text and composed characters disappear. 6. Pictures inside grouped objects are dropped without a placeholder. On the binary Our tests build each of these cases in memory ( |
Summary
Adds a native input backend for HWPX documents (Korean Hangul Word Processor XML format, OWPML / KS X 6101), the first half of #3602.
HWPX is a zip+XML container, structurally analogous to DOCX, so it is parsed natively with
zipfileandlxmlonly:lxmlis already a core dependency;pyproject.tomlanduv.lockare untouched.InputFormat.HWPXfor.hwpx(extension-first detection with zip-content confirmation, so generic zips are not misdetected).HwpxDocumentBackend(DeclarativeDocumentBackend) maps OWPML toDoclingDocument: paragraphs, headings (outline levels), lists, tables including merged cells, and pictures..hwpis intentionally excluded; see the plan below.index.md,supported_formats.md); test fixtures are MIT-licensed samples with provenance recorded intests/data/hwpx/SOURCES.md.Relation to #3602 (please do not auto-close)
Part of #3602. This PR covers the XML half of the request with no dependency risk. The binary
.hwphalf needs a real parser and is planned as a follow-up on top of rhwp (MIT Rust HWP parser), where I have an implementation PR for a versioned DocLang v0.6 export in review: edwardkim/rhwp#3132. Feedback on the preferred integration shape for that follow-up (CLI subprocess like the Tesseract OCR engine, or an optional binding) is welcome.Issue resolved by this Pull Request:
Part of #3602 (HWPX only; binary HWP remains open)
Checklist:
Validation
uv run pytest tests/test_backend_hwpx.py— 14 passed (format detection for path and stream inputs, e2e conversion with groundtruth verification, heading levels, table withcolSpanmerged cells, list items, picture, footnote, formula script preservation)uv run pytest tests/test_input_doc.py— 9 passed (no regression in existing format detection)make validate— all hooks pass cleanlyGroundtruth data was generated with
DOCLING_GEN_TEST_DATA=1and reviewed manually. Test fixtures are MIT-licensed HWPX samples; one minimal fixture is synthesised for outline-heading coverage. Full provenance intests/data/hwpx/SOURCES.md.