Repository navigation
fix(hwp): keep picture captions when converting to DOCX - #2080
Merged
KnifeLemon merged 2 commits intoDec 5, 2026
Merged
Conversation
…2080) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
KnifeLemon
approved these changes
Dec 5, 2026
KnifeLemon
left a comment
Owner
There was a problem hiding this comment.
Thanks, and thanks for the clear reproduction with the bench fixtures. The fix is small and in the right place:
- Reading the caption with
ReadSubListmatches how table captions are already read, so nested paragraphs, tables and the nesting limit all behave the same way. - Holding the caption blocks until
Finishkeeps the host sentence whole, which is what Word readers expect. It also works inside cells, text boxes and headers, since each of those has its ownParagraphBuilder. - Every target that reads through
HwpxReadergets the caption, not only DOCX, which is a good side effect.
Two things to know, neither blocking:
- A caption set to
side="TOP"also comes after the paragraph. Putting it before would mean holding it until the anchor paragraph starts, which is more change than this needs. If a real document shows it, a follow-up can handle it. - Only
piccaptions are read. Rectangles and groups can carry captions too, but pictures are by far the common case.
I pushed a CHANGELOG line under 2.6.0 Fixes (c74681d). Approving. This merges once CI is green.
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.
What changed
Filee exports a floating picture to Word but loses the caption attached to it. When the picture is anchored between words, the caption belongs in its own paragraph after the complete sentence. The HWPX reader now reads the picture’s caption with the existing paragraph-list reader and appends its blocks when the anchor paragraph is complete. Captions become editable Word paragraphs. This also covers HWP → DOCX when rhwp converts the input to HWPX first.
Reproduce
Download either the HWP fixture or the HWPX fixture, then run
filee-cli convert 13_floating_caption.hwpx --to docx(substitute the HWP filename for the other case).Filee 2.5.0 and main at
c0888c0both keep the picture and the two body paragraphs but omit그림 1. 야간 개관 안내. After the change, the DOCX contains the complete host sentence, that caption exactly once, then안내문은 입구에 있다., matching the expected paragraphs.Verification
HwpxReaderTests,DocxWriterTestsandUnhwpLineBreakTests, with the release’s rhwp available. Formatting verification passed for all three changed files.