This skill helps you create, edit, read, and extract text from Word documents using Python, docx, and associated tooling.
npx playbooks add skill enoch-robinson/agent-skill-collection --skill docx
| 任务 | 推荐方法 |
|------|----------|
| 读取/分析内容 | pandoc 转Markdown |
| 创建新文档 | docx-js (JavaScript) |
| 编辑现有文档 | python-docx 或OOXML |
| 修订追踪 | Redlining 工作流 |
# 基础转换
pandoc document.docx -o output.md
# 保留修订追踪
pandoc --track-changes=all document.docx -o output.md
const { Document, Packer, Paragraph, TextRun } = require('docx');
const doc = new Document({
sections: [{
children: [
new Paragraph({
children: [
new TextRun({ text: "标题", bold: true, size: 32 }),],
}),
new Paragraph({
children: [
new TextRun("正文内容"),
],
}),
],
}],
});
// 导出
Packer.toBuffer(doc).then(buffer => {
fs.writeFileSync("output.docx", buffer);
});
from docx import Document
# 打开文档
doc = Document('existing.docx')
# 添加段落
doc.add_paragraph('新段落内容')
# 添加标题
doc.add_heading('新标题', level=1)
# 添加表格
table = doc.add_table(rows=2, cols=2)
table.cell(0, 0).text = '单元格内容'
# 保存
doc.save('modified.docx')
from docx import Document
doc = Document('document.docx')
full_text = []
for para in doc.paragraphs:
full_text.append(para.text)
print('\n'.join(full_text))
pandoc --track-changes=all file.docx -o current.md<w:ins> 和 <w:del> 标签# DOCX → PDF
soffice --headless --convert-to pdf document.docx
# PDF → 图片
pdftoppm -jpeg -r 150 document.pdf page
# Python
pip install python-docx
# JavaScript
npm install docx
# 命令行工具
sudo apt-get install pandoc libreoffice poppler-utilsWeekly roundup of top Claude Code skills, MCP servers, and AI coding tips.