diff --git a/confluence-mdx/bin/confluence_xhtml_to_markdown.py b/confluence-mdx/bin/confluence_xhtml_to_markdown.py
index 075196f94..4cb6277dc 100755
--- a/confluence-mdx/bin/confluence_xhtml_to_markdown.py
+++ b/confluence-mdx/bin/confluence_xhtml_to_markdown.py
@@ -2039,7 +2039,8 @@ def add_import(self, module_name, condition=True):
else:
self._imports[module_name] = False
- def load_attachments(self, input_dir: str, output_dir: str, public_dir: str) -> None:
+ def load_attachments(self, input_dir: str, output_dir: str, public_dir: str,
+ skip_image_copy: bool = False) -> None:
# Find all ac:image nodes first
ac_image_nodes = self.soup.find_all('ac:image')
attachments: List[Attachment] = []
@@ -2049,7 +2050,8 @@ def load_attachments(self, input_dir: str, output_dir: str, public_dir: str) ->
for node in attachment_nodes:
logging.debug(f"add attachment of {node}")
attachment = Attachment(node, input_dir, output_dir, public_dir)
- attachment.copy_to_destination()
+ if not skip_image_copy:
+ attachment.copy_to_destination()
attachments.append(attachment)
logging.debug(f"attachments: {attachments}")
@@ -2154,6 +2156,8 @@ def main():
help='/public directory path')
parser.add_argument('--attachment-dir',
help='Directory to save attachments (default: output file directory)')
+ parser.add_argument('--skip-image-copy', action='store_true',
+ help='이미지 파일 복사를 생략 (경로만 지정대로 생성)')
parser.add_argument('--log-level',
choices=['debug', 'info', 'warning', 'error', 'critical'],
default='info',
@@ -2218,7 +2222,8 @@ def main():
GLOBAL_LINK_MAPPING = build_link_mapping(page_v1)
converter = ConfluenceToMarkdown(html_content)
- converter.load_attachments(input_dir, output_dir, args.public_dir)
+ converter.load_attachments(input_dir, output_dir, args.public_dir,
+ skip_image_copy=args.skip_image_copy)
markdown_content = converter.as_markdown()
with open(args.output_file, 'w', encoding='utf-8') as f:
diff --git a/confluence-mdx/bin/reverse_sync_cli.py b/confluence-mdx/bin/reverse_sync_cli.py
index 0170c637d..2c52bf02f 100644
--- a/confluence-mdx/bin/reverse_sync_cli.py
+++ b/confluence-mdx/bin/reverse_sync_cli.py
@@ -87,6 +87,15 @@ def _resolve_page_id(ko_mdx_path: str) -> str:
raise ValueError(f"MDX path '{ko_mdx_path}' not found in var/pages.yaml")
+def _resolve_attachment_dir(page_id: str) -> str:
+ """page_id에서 pages.yaml의 path를 조회하여 attachment-dir를 반환."""
+ pages = yaml.safe_load(Path('var/pages.yaml').read_text())
+ for page in pages:
+ if page['page_id'] == page_id:
+ return '/' + '/'.join(page['path'])
+ raise ValueError(f"page_id '{page_id}' not found in var/pages.yaml")
+
+
def _forward_convert(patched_xhtml_path: str, output_mdx_path: str, page_id: str) -> str:
"""patched XHTML 파일을 forward converter로 MDX로 변환한다.
@@ -99,11 +108,13 @@ def _forward_convert(patched_xhtml_path: str, output_mdx_path: str, page_id: str
abs_input = Path(patched_xhtml_path).resolve()
abs_output = Path(output_mdx_path).resolve()
+ attachment_dir = _resolve_attachment_dir(page_id)
result = subprocess.run(
[sys.executable, str(converter), '--log-level', 'warning',
str(abs_input), str(abs_output),
'--public-dir', str(var_dir.parent),
- '--attachment-dir', f'/{page_id}/verify'],
+ '--attachment-dir', attachment_dir,
+ '--skip-image-copy'],
capture_output=True, text=True,
)
if result.returncode != 0: