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:
@@ -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''
|
||||
|
||||
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'']
|
||||
return [_img_link(base_name, filename, idx + 1)]
|
||||
return [f'']
|
||||
|
||||
text = _extract_text(p_elem)
|
||||
|
||||
Reference in New Issue
Block a user