0.26.0: HWP → HTML on our own reader (replaces pyhwp) + HWP reader fixes - #10
Merged
Merged
Conversation
…ader fixes New documents/legacy/hwp_html.hwp_to_html: one self-contained HTML page straight from HwpFile's model — no DOCX detour, no subprocess. Fonts/sizes/ colors, alignment/margins/hanging indents/line spacing, merges/column widths/cell and table border-fill, pictures, headers/footers, master pages, footnotes, inline objects in place. Safe to inject unsanitized: text and attributes escaped, font names stripped to [\w .-], every CSS rule under .hwp-doc, only png/jpeg/gif/bmp embedded (bmp/tif → png), 64 MB image cap. Reader (shared with hwp_to_docx, so workflow previews get these too): - HwpFile loader (header checks, DocInfo, sections, BinData) split out. - Char-shape positions are raw word positions (controls count 8): mapped, so styles after section/field controls land where the file says. - Hyphen / 묶음 빈칸 / 고정폭 빈칸 are text; surrogate pairs kept whole. - Extended controls paired with their CTRL_HEADER by ctrl id: auto numbers (표 142, number shapes 표 134), 덧말/글자 겹침 text in place, tbl/gso get inline (treat-as-char, 표 70 bit 0) + position, footnotes/endnotes kept. - BinData compression per item (표 18 bits 4-5): png/jpg stored raw were being inflated, failing and silently dropped (11 of 15 pictures in a real press release). - Char shape per 표 35: strike is bits 18-20, underline 1/overline 3, super/subscript — underline kind 2 was read as strike. - Para shape: left/right margin + indent (표 43), distribute align, Korean line break by 어절/글자 (표 44 bit 7). Landscape pages (표 132). - Table border-fill (표 74), caption side (표 73), nested paragraph lists hanging off a paragraph, text-box attachments, per-section headers. - Distribution documents (배포용) opened per Hancom's published spec (seed → MSVC rand → XOR → AES-128 ECB); copy/print protection kept. DRM / certificate-encrypted files refused by name. 256 MB decompression cap. Checked on 31 HWP files (8 format fixtures + 23 real documents incl. government reports, a 10 MB handbook, exams, the HWP spec itself): hwp5html fails on 5 of them, ours on none; text coverage of doc2chunk's chunk text in the HTML is ≥ hwp5html on every file; images/tables ≥. 본 제품은 한글과컴퓨터의 글 문서 파일(.hwp) 공개 문서를 참고하여 개발하였습니다. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
Why
XGEN's document source viewer rendered
.hwpthrough pyhwp'shwp5html(AGPL-3.0). XGEN keeps no AGPL dependency, so this adds an HTML renderer on our own HWP reader. Comparing it against hwp5html on real documents also exposed reader bugs that already affected workflow's HWP preview (DOCX path).New:
documents/legacy/hwp_html.hwp_to_html(content) -> strOne self-contained HTML page built directly from the reader's model (no DOCX detour, no subprocess):
Safe to inject unsanitized (the frontend does):
[\w .-].hwp-docReader fixes (shared with
hwp_to_docx)표 1)Verification
tests/unit/test_hwp_html.py(25 tests, fixtures built per spec)본 제품은 한글과컴퓨터의 글 문서 파일(.hwp) 공개 문서를 참고하여 개발하였습니다.
🤖 Generated with Claude Code