71 lines
2.0 KiB
Markdown
71 lines
2.0 KiB
Markdown
---
|
|
name: edge-word-docx
|
|
description: edge_collector Word/DOCX 文档生成、转换和格式检查规范。用于把 Markdown 方案、部署手册、测试报告、故障报告、用户手册转换为 .docx,或读取、检查、整理已有 DOCX 文档,保持中文字体、标题、表格和验证记录规范。
|
|
---
|
|
|
|
# edge_collector Word/DOCX 处理
|
|
|
|
## 适用场景
|
|
|
|
- 将 `docs/*.md` 转成客户可交付 `.docx`。
|
|
- 生成测试报告、部署手册、故障报告 Word 版。
|
|
- 读取客户提供的 DOCX 模板或说明。
|
|
- 检查 DOCX 中的文字、表格、图片和格式。
|
|
|
|
## 默认中文格式
|
|
|
|
| 内容 | 字体 | 字号 | 行距 |
|
|
|------|------|------|------|
|
|
| 正文 | 宋体 | 小四 12pt | 1.5 倍 |
|
|
| 表格 | 宋体 | 小四 12pt | 1.2 倍 |
|
|
| 一级标题 | 黑体 | 小三 15pt | 1.5 倍 |
|
|
| 二级标题 | 黑体 | 四号 14pt | 1.5 倍 |
|
|
| 三级标题 | 宋体 | 小四 12pt,加粗 | 1.5 倍 |
|
|
|
|
用户提供模板时,模板优先。
|
|
|
|
## 生成流程
|
|
|
|
1. 确认源文档、输出路径、标题、是否需要封面/目录/页码。
|
|
2. 优先从 Markdown 生成结构化 DOCX。
|
|
3. 表格单元格显式设置中文字体和行距。
|
|
4. 图片保留清晰度,图题和正文引用一致。
|
|
5. 生成后解包或转换检查关键格式。
|
|
|
|
## 读取 DOCX
|
|
|
|
优先:
|
|
|
|
```bash
|
|
pandoc --track-changes=all input.docx -o output.md
|
|
```
|
|
|
|
需要检查图片、批注、复杂格式时,再解包查看 OOXML:
|
|
|
|
```bash
|
|
unzip -l input.docx
|
|
unzip -p input.docx word/document.xml
|
|
```
|
|
|
|
## 验证
|
|
|
|
生成后至少检查:
|
|
|
|
```bash
|
|
unzip -p output.docx word/styles.xml | rg "宋体|黑体|w:sz"
|
|
unzip -p output.docx word/document.xml | rg "w:line"
|
|
```
|
|
|
|
如果安装 LibreOffice,可转换 PDF 抽查版式:
|
|
|
|
```bash
|
|
soffice --headless --convert-to pdf output.docx
|
|
```
|
|
|
|
## 注意
|
|
|
|
- 不要把中文正文默认成 Calibri、Arial 或微软雅黑。
|
|
- 不要只检查文件存在,要检查格式和内容。
|
|
- 修改客户提供的 DOCX 时,尽量保留原模板样式。
|
|
- 涉及密钥、账号、内网地址时,交付版要脱敏。
|