feat: add native HWPX document backend#3856
Open
myeolinmalchi wants to merge 3 commits into
Open
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: 강민석 <minsuk4820@naver.com>
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: 강민석 <minsuk4820@naver.com>
List HWPX in the supported input formats table and the What's new section. Signed-off-by: 강민석 <minsuk4820@naver.com>
Contributor
|
✅ DCO Check Passed Thanks @myeolinmalchi, all your commits are properly signed off. 🎉 |
Contributor
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/
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.