一键导入
docx-to-md
Word 文档转 Markdown。Use when (1) 将 .docx 转换为 .md, (2) 提取 Word 文档内容, (3) 批量转换文档, (4) 保留格式和图片, (5) 自动化文档处理
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Word 文档转 Markdown。Use when (1) 将 .docx 转换为 .md, (2) 提取 Word 文档内容, (3) 批量转换文档, (4) 保留格式和图片, (5) 自动化文档处理
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Complete software development lifecycle from requirements to deployment. Use when (1) starting a new project from scratch, (2) need structured end-to-end development process, (3) require comprehensive documentation and quality gates at each phase.
专业的AI Agent(AI Agents)顾问助手,探索 AI Agent 框架和应用。当用户询问以下问题时使用:(1) 技术选型和对比 (2) 使用指南和最佳实践 (3) 问题诊断和解决 (4) 资源推荐 (5) 常见问题解答
Comprehensive CV learning assistant. Use when studying image processing, object detection, segmentation, or any CV tasks. Helps with algorithm understanding, implementation, and model optimization.
Comprehensive DL learning assistant. Use when studying neural networks, CNN, RNN, LSTM, Transformer, or any DL architectures. Helps with network design, training strategies, debugging, and optimization techniques.
Comprehensive LLM learning assistant. Use when studying transformer architecture, attention mechanisms, pre-training, fine-tuning, or prompt engineering. Helps with understanding LLM principles and practical applications.
Comprehensive ML learning assistant. Use when studying supervised learning, unsupervised learning, regression, classification, clustering, or any ML concepts. Helps with algorithm understanding, implementation guidance, model evaluation, and practical applications.
| name | docx-to-md |
| description | Word 文档转 Markdown。Use when (1) 将 .docx 转换为 .md, (2) 提取 Word 文档内容, (3) 批量转换文档, (4) 保留格式和图片, (5) 自动化文档处理 |
Mammoth is the recommended tool:
CRITICAL: Only convert format, never modify content.
import mammoth
from pathlib import Path
def docx_to_md_mammoth(docx_path: Path, md_path: Path):
"""
Convert DOCX to Markdown using mammoth.
CRITICAL: This function only converts format.
It does NOT modify any content, titles, or text.
"""
with open(docx_path, 'rb') as docx_file:
result = mammoth.convert_to_markdown(docx_file)
md_path.write_text(result.value, encoding='utf-8')
# Print warnings
for message in result.messages:
print(f"Warning: {message}")
return md_path
# Install mammoth
uv add mammoth
from pathlib import Path
import mammoth
def batch_convert(input_dir: Path, output_dir: Path):
"""Convert all DOCX files in directory."""
output_dir.mkdir(parents=True, exist_ok=True)
for docx_file in input_dir.glob('*.docx'):
if docx_file.name.startswith('~$'): # Skip temp files
continue
md_file = output_dir / f"{docx_file.stem}.md"
with open(docx_file, 'rb') as f:
result = mammoth.convert_to_markdown(f)
md_file.write_text(result.value, encoding='utf-8')
print(f"✓ Converted: {docx_file.name} -> {md_file.name}")
import subprocess
from pathlib import Path
def convert_with_images(docx_path: Path, output_dir: Path):
"""Convert DOCX and organize images."""
md_path = output_dir / f"{docx_path.stem}.md"
images_dir = output_dir / 'images'
# Convert
subprocess.run([
'pandoc',
str(docx_path),
'-o', str(md_path),
'--extract-media', str(images_dir)
])
# Update image paths in markdown
content = md_path.read_text(encoding='utf-8')
content = content.replace('](media/', '](images/')
md_path.write_text(content, encoding='utf-8')
return md_path
def convert_lab_template(docx_path: Path, output_path: Path):
"""Convert lab answer document with specific formatting."""
# Convert
subprocess.run([
'pandoc',
str(docx_path),
'-o', str(output_path),
'--wrap=none',
'--atx-headers'
])
# Post-process: Add front matter
content = output_path.read_text(encoding='utf-8')
front_matter = """---
title: Lab Assignment
author: Your Name
date: 2026-01-22
---
"""
output_path.write_text(front_matter + content, encoding='utf-8')
def insert_screenshots(md_path: Path, images_dir: Path):
"""Automatically insert screenshots into markdown."""
content = md_path.read_text(encoding='utf-8')
# Find all image files
images = sorted(images_dir.glob('*.png'))
# Insert images at appropriate locations
for i, img in enumerate(images, 1):
marker = f"<!-- INSERT_IMAGE_{i} -->"
if marker in content:
img_markdown = f"})\n"
content = content.replace(marker, img_markdown)
md_path.write_text(content, encoding='utf-8')
# Install mammoth
uv add mammoth
Images not extracted → Mammoth converts images to base64 embedded in markdown
Chinese characters garbled → Ensure UTF-8 encoding when writing file
Tables broken → Mammoth handles simple tables, complex tables may need manual adjustment
Formatting lost → Mammoth preserves basic formatting (bold, italic, headings, lists)
Temp files (~$*.docx) → Skip files starting with ~$ in batch processing
Use provided scripts for common tasks:
# Convert single file
uv run python .skills/dev-docx_to_md/scripts/convert_docx_mammoth.py input.docx output.md
# Batch convert
uv run python .skills/dev-docx_to_md/scripts/batch_convert.py input_dir/ output_dir/
For detailed examples: See references/examples.md
For pandoc filters: See references/filters.md
For troubleshooting: See references/troubleshooting.md
# Install
uv add mammoth
# Convert single file (Python)
uv run python -c "import mammoth; print(mammoth.convert_to_markdown(open('input.docx', 'rb')).value)" > output.md
# Or use helper script
uv run python .skills/dev-docx_to_md/scripts/convert_docx_mammoth.py input.docx output.md