Skip to content

HWP 5.0 변환본의 메모가 notes.memos·remove_memo에 잡히지 않는다 (MEMO 필드 안 subList 모양) #293

Description

@airmang

무엇이 일어나나

HWP 5.0 파일을 HwpxDocument.open("x.hwp")로 열면 메모가 <hp:fieldBegin type="MEMO"> 안에 메모 글(hp:subList)을 품은 필드로 들어온다. 그런데 메모 API는 이 메모를 보지 못한다.

  • doc.notes.memos → [] (섹션의 hp:memogroup만 읽는다 — 변환본에는 memogroup이 없다)
  • 그래서 doc.notes.remove_memo(...)로도 지울 수 없다
  • conversion_report는 비어 있다(unconverted·dropped 없음) — 변환은 되었는데 읽기 API가 그 모양을 모른다

같은 라이브러리의 HWP 변환기가 쓴 메모를 같은 라이브러리의 메모 API가 읽지 못하는 상태다.

재현

  1. 메모(한/글 "메모 넣기")가 몇 개 있는 HWP 5.0 파일을 준비한다.
  2. python-hwpx 6.6.0:
from hwpx.document import HwpxDocument

doc = HwpxDocument.open("with_memos.hwp")
print(doc.conversion_report)          # unconverted={}, dropped={}
print(len(doc.notes.memos))           # 0

sec = doc.sections[0].element
ns = "{http://www.hancom.co.kr/hwpml/2011/paragraph}"
memo_fields = [f for f in sec.iter(ns + "fieldBegin") if f.get("type") == "MEMO"]
print(len(memo_fields))               # 메모 개수만큼(실측 14)

실측(메모 14개인 HWP 5.0 서식 한 장): fieldBegin type="MEMO" 14개 · 짝 fieldEnd(beginIDRef) 14개 · 각 fieldBegin이 자기 hp:ctrl 안에 있고 메모 글은 fieldBegin의 hp:subList 안. 변환본을 한/글에서 열면 메모가 정상으로 보인다(렌더도 원본 .hwp와 같다).

기대

둘 중 하나(또는 둘 다):

  • 읽기: notes.memos가 MEMO 필드형 메모도 문서 순서대로 돌려주고, remove_memo가 필드 틀(fieldBegin·fieldEnd 컨트롤)과 메모 글을 지운다(앵커 글은 남긴다).
  • 변환: 변환기가 메모를 API가 읽는 모양(hp:memogroup + 앵커)으로 쓴다 — 어느 쪽이 한/글 저장본의 정본 모양인지 실한컴 저장본으로 먼저 확인할 것.

영향

변환본에서 메모를 지우거나 읽어야 하는 쪽(예: 안내 메모가 달린 서식 양식을 조판 바탕으로 쓰는 경우)이 XML을 직접 만져야 한다. 하류에서는 지금 fieldBegin type="MEMO"와 짝 fieldEnd의 hp:ctrl을 직접 지워 우회하고 있다.

  • python-hwpx 6.6.0 (6.5.0은 HWP 변환이 없음)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions