Skip to content

feat: Phase 2 — LineSegment 레이아웃 엔진 (flat_text + layout_text + layout_line_segment)#168

Merged
ohah merged 3 commits intomainfrom
feat/doc-html-layout-phase2-lineseg
Mar 18, 2026
Merged

feat: Phase 2 — LineSegment 레이아웃 엔진 (flat_text + layout_text + layout_line_segment)#168
ohah merged 3 commits intomainfrom
feat/doc-html-layout-phase2-lineseg

Conversation

@ohah
Copy link
Copy Markdown
Owner

@ohah ohah commented Mar 18, 2026

Summary

doc_to_html 레이아웃 엔진 Phase 2: 핵심 텍스트 렌더링 + 라인 세그먼트 배치

flat_text.rs — Run[] → flat 구조 어댑터

  • extract_flat_text(): Paragraph.runs[] → (text, char_shapes[], text_len)
  • find_char_shape_at(): binary search 위치별 조회
  • 테스트 3개

layout_text.rs — CharShape-segmented 텍스트 렌더러

  • render_layout_text(): flat text → <span class="hrt cs{N}"> HTML
  • convert_consecutive_spaces(): 공백 →   변환
  • apply_inline_styles(): italic/underline/strikethrough/super/sub
  • 테스트 2개

layout_line_segment.rs — hls div 절대 좌표 배치

  • render_line_segments(): LineSegmentInfo[] + flat text → hls div HTML
  • mm 절대 좌표 (top/left/height/width)
  • 빈 세그먼트 스킵, CharShape 범위 필터링
  • 테스트 2개

Test plan

  • cargo test — 전체 workspace 0 FAILED
  • flat_text 테스트 3개 + layout_text 테스트 2개 + layout_line_segment 테스트 2개

🤖 Generated with Claude Code

ohah and others added 3 commits March 18, 2026 19:27
doc_html/flat_text.rs:
- extract_flat_text(): Paragraph.runs[] → (text, char_shapes[], text_len)
- find_char_shape_at(): binary search로 위치별 char_shape_id 조회
- 테스트 3개 (simple text, tab, char_shape lookup)

Run 트리 → flat 구조 변환으로 old viewer의 LineSegment 렌더러가
Document 모델과 호환되는 데이터를 받을 수 있게 함.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
doc_html/layout_text.rs:
- render_layout_text(): flat text + FlatCharShapeInfo[] → <span class="hrt cs{N}"> HTML
- convert_consecutive_spaces(): leading/연속/trailing 공백 → &nbsp; 변환
- apply_inline_styles(): italic/underline/strikethrough/super/sub 인라인 태그
- 탭 문자 → htC span 변환
- 테스트 2개 (공백 변환, 기본 렌더링)

old viewer의 text.rs와 동일한 출력을 Document 모델에서 생성.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
doc_html/layout_line_segment.rs:
- render_line_segments(): LineSegmentInfo[] + flat text → hls div HTML
  각 줄을 mm 절대 좌표로 배치 (top/left/height/width)
- 빈 세그먼트 스킵 (flags.is_empty_segment)
- CharShape 구간을 세그먼트 범위로 필터링/오프셋 조정
- 테스트 2개 (빈 입력, 단일 줄)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@ohah ohah added the enhancement New feature or request label Mar 18, 2026
@ohah ohah self-assigned this Mar 18, 2026
@ohah ohah merged commit d6ba94a into main Mar 18, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant