Skip to content

feat: add native HWPX document backend#3856

Open
myeolinmalchi wants to merge 3 commits into
docling-project:mainfrom
myeolinmalchi:feat/hwpx-backend
Open

feat: add native HWPX document backend#3856
myeolinmalchi wants to merge 3 commits into
docling-project:mainfrom
myeolinmalchi:feat/hwpx-backend

Conversation

@myeolinmalchi

Copy link
Copy Markdown

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 zipfile and lxml only:

  • Zero new dependencies. lxml is already a core dependency; pyproject.toml and uv.lock are untouched.
  • Registers InputFormat.HWPX for .hwpx (extension-first detection with zip-content confirmation, so generic zips are not misdetected).
  • HwpxDocumentBackend (DeclarativeDocumentBackend) maps OWPML to DoclingDocument: paragraphs, headings (outline levels), lists, tables including merged cells, and pictures.
  • Out of scope for v1 and documented as such: charts, text-box content, header/footer furniture, equations beyond raw-script preservation, and DRM/distribution documents (rejected with a clear error). Legacy binary .hwp is intentionally excluded; see the plan below.
  • Docs updated (index.md, supported_formats.md); test fixtures are MIT-licensed samples with provenance recorded in tests/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 .hwp half 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:

  • Documentation has been updated, if necessary.
  • Examples have been added, if necessary.
  • Tests have been added, if necessary.

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 with colSpan merged 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 cleanly

Groundtruth data was generated with DOCLING_GEN_TEST_DATA=1 and reviewed manually. Test fixtures are MIT-licensed HWPX samples; one minimal fixture is synthesised for outline-heading coverage. Full provenance in tests/data/hwpx/SOURCES.md.

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>
@github-actions

Copy link
Copy Markdown
Contributor

DCO Check Passed

Thanks @myeolinmalchi, all your commits are properly signed off. 🎉

@mergify

mergify Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Merge Protections

🔴 1 of 2 protections blocking · waiting on 👀 reviews

Protection Waiting on
🔴 Require two reviewer for test updates 👀 reviews
🟢 Enforce conventional commit

🔴 Require two reviewer for test updates

Waiting for

  • #approved-reviews-by >= 2
This rule is failing.

When test data is updated, we require two reviewers

  • #approved-reviews-by >= 2

Show 1 satisfied protection

🟢 Enforce conventional commit

Make sure that we follow https://www.conventionalcommits.org/en/v1.0.0/

  • title ~= ^(fix|feat|docs|style|refactor|perf|test|build|ci|chore|revert)(?:\(.+\))?(!)?:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant