GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: v0.3.0 IR S3 — ListItem/Caption/Toc/Field 일괄 도입 · DanMeon/rhwp-python@130f560

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • .github/workflows
    • ci.yml
  • docs
    • implementation/v0.3.0/stages
      • stage-3.md
    • roadmap
      • README.md
  • python/rhwp
    • integrations
      • langchain.py
    • ir
      • __init__.pyi
      • _mapper.py
      • _raw_types.py
      • nodes.py
      • schema.py
      • schema
        • hwp_ir_v1.json
  • src
    • ir.rs
  • tests
    • test_ir_caption.py
    • test_ir_field.py
    • test_ir_footnote.py
    • test_ir_formula.py
    • test_ir_furniture.py
    • test_ir_iter_blocks.py
    • test_ir_list.py
    • test_ir_mapper.py
    • test_ir_picture.py
    • test_ir_roundtrip.py
    • test_ir_schema.py
    • test_ir_schema_export.py
    • test_ir_tables.py
    • test_ir_toc.py
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎.github/workflows/ci.yml‎

Copy file name to clipboardExpand all lines: .github/workflows/ci.yml
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ jobs:
7070
tests/test_ir_iter_blocks.py tests/test_ir_schema_export.py \
7171
tests/test_ir_picture.py tests/test_ir_furniture.py \
7272
tests/test_ir_formula.py tests/test_ir_footnote.py \
73+
tests/test_ir_list.py tests/test_ir_caption.py \
74+
tests/test_ir_toc.py tests/test_ir_field.py \
7375
tests/conftest.py tests/type_check_samples.py
7476
- name: Run pyright (intentional errors — expect 4)
7577
if: matrix.lint
Collapse file

‎docs/implementation/v0.3.0/stages/stage-3.md‎

Copy file name to clipboardExpand all lines: docs/implementation/v0.3.0/stages/stage-3.md
+138Lines changed: 138 additions & 0 deletions
  • Display the source diff
  • Display the rich diff
Large diffs are not rendered by default.
Collapse file

‎docs/roadmap/README.md‎

Copy file name to clipboardExpand all lines: docs/roadmap/README.md
+3-3Lines changed: 3 additions & 3 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ rhwp-python 의 버전별 로드맵 + **활성 spec 인덱스 SSOT**. 모든 spe
44

55
본 문서는 Living — 자유 갱신.
66

7-
## 현재 상태 (2026-04-26)
7+
## 현재 상태 (2026-04-27)
88

99
- **v0.1.0 / v0.1.1** — Frozen, PyPI 배포 완료
1010
- **v0.2.0** — Frozen, Document IR v1 GA (2026-04-25)
11-
- **v0.3.0** — Draft, Phase 2 (IR 확장 + `rhwp-py` CLI) 진행 중
11+
- **v0.3.0** — Draft, Phase 2 (IR 확장 + `rhwp-py` CLI) 진행 중. IR 확장 S1~S3 완료 (S4 Schema GA + CLI/LangChain 마무리 남음)
1212
- **v0.4.0+** — 미착수, Phase 3 이후
1313

1414
## 활성 spec 인덱스
@@ -44,7 +44,7 @@ Phase 1 (v0.1.x) 은 GA 완료로 별도 phase 문서 없음.
4444
|---|---|---|
4545
| v0.1.0 | [implementation/v0.1.0/migration.md](../implementation/v0.1.0/migration.md) | [verification/v0.1.0/spinoff-review.md](../verification/v0.1.0/spinoff-review.md) |
4646
| v0.2.0 | [implementation/v0.2.0/stages/](../implementation/v0.2.0/stages/) (S1~S5) | — |
47-
| v0.3.0 (in-progress) | [implementation/v0.3.0/stages/](../implementation/v0.3.0/stages/) (S1) | — |
47+
| v0.3.0 (in-progress) | [implementation/v0.3.0/stages/](../implementation/v0.3.0/stages/) (S1~S3) | — |
4848

4949
## 원칙
5050

Collapse file

‎python/rhwp/integrations/langchain.py‎

Copy file name to clipboardExpand all lines: python/rhwp/integrations/langchain.py
+77-5Lines changed: 77 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,16 @@
2828
import rhwp
2929
from rhwp.ir.nodes import (
3030
Block,
31+
CaptionBlock,
3132
EndnoteBlock,
33+
FieldBlock,
3234
FootnoteBlock,
3335
FormulaBlock,
36+
ListItemBlock,
3437
ParagraphBlock,
3538
PictureBlock,
3639
TableBlock,
40+
TocBlock,
3741
UnknownBlock,
3842
)
3943

@@ -152,20 +156,27 @@ def _block_to_content_and_meta(block: Block) -> tuple[str, dict[str, Any]]:
152156
"char_end": block.prov.char_end,
153157
}
154158
if isinstance(block, TableBlock):
155-
# ^ HTML 을 page_content 로 — LLM 에 구조 정보 제공. 검색 색인용 평문은 메타로 노출
159+
# ^ HTML 을 page_content 로 — LLM 에 구조 정보 제공. 검색 색인용 평문은 메타로 노출.
160+
# caption 은 v0.2.0 호환 평문 우선, 없으면 caption_block.blocks 평문 폴백
161+
# (PictureBlock 분기와 대칭 — caption 정보 손실 회피).
162+
caption_text = block.caption or (
163+
_caption_plain_text(block.caption_block) if block.caption_block is not None else None
164+
)
156165
return block.html, {
157166
"kind": "table",
158167
"section_idx": block.prov.section_idx,
159168
"para_idx": block.prov.para_idx,
160169
"rows": block.rows,
161170
"cols": block.cols,
162171
"text": block.text,
163-
"caption": block.caption,
172+
"caption": caption_text,
164173
}
165174
if isinstance(block, PictureBlock):
166-
# ^ description (HWP alt-text) 을 page_content 로 — 빈 description 은 lazy_load
167-
# 상위에서 strip 후 skip. image meta 는 RAG 가 picture 를 별도 색인할 때 활용
168-
content = block.description or ""
175+
# ^ caption.blocks 평문 우선 (S3 구조화), 없으면 description (S1 호환).
176+
# image meta 는 RAG 가 picture 를 별도 색인할 때 활용. 빈 content 는
177+
# lazy_load 상위에서 strip 후 skip.
178+
caption_text = _caption_plain_text(block.caption) if block.caption is not None else ""
179+
content = caption_text or (block.description or "")
169180
meta: dict[str, Any] = {
170181
"kind": "picture",
171182
"section_idx": block.prov.section_idx,
@@ -198,6 +209,47 @@ def _block_to_content_and_meta(block: Block) -> tuple[str, dict[str, Any]]:
198209
"marker_section_idx": block.marker_prov.section_idx,
199210
"marker_para_idx": block.marker_prov.para_idx,
200211
}
212+
if isinstance(block, ListItemBlock):
213+
# ^ marker + " " + text 로 합쳐 content — RAG 가 항목 단위로 색인 가능.
214+
# level/enumerated 는 청킹 시 hierarchy 보존 단서로 사용.
215+
content = f"{block.marker} {block.text}".strip()
216+
return content, {
217+
"kind": "list_item",
218+
"section_idx": block.prov.section_idx,
219+
"para_idx": block.prov.para_idx,
220+
"level": block.level,
221+
"enumerated": block.enumerated,
222+
}
223+
if isinstance(block, CaptionBlock):
224+
# ^ 단독 CaptionBlock 은 거의 없음 (Picture/Table 자식). 명시적으로 body 에
225+
# 넣은 사용자 경로만 — direction 메타로 노출.
226+
return _caption_plain_text(block), {
227+
"kind": "caption",
228+
"section_idx": block.prov.section_idx,
229+
"para_idx": block.prov.para_idx,
230+
"direction": block.direction,
231+
}
232+
if isinstance(block, TocBlock):
233+
# ^ entries 의 text 들을 개행 결합. v0.3.0 entries 는 빈 리스트가 일반적
234+
# (TOC entry 추출은 v0.4.0+) — 빈 content 는 lazy_load 상위에서 skip.
235+
toc_text = "\n".join(e.text for e in block.entries if e.text)
236+
return toc_text, {
237+
"kind": "toc",
238+
"section_idx": block.prov.section_idx,
239+
"para_idx": block.prov.para_idx,
240+
"entry_count": len(block.entries),
241+
}
242+
if isinstance(block, FieldBlock):
243+
# ^ cached_value 가 있으면 그것이 content (예: 자동 날짜). raw_instruction 은
244+
# round-trip 보존용으로 메타에. v0.3.0 은 cached_value 가 항상 None 이므로
245+
# 대부분 빈 content — lazy_load 상위에서 skip 됨.
246+
return block.cached_value or "", {
247+
"kind": "field",
248+
"section_idx": block.prov.section_idx,
249+
"para_idx": block.prov.para_idx,
250+
"field_kind": block.field_kind,
251+
"raw_instruction": block.raw_instruction,
252+
}
201253
# 새 Block variant 가 추가되면 그 variant 의 elif 를 이 assert 보다 위에 먼저
202254
# 추가해야 한다. 그러지 않으면 AssertionError 로 fail-fast (silent fallback 방지)
203255
assert isinstance(block, UnknownBlock)
@@ -206,3 +258,23 @@ def _block_to_content_and_meta(block: Block) -> tuple[str, dict[str, Any]]:
206258
"section_idx": block.prov.section_idx,
207259
"para_idx": block.prov.para_idx,
208260
}
261+
262+
263+
def _caption_plain_text(caption: CaptionBlock) -> str:
264+
"""CaptionBlock.blocks 의 텍스트 표현을 개행 결합 (S3 신규 헬퍼).
265+
266+
포함 대상: ParagraphBlock.text + FormulaBlock.text_alt|script + FieldBlock.cached_value.
267+
캡션 안의 수식·필드도 평문 흐름의 일부 (spec § 5 "캡션 안의 인라인 수식·필드도
268+
자연스럽게 표현") — RAG 색인에 자연 포함. 표/그림 등 구조 블록은 별도 색인.
269+
"""
270+
parts: list[str] = []
271+
for b in caption.blocks:
272+
if isinstance(b, ParagraphBlock) and b.text:
273+
parts.append(b.text)
274+
elif isinstance(b, FormulaBlock):
275+
text = b.text_alt or b.script
276+
if text:
277+
parts.append(text)
278+
elif isinstance(b, FieldBlock) and b.cached_value:
279+
parts.append(b.cached_value)
280+
return "\n".join(parts)
Collapse file

‎python/rhwp/ir/__init__.pyi‎

Copy file name to clipboardExpand all lines: python/rhwp/ir/__init__.pyi
+24Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ from rhwp.ir.nodes import (
66
from rhwp.ir.nodes import (
77
Block as Block,
88
)
9+
from rhwp.ir.nodes import (
10+
CaptionBlock as CaptionBlock,
11+
)
912
from rhwp.ir.nodes import (
1013
DocumentMetadata as DocumentMetadata,
1114
)
@@ -15,6 +18,12 @@ from rhwp.ir.nodes import (
1518
from rhwp.ir.nodes import (
1619
EndnoteBlock as EndnoteBlock,
1720
)
21+
from rhwp.ir.nodes import (
22+
FieldBlock as FieldBlock,
23+
)
24+
from rhwp.ir.nodes import (
25+
FieldKind as FieldKind,
26+
)
1827
from rhwp.ir.nodes import (
1928
FootnoteBlock as FootnoteBlock,
2029
)
@@ -33,6 +42,9 @@ from rhwp.ir.nodes import (
3342
from rhwp.ir.nodes import (
3443
InlineRun as InlineRun,
3544
)
45+
from rhwp.ir.nodes import (
46+
ListItemBlock as ListItemBlock,
47+
)
3648
from rhwp.ir.nodes import (
3749
ParagraphBlock as ParagraphBlock,
3850
)
@@ -54,6 +66,12 @@ from rhwp.ir.nodes import (
5466
from rhwp.ir.nodes import (
5567
TableCell as TableCell,
5668
)
69+
from rhwp.ir.nodes import (
70+
TocBlock as TocBlock,
71+
)
72+
from rhwp.ir.nodes import (
73+
TocEntryBlock as TocEntryBlock,
74+
)
5775
from rhwp.ir.nodes import (
5876
UnknownBlock as UnknownBlock,
5977
)
@@ -73,15 +91,19 @@ from rhwp.ir.schema import (
7391
__all__ = [
7492
"CURRENT_SCHEMA_VERSION",
7593
"Block",
94+
"CaptionBlock",
7695
"DocumentMetadata",
7796
"DocumentSource",
7897
"EndnoteBlock",
98+
"FieldBlock",
99+
"FieldKind",
79100
"FootnoteBlock",
80101
"FormulaBlock",
81102
"Furniture",
82103
"HwpDocument",
83104
"ImageRef",
84105
"InlineRun",
106+
"ListItemBlock",
85107
"ParagraphBlock",
86108
"PictureBlock",
87109
"Provenance",
@@ -91,6 +113,8 @@ __all__ = [
91113
"Section",
92114
"TableBlock",
93115
"TableCell",
116+
"TocBlock",
117+
"TocEntryBlock",
94118
"UnknownBlock",
95119
"export_schema",
96120
"load_schema",

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.