Skip to content

edwardkim/rhwp

Repository files navigation

rhwp

"모두의 한글" — hwp/hwpx를 읽고 보고 쓸 수 있는 오픈소스 한글 편집기

지금까지 hwp/hwpx는 특정 회사의 전유물이었습니다. rhwp는 공개된 hwp/hwpx 스펙문서를 기반으로, AI에 적합한 방식으로 재구성하고 모두가 참여할 수 있는 워크스페이스를 목표로 합니다.

License: MIT Rust WASM

로드맵

혼자 뼈대를 세우고, 함께 살을 붙이고, 모두의 것으로 완성한다.

0.5 ──── 1.0 ──── 2.0 ──── 3.0
뼈대      조판      협업      완성
단계 방향 전략
0.5 → 1.0 읽기/쓰기 기반 위에 조판 엔진 체계화 핵심 아키텍처를 혼자 견고하게
1.0 → 2.0 AI 조판 파이프라인 위에 커뮤니티 참여 개방 기여 진입 장벽을 낮추는 구조
2.0 → 3.0 커뮤니티가 채운 기능 위에 공공 자산화 한컴 대등 수준 달성

0.5.0까지 혼자 뼈대를 완성하고 공개하는 이유 — 커뮤니티가 붙었을 때 방향이 흔들리지 않으려면 핵심 아키텍처가 먼저 견고해야 합니다.

이정표

v0.5.0 — 뼈대 (현재)

역공학 완성, 읽기/쓰기 기반 구축

  • HWP 5.0 / HWPX 파서, 문단·표·수식·이미지·차트 렌더링
  • 페이지네이션 (다단 분할, 표 행 분할), 머리말/꼬리말/바탕쪽/각주
  • SVG 내보내기 (CLI) + Canvas 렌더링 (WASM/Web)
  • 웹 에디터 + hwpctl 호환 API (30 Actions, Field API)
  • 755+ 테스트

v1.0.0 — 조판 엔진

AI 조판 파이프라인, 뼈대 완성

  • 편집 시 동적 재조판 체계화 (LINE_SEG 재계산 + 페이지네이션 연동)
  • AI 기반 문서 생성/편집 파이프라인
  • 문서 조판 품질 한컴 뷰어 수준 도달

v2.0.0 — 협업

커뮤니티가 기능을 채워가는 단계, 살 붙이기

  • 플러그인/확장 아키텍처, 실시간 협업 편집
  • 다양한 출력 포맷 (PDF, DOCX 등)

v3.0.0 — 완성

한컴과 대등한 수준, 완전한 공공 자산

  • 전체 HWP 기능 커버리지, 접근성(a11y), 모바일 대응
  • 공공기관 실무 투입 가능 수준

자세한 내용은 로드맵 문서를 참조하세요.


Features

Parsing (파싱)

  • HWP 5.0 binary format (OLE2 Compound File)
  • HWPX (Open XML-based format)
  • Sections, paragraphs, tables, textboxes, images, equations, charts
  • Header/footer, master pages, footnotes/endnotes

Rendering (렌더링)

  • Paragraph layout: line spacing, indentation, alignment, tab stops
  • Tables: cell merging, border styles (solid/double/triple/dotted), cell formula calculation
  • Multi-column layout (2-column, 3-column, etc.)
  • Paragraph numbering/bullets
  • Vertical text (영문 눕힘/세움)
  • Header/footer (odd/even page separation)
  • Master pages (Both/Odd/Even, is_extension/overlap)
  • Object placement: TopAndBottom, treat-as-char (TAC), in-front-of/behind text

Equation (수식)

  • Fractions (OVER), square roots (SQRT/ROOT), subscript/superscript
  • Matrices: MATRIX, PMATRIX, BMATRIX, DMATRIX
  • Cases, alignment (EQALIGN), stacking (PILE/LPILE/RPILE)
  • Large operators: INT, DINT, TINT, OINT, SUM, PROD
  • Relations (REL/BUILDREL), limits (lim), long division (LONGDIV)
  • 15 text decorations, full Greek alphabet, 100+ math symbols

Pagination (페이지 분할)

  • Multi-column document column/page splitting
  • Table row-level page splitting (PartialTable)
  • shape_reserved handling for TopAndBottom objects
  • vpos-based paragraph position correction

Output (출력)

  • SVG export (CLI)
  • Canvas rendering (WASM/Web)
  • Debug overlay (paragraph/table boundaries + indices + y-coordinates)

Web Editor (웹 에디터)

  • Text editing (insert, delete, undo/redo)
  • Character/paragraph formatting dialogs
  • Table creation, row/column insert/delete, cell formula
  • hwpctl-compatible API layer (한컴 웹기안기 호환)

hwpctl Compatibility (한컴 호환 레이어)

  • 30 Actions: TableCreate, InsertText, CharShape, ParagraphShape, etc.
  • ParameterSet/ParameterArray API
  • Field API: GetFieldList, PutFieldText, GetFieldText
  • Template data binding support

Quick Start

처음 프로젝트에 참여하는 개발자는 온보딩 가이드를 먼저 읽어보세요. 프로젝트 아키텍처, 디버깅 도구, 개발 워크플로우를 한눈에 파악할 수 있습니다.

Requirements

  • Rust 1.75+
  • Docker (for WASM build)
  • Node.js 18+ (for web editor)

Native Build

cargo build                    # Development build
cargo build --release          # Release build
cargo test                     # Run tests (755+ tests)

WASM Build

WASM 빌드는 Docker를 사용합니다. 플랫폼에 관계없이 동일한 wasm-pack + Rust 툴체인 환경을 보장하기 위함입니다.

cp .env.docker.example .env.docker   # 최초 1회: 환경변수 템플릿 복사
docker compose --env-file .env.docker run --rm wasm

빌드 결과물은 pkg/ 디렉토리에 생성됩니다.

Web Editor

cd rhwp-studio
npm install
npx vite --host 0.0.0.0 --port 7700

Open http://localhost:7700 in your browser.

CLI Usage

SVG Export

rhwp export-svg sample.hwp                         # Export to output/
rhwp export-svg sample.hwp -o my_dir/              # Export to custom directory
rhwp export-svg sample.hwp -p 0                    # Export specific page (0-indexed)
rhwp export-svg sample.hwp --debug-overlay         # Debug overlay (paragraph/table boundaries)

Document Inspection

rhwp dump sample.hwp                  # Full IR dump
rhwp dump sample.hwp -s 2 -p 45      # Section 2, paragraph 45 only
rhwp dump-pages sample.hwp -p 15     # Page 16 layout items
rhwp info sample.hwp                  # File info (size, version, sections, fonts)

Debugging Workflow

  1. export-svg --debug-overlay → Identify paragraphs/tables by s{section}:pi={index} y={coord}
  2. dump-pages -p N → Check paragraph layout list and heights
  3. dump -s N -p M → Inspect ParaShape, LINE_SEG, table properties

No code modification needed for the entire debugging process.

Project Structure

src/
├── main.rs                    # CLI entry point
├── parser/                    # HWP/HWPX file parser
├── model/                     # HWP document model
├── document_core/             # Document core (CQRS: commands + queries)
│   ├── commands/              # Edit commands (text, formatting, tables)
│   ├── queries/               # Queries (rendering data, pagination)
│   └── table_calc/            # Table formula engine (SUM, AVG, PRODUCT, etc.)
├── renderer/                  # Rendering engine
│   ├── layout/                # Layout (paragraph, table, shapes, cells)
│   ├── pagination/            # Pagination engine
│   ├── equation/              # Equation parser/layout/renderer
│   ├── svg.rs                 # SVG output
│   └── web_canvas.rs          # Canvas output
├── serializer/                # HWP file serializer (save)
└── wasm_api.rs                # WASM bindings

rhwp-studio/                   # Web editor (TypeScript + Vite)
├── src/
│   ├── core/                  # Core (WASM bridge, types)
│   ├── engine/                # Input handlers
│   ├── hwpctl/                # hwpctl compatibility layer
│   ├── ui/                    # UI (menus, toolbars, dialogs)
│   └── view/                  # Views (ruler, status bar, canvas)
├── e2e/                       # E2E tests (Puppeteer + Chrome CDP)
│   └── helpers.mjs            # Test helpers (headless/host modes)

mydocs/                        # Project documentation (Korean)
├── orders/                    # Daily task tracking
├── plans/                     # Task plans and implementation specs
├── feedback/                  # Code review feedback
├── tech/                      # Technical documents
└── manual/                    # Manuals and guides

scripts/                       # Build & quality tools
├── metrics.sh                 # Code quality metrics collection
└── dashboard.html             # Quality dashboard with trend tracking

Development with Claude Code

This project is developed using Claude Code (Anthropic's AI coding agent) as a pair programming partner. The entire development process — from task planning to implementation to code review — is documented in mydocs/.

Human-AI Collaboration Protocol

  1. Task Registration: mydocs/orders/yyyymmdd.md
  2. Plan Approval: mydocs/plans/task_{N}.md → review → approval
  3. Implementation: local/task{N} branch → implement → test
  4. Debug Protocol: --debug-overlay + dump-pages + dump for precise paragraph identification
  5. Code Review: 4 rounds of code review documented in mydocs/feedback/

The documentation in mydocs/ serves as an educational resource for AI-assisted software development.

Architecture

graph TB
    HWP[HWP/HWPX File] --> Parser
    Parser --> Model[Document Model]
    Model --> DocumentCore
    DocumentCore --> |Commands| Edit[Edit Operations]
    DocumentCore --> |Queries| Render[Rendering Pipeline]
    Render --> Pagination
    Pagination --> Layout
    Layout --> SVG[SVG Output]
    Layout --> Canvas[Canvas Output]
    DocumentCore --> WASM[WASM API]
    WASM --> Studio[rhwp-studio Web Editor]
    Studio --> hwpctl[hwpctl Compatibility Layer]
Loading

HWPUNIT

  • 1 inch = 7,200 HWPUNIT
  • 1 inch = 25.4 mm
  • 1 HWPUNIT ≈ 0.00353 mm

Contributing

See CONTRIBUTING.md for guidelines.

License

MIT License — Copyright (c) 2025-2026 Edward Kim

About

아래한글 hwp viewer and editor by rust and wasm

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors