refactor: HWP 변환을 exe(HWP→HWPX) 단일 경로로 교체, 이미지 경로 URL 인코딩

- hwp.py: COM/pyhwp 제거, HwpToPdfConverter.exe → hwpx 컨버터 재사용으로 단순화
- hwpx.py, hml.py: 이미지 경로의 공백/대괄호 URL 인코딩(%20, %5B, %5D) 추가
  (Obsidian 등 Markdown 뷰어에서 [기본이론] 포함 파일명 이미지 표시 오류 수정)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
minsung
2026-04-30 08:41:20 +09:00
parent 1d40d90242
commit b944a8f526
3 changed files with 46 additions and 185 deletions

View File

@@ -6,6 +6,13 @@ import re
import zipfile
import xml.etree.ElementTree as ET
from pathlib import Path
def _esc_path(s: str) -> str:
return s.replace(' ', '%20').replace('[', '%5B').replace(']', '%5D')
def _img_link(base_name: str, filename: str, idx: int) -> str:
path = f'{_esc_path(base_name)}_images/{_esc_path(filename)}'
return f'![그림 {idx}]({path})'
NS = {
'hp': 'http://www.hancom.co.kr/hwpml/2011/paragraph',
@@ -128,7 +135,7 @@ def _process_para(p_elem, pic_counter: list, id_to_file: dict, base_name: str) -
ref_id = img_elem.get('binaryItemIDRef', '')
filename = id_to_file.get(ref_id, '')
if filename:
return [f'![그림 {idx+1}]({base_name}_images/{filename})']
return [_img_link(base_name, filename, idx + 1)]
return [f'![그림 {idx+1}](그림_{idx+1}.png)']
text = _extract_text(p_elem)