| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- # -*- coding: utf-8 -*-
- """把系统初始化配置指南 Markdown 转成 Word。
- 排版逻辑不在这里重复一遍,直接复用系统集成那套生成器:横向版式、黑体标题套内置
- Heading 样式(Word 导航窗格与自动目录才认得层级)、表格 Table Grid 加表头底色、
- 一级标题前分页、「目录」一节换成 Word 自动目录域。
- """
- from __future__ import annotations
- import importlib.util
- import sys
- from pathlib import Path
- BASE = Path(__file__).resolve().parent
- GENERATOR = BASE.parent / "系统集成" / "_gen_integration_guide_docx.py"
- JOBS = [
- ("Ai-DOP系统初始化配置指南.md", "Ai-DOP系统初始化配置指南.docx", True, True),
- ]
- def load_generator():
- spec = importlib.util.spec_from_file_location("_aidop_docx_generator", GENERATOR)
- if spec is None or spec.loader is None:
- raise SystemExit(f"找不到排版生成器:{GENERATOR}")
- module = importlib.util.module_from_spec(spec)
- sys.modules[spec.name] = module
- spec.loader.exec_module(module)
- return module
- def main():
- gen = load_generator()
- for src_name, out_name, landscape, page_break_before_h1 in JOBS:
- src = BASE / src_name
- out = BASE / out_name
- doc = gen.build_docx(src.read_text(encoding="utf-8"), landscape, page_break_before_h1)
- doc.save(out)
- print(f"OK: {out}")
- if __name__ == "__main__":
- main()
|