pandoc-docx
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePandoc Docx
Pandoc Docx
Prerequisites
前置条件
Ensure Pandoc is installed:
bash
pandoc --version确保已安装Pandoc:
bash
pandoc --versionIf not installed: brew install pandoc (macOS) or apt-get install pandoc (Linux)
如果未安装:macOS使用 brew install pandoc,Linux使用 apt-get install pandoc
undefinedundefinedDirectory Setup
目录设置
Create working directories in your project root:
bash
mkdir -p import export- - Source files to convert
import/ - - Converted output files
export/
在项目根目录创建工作目录:
bash
mkdir -p import export- - 待转换的源文件
import/ - - 转换后的输出文件
export/
Convert to DOCX
转换为DOCX
Basic conversion:
bash
pandoc import/input.md -o export/output.docxCommon options:
- - Apply custom styling
--reference-doc=template.docx - - Generate table of contents
--toc - - Set TOC depth
--toc-depth=2 - - Set document metadata
--metadata="title=My Document"
Use skill's Chinese template:
bash
undefined基础转换命令:
bash
pandoc import/input.md -o export/output.docx常用选项:
- - 应用自定义样式
--reference-doc=template.docx - - 生成目录
--toc - - 设置目录层级
--toc-depth=2 - - 设置文档元数据
--metadata="title=My Document"
使用技能的中文模板:
bash
undefinedPath depends on where skill is installed:
路径取决于技能的安装位置:
- Project local: .agents/skills/pandoc-docx/ (or your skill installation path)
- 项目本地:.agents/skills/pandoc-docx/(或你的技能安装路径)
- Global: ~/.config/skills/pandoc-docx/ (varies by OS and tool)
- 全局:~/.config/skills/pandoc-docx/(因操作系统和工具而异)
pandoc import/input.md -o export/output.docx
--reference-doc=<skill-path>/assets/templates.docx
--reference-doc=<skill-path>/assets/templates.docx
undefinedpandoc import/input.md -o export/output.docx
--reference-doc=<skill-path>/assets/templates.docx
--reference-doc=<skill-path>/assets/templates.docx
undefinedConvert from DOCX
从DOCX转换为其他格式
bash
pandoc import/document.docx -o export/document.md --extract-media=export/images/bash
pandoc import/document.docx -o export/document.md --extract-media=export/images/Custom Templates
自定义模板
- Generate default template:
pandoc --print-default-data-file reference.docx > reference.docx - Edit styles in Word
- Apply:
pandoc import/input.md -o export/output.docx --reference-doc=reference.docx
- 生成默认模板:
pandoc --print-default-data-file reference.docx > reference.docx - 在Word中编辑样式
- 应用模板:
pandoc import/input.md -o export/output.docx --reference-doc=reference.docx
Batch Processing
批量处理
bash
SKILL_PATH="<skill-path>" # Adjust to your skill installation path
for file in import/*.md; do
pandoc "$file" -o "export/$(basename "${file%.md}").docx" \
--reference-doc=$SKILL_PATH/assets/templates.docx
donebash
SKILL_PATH="<skill-path>" # 根据你的技能安装路径调整
for file in import/*.md; do
pandoc "$file" -o "export/$(basename "${file%.md}").docx" \
--reference-doc=$SKILL_PATH/assets/templates.docx
doneResources
资源
- assets/templates.docx - Chinese DOCX template with title numbering and code highlighting
- scripts/convert.sh - Helper script for conversions (see usage below)
- references/pandoc-options.md - Complete option reference and advanced patterns
- assets/templates.docx - 包含标题编号和代码高亮的中文DOCX模板
- scripts/convert.sh - 转换辅助脚本(使用方法如下)
- references/pandoc-options.md - 完整选项参考与进阶用法
Using convert.sh
使用convert.sh
bash
undefinedbash
undefinedRun from project root. Adjust <skill-path> to where skill is installed:
从项目根目录运行。根据技能安装路径调整<skill-path>:
<skill-path>/scripts/convert.sh report.md report.docx
<skill-path>/scripts/convert.sh report.md report.docx
With options
带选项使用
<skill-path>/scripts/convert.sh report.md report.docx --toc
<skill-path>/scripts/convert.sh report.md report.docx --toc
Absolute paths work as usual
绝对路径同样适用
<skill-path>/scripts/convert.sh /path/to/input.md /path/to/output.docx
undefined<skill-path>/scripts/convert.sh /path/to/input.md /path/to/output.docx
undefined