fix: HWP5 multi-TAC paragraph z-order 정합 — composer marker synthesis (closes #991)#995
Closed
jangster77 wants to merge 4 commits into
Closed
fix: HWP5 multi-TAC paragraph z-order 정합 — composer marker synthesis (closes #991)#995jangster77 wants to merge 4 commits into
jangster77 wants to merge 4 commits into
Conversation
…C paragraph z-order 정합
KS X 6101 / HWP5 spec 표 6 분석 결과:
- 확장 컨트롤 (ch=1-3, 11-12, 14-18, 21-23) 은 stream 에 8 wchar,
visual 로 1 char position (placeholder).
- HWP3 parser 는 \u{FFFC} 마커 push (spec 정합).
- HWP5 parser 는 마커 미푸시 → composer 의 line-to-control 매핑 어긋남.
증상 (samples/hwp3-sample16-hwp5.hwp 페이지 18):
- pi=394 의 3 TAC controls (가. 라벨, 다이어그램, 나. 라벨) 가
ls[0]/[1]/[2] 에 분포되어야 함.
- char_offsets=[16,17] (sparse) 로 composer 가 ls[0] 빈 라인 처리.
- 결과: 가. 라벨이 다이어그램 아래 (PDF 정답: 위).
Fix (F2-narrow):
src/renderer/composer.rs 의 compose_paragraph 진입 시 marker synthesis.
좁힘 조건:
- inline_ctrl_count >= 3 (pi=394 패턴)
- n_leading >= 2 (leading char_offsets gap 에 2+ extended ctrl)
- existing_markers < inline_ctrl_count (HWP3 자동 차단)
영향 범위:
- Composer 내부만 (rendering pipeline)
- Editor pipeline (insert_text/save/cursor) 영향 없음 (parser 미변경)
검증:
- cargo test --release --lib: 1297 passed, 0 failed
- 240 sample 페이지 수: 변동 0 건
- HWP5 sample16 p18 시각: PDF 정합 확인 (가. 위, 나. 아래)
- HWP5 page count: 62 (변동 없음)
이전 시도 vs 본 fix:
- F1 (parser 광범위): 9 test fail (editor 영향)
- F1-narrow (ch=11/14): 5 test fail
- F2-wide (composer synth, 조건 없음): 5 test fail
- F2-narrow (3+ TAC + 2+ leading): 0 test fail ✓
잔존:
- HWPX 변종 (sample16-hwp5.hwpx) 은 parser path 다름 — 본 fix 미적용.
edwardkim#942/edwardkim#988 close 영역 (HWPX 포맷 fundamental 한계).
closes edwardkim#991
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
하이퍼-워터폴 절차 보완 — 직전 commit (ad1f20d) 에서 누락한 문서 추가: - mydocs/plans/task_m100_991_impl.md (구현 계획서) - mydocs/working/task_m100_991_stage2.md (Stage 2: F2 후보 결정) - mydocs/working/task_m100_991_stage3.md (Stage 3: 회귀 검증) - mydocs/working/task_m100_991_stage4.md (Stage 4: 시각 검증) 소스 변경 없음 (docs 만). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Owner
|
검토 완료 — merge 수용. devel 에 반영했습니다. 검증 결과
처리
F2-narrow 의 3중 좁힘 가드 설계가 적절했습니다 (F1/F2-wide 5~9 fail → F2-narrow 0 fail). composer-only 격리로 editor/HWP3/HWPX path 무영향인 점도 확인했습니다. 이슈 #991 은 이미 CLOSED 상태이므로 기여 감사합니다. |
Owner
|
devel 반영 완료 (cherry-pick). PR close 합니다. |
edwardkim
pushed a commit
that referenced
this pull request
May 19, 2026
PR #995 검토 §3.3 지적 2건 정정. 동작 완전 불변 (좁힘 3조건·합성 로직 그대로), 중복/죽은 코드만 제거. - (a) first_off/n_leading 중복 계산 제거: offsets 바인딩을 좁힘 가드 앞으로 이동 → 1회 계산 후 본문 재사용 (shadowing 제거) - (b) 빈 paragraph 분기 제거: 좁힘 가드 n_leading<2 가 빈 offsets (n_leading=0) 를 항상 차단 → 도달 불가 죽은 코드. 근거 주석 명시 검증: cargo fmt --check ✅ / cargo test --release --lib 1303 passed 0 failed ✅ (clean-up 전후 통과 동일 → 동작 불변 확인) Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
edwardkim
pushed a commit
that referenced
this pull request
May 19, 2026
edwardkim
pushed a commit
that referenced
this pull request
May 19, 2026
다른 환경의 devel 작업 통합: - Task #993: HWPX→HWP cell contracts + top-aligned cell line positioning - fix(fmt): task 993 diagnostics 포맷 정정 (CI Format check 복구) - fix(clippy): nested format 회피 - test: issue 617 SVG snapshot 갱신 로컬 PR #995 (HWP5 multi-TAC z-order) + 메모리 동기화 분기와 통합. Co-Authored-By: Claude Opus 4.7 (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.
Summary
Root cause (KS X 6101 표 6 분석)
확장 컨트롤 (ch=1-3, 11-12, 14-18, 21-23) 은 stream 에 8 wchar 차지, visual 로 1 char position (placeholder).
→ HWP5 가 sparse text + char_offsets 으로 composer 가 line 별 text 범위 계산 시 어긋남.
pi=394 (HWP5 sample16) 예
```
3 TAC controls + 3 line_segs:
ls[0] ts=0 contains 가. 라벨
ls[1] ts=8 contains 다이어그램
ls[2] ts=18 contains 나. 라벨
HWP5 IR (sparse):
text=" " (2 chars), char_offsets=[16, 17]
composer.utf16_range_to_text_range(0, 8): text [0..0) — 빈!
→ ls[0] 빈 라인 처리 → 가. 라벨 어긋남
```
Fix (F2-narrow)
src/renderer/composer.rs 의 `compose_paragraph` 진입 시 marker synthesis layer 추가:
```rust
fn synthesize_marker_paragraph(para: &Paragraph) -> Option {
// inline-visible extended ctrl count
let inline_ctrl_count = ...; // Header/Footer/Footnote/Endnote/HiddenComment 제외
}
pub fn compose_paragraph(para: &Paragraph) -> ComposedParagraph {
let synth = synthesize_marker_paragraph(para);
let para = synth.as_ref().unwrap_or(para); // shadow
// ... 기존 logic ...
}
```
좁힘 조건
Verification
시도 비교
Residual / 후속
Test plan
🤖 Generated with Claude Code