Showing
1 changed file
with
6 additions
and
3 deletions
| @@ -228,7 +228,7 @@ def save_document_ir(document_ir, base_name, timestamp): | @@ -228,7 +228,7 @@ def save_document_ir(document_ir, base_name, timestamp): | ||
| 228 | return ir_path | 228 | return ir_path |
| 229 | 229 | ||
| 230 | 230 | ||
| 231 | -def render_markdown(document_ir, base_name, timestamp): | 231 | +def render_markdown(document_ir, base_name, timestamp, ir_path=None): |
| 232 | """ | 232 | """ |
| 233 | 使用 MarkdownRenderer 将 Document IR 渲染为 Markdown 并保存。 | 233 | 使用 MarkdownRenderer 将 Document IR 渲染为 Markdown 并保存。 |
| 234 | 234 | ||
| @@ -239,12 +239,14 @@ def render_markdown(document_ir, base_name, timestamp): | @@ -239,12 +239,14 @@ def render_markdown(document_ir, base_name, timestamp): | ||
| 239 | document_ir: 装订完成的整本 IR | 239 | document_ir: 装订完成的整本 IR |
| 240 | base_name: 文件名片段(来源于报告主题/标题) | 240 | base_name: 文件名片段(来源于报告主题/标题) |
| 241 | timestamp: 时间戳字符串 | 241 | timestamp: 时间戳字符串 |
| 242 | + ir_path: 可选,IR 文件路径,提供时修复后会自动保存 | ||
| 242 | 243 | ||
| 243 | 返回: | 244 | 返回: |
| 244 | Path: 生成的 Markdown 文件路径 | 245 | Path: 生成的 Markdown 文件路径 |
| 245 | """ | 246 | """ |
| 246 | renderer = MarkdownRenderer() | 247 | renderer = MarkdownRenderer() |
| 247 | - markdown_content = renderer.render(document_ir) | 248 | + # 传入 ir_file_path,修复后自动保存 |
| 249 | + markdown_content = renderer.render(document_ir, ir_file_path=str(ir_path) if ir_path else None) | ||
| 248 | 250 | ||
| 249 | output_dir = Path(settings.OUTPUT_DIR) / "md" | 251 | output_dir = Path(settings.OUTPUT_DIR) / "md" |
| 250 | output_dir.mkdir(parents=True, exist_ok=True) | 252 | output_dir.mkdir(parents=True, exist_ok=True) |
| @@ -315,7 +317,8 @@ def main(): | @@ -315,7 +317,8 @@ def main(): | ||
| 315 | ) | 317 | ) |
| 316 | 318 | ||
| 317 | ir_path = save_document_ir(document_ir, base_name, timestamp) | 319 | ir_path = save_document_ir(document_ir, base_name, timestamp) |
| 318 | - md_path = render_markdown(document_ir, base_name, timestamp) | 320 | + # 传入 ir_path,修复后的图表会自动保存到 IR 文件 |
| 321 | + md_path = render_markdown(document_ir, base_name, timestamp, ir_path=ir_path) | ||
| 319 | 322 | ||
| 320 | logger.info("") | 323 | logger.info("") |
| 321 | logger.info("🎉 Markdown装订与渲染完成") | 324 | logger.info("🎉 Markdown装订与渲染完成") |
-
Please register or login to post a comment