演示文稿创建、编辑和分析。当 Claude 需要处理演示文稿(.pptx 文件)时使用,包括:(1) 创建新演示文稿,(2) 修改或编辑内容,(3) 处理版式,(4) 添加批注或演讲者备注,或其他任何演示文稿任务
npx skills add https://github.com/LeastBit/Claude_skills_zh-CN --skill pptx
用户可能会要求您创建、编辑或分析 .pptx 文件的内容。.pptx 文件本质上是一个包含 XML 文件和其他资源的 ZIP 压缩包,您可以读取或编辑。不同的任务有不同的工具和工作流程可用。
如果您只需要读取演示文稿的文本内容,应将文档转换为 markdown:
# 将文档转换为 markdown
python -m markitdown path-to-file.pptx
您需要原始 XML 访问来处理:批注、演讲者备注、幻灯片版式、动画、设计元素和复杂格式。对于这些功能,您需要解压演示文稿并读取其原始 XML 内容。
python ooxml/scripts/unpack.py <office_file> <output_dir>
注意:unpack.py 脚本位于相对于项目根目录的 skills/pptx/ooxml/scripts/unpack.py。如果脚本不在此路径,请使用 find . -name "unpack.py" 来定位它。
ppt/presentation.xml - 主演示文稿元数据和幻灯片引用ppt/slides/slide{N}.xml - 单个幻灯片内容(slide1.xml、slide2.xml 等)ppt/notesSlides/notesSlide{N}.xml - 每个幻灯片的演讲者备注ppt/comments/modernComment_*.xml - 特定幻灯片的批注ppt/slideLayouts/ - 幻灯片版式模板ppt/slideMasters/ - 母版幻灯片模板ppt/theme/ - 主题和样式信息ppt/media/ - 图片和其他媒体文件当提供了要模仿的示例设计时:始终先使用以下方法分析演示文稿的排版和颜色:
ppt/theme/theme1.xml 中的颜色(<a:clrScheme>)和字体(<a:fontScheme>)ppt/slides/slide1.xml 中的实际字体使用(<a:rPr>)和颜色<a:solidFill>、<a:srgbClr>)和字体引用从头开始创建新 PowerPoint 演示文稿时,使用 html2pptx 工作流程将 HTML 幻灯片转换为具有精确定位的 PowerPoint。
关键:在创建任何演示文稿之前,分析内容并选择适当的设计元素:
要求:
创造性地选择颜色:
示例调色板(用于激发创意 - 选择一个、调整它或创建自己的):
10. 黑与金:金色(#BF9A4A)、黑色(#000000)、奶油(#F4F6F6)
11. 鼠尾草与赤陶:鼠尾草(#87A96B)、赤陶(#E07A5F)、奶油(#F4F1DE)、炭灰(#2C2C2C)
12. 炭灰与红:炭灰(#292929)、红色(#E33737)、浅灰(#CCCBCB)
13. 活力橙:橙色(#F96D00)、浅灰(#F2F2F2)、炭灰(#222831)
14. 森林绿:黑色(#191A19)、绿色(#4E9F3D)、深绿(#1E5128)、白色(#FFFFFF)
15. 复古彩虹:紫色(#722880)、粉色(#D72D51)、橙色(#EB5C18)、琥珀(#F08800)、金色(#DEB600)
16. 复古大地:芥末(#E3B448)、鼠尾草(#CBD18F)、森林绿(#3A6B35)、奶油(#F4F1DE)
17. 海岸玫瑰:老玫瑰(#AD7670)、海狸(#B49886)、蛋壳(#F3ECDC)、灰绿(#BFD5BE)
18. 橙与青绿:浅橙(#FC993E)、灰青绿(#667C6F)、白色(#FCFCFC)
几何图案:
边框和框架处理:
排版处理:
图表和数据样式:
布局创新:
背景处理:
创建带图表或表格的幻灯片时:
html2pptx.md,从头到尾。阅读此文件时切勿设置任何范围限制。 在开始创建演示文稿之前,阅读完整文件内容以了解详细语法、关键格式规则和最佳实践。<p>、<h1>-<h6>、<ul>、<ol> 处理所有文本内容class="placeholder"(渲染灰色背景以便可见)html2pptx.js 库的 JavaScript 文件,将 HTML 幻灯片转换为 PowerPoint 并保存演示文稿html2pptx() 函数处理每个 HTML 文件pptx.writeFile() 保存演示文稿python scripts/thumbnail.py output.pptx workspace/thumbnails --cols 4编辑现有 PowerPoint 演示文稿中的幻灯片时,您需要使用原始 Office Open XML(OOXML)格式。这涉及解压 .pptx 文件、编辑 XML 内容,然后重新打包。
ooxml.md(约 500 行),从头到尾。阅读此文件时切勿设置任何范围限制。 在编辑任何演示文稿之前,阅读完整文件内容以获取有关 OOXML 结构和编辑工作流程的详细指导。python ooxml/scripts/unpack.py <office_file> <output_dir>ppt/slides/slide{N}.xml 和相关文件)python ooxml/scripts/validate.py <dir> --original <file>python ooxml/scripts/pack.py <input_directory> <office_file>当您需要创建遵循现有模板设计的演示文稿时,您需要复制和重新排列模板幻灯片,然后替换占位符内容。
python -m markitdown template.pptx > template-content.mdtemplate-content.md:阅读整个文件以了解模板演示文稿的内容。阅读此文件时切勿设置任何范围限制。python scripts/thumbnail.py template.pptxtemplate-inventory.md,包含: # 模板清单分析
**总幻灯片数:[count]**
**重要:幻灯片从 0 开始索引(第一张幻灯片 = 0,最后一张幻灯片 = count-1)**
## [类别名称]
- 幻灯片 0:[版式代码(如有)] - 描述/用途
- 幻灯片 1:[版式代码] - 描述/用途
- 幻灯片 2:[版式代码] - 描述/用途
[... 每个幻灯片都必须单独列出其索引 ...]
outline.md,包含内容和利用可用设计的模板映射 # 要使用的模板幻灯片(0 基索引)
# 警告:验证索引在范围内!有 73 张幻灯片的模板索引为 0-72
# 映射:大纲中的幻灯片编号 -> 模板幻灯片索引
template_mapping = [
0, # 使用幻灯片 0(标题/封面)
34, # 使用幻灯片 34(B1:标题和正文)
34, # 再次使用幻灯片 34(复制用于第二个 B1)
50, # 使用幻灯片 50(E1:引用)
54, # 使用幻灯片 54(F2:结束语+文本)
]
rearrange.py 复制、重新排序和删除幻灯片:scripts/rearrange.py 脚本创建具有所需顺序幻灯片的新演示文稿: python scripts/rearrange.py template.pptx working.pptx 0,34,34,50,52
inventory.py 脚本提取所有文本: python scripts/inventory.py working.pptx text-inventory.json
{
"slide-0": {
"shape-0": {
"placeholder_type": "TITLE", // 或非占位符为 null
"left": 1.5, // 位置(英寸)
"top": 2.0,
"width": 7.5,
"height": 1.2,
"paragraphs": [
{
"text": "段落文本",
// 可选属性(仅在非默认时包含):
"bullet": true, // 检测到显式项目符号
"level": 0, // 仅在 bullet 为 true 时包含
"alignment": "CENTER", // CENTER、RIGHT(非 LEFT)
"space_before": 10.0, // 段前间距(磅)
"space_after": 6.0, // 段后间距(磅)
"line_spacing": 22.4, // 行间距(磅)
"font_name": "Arial", // 来自第一个运行
"font_size": 14.0, // 磅
"bold": true,
"italic": false,
"underline": false,
"color": "FF0000" // RGB 颜色
}
]
}
}
}
default_font_size(磅,如可用)bullet: true 时,level 始终包含(即使是 0)space_before、space_after 和 line_spacing(磅,仅在设置时包含)color(例如"FF0000"),主题颜色的 theme_color(例如"DARK_1")根据上一步的文本清单:
"bullet": true 时不要设置 alignment 属性"bold": true"bullet": true, "level": 0(bullet 为 true 时需要 level)"alignment": "CENTER")"font_size": 14.0、"font_name": "Lora")"color": "FF0000",主题颜色使用 "theme_color": "DARK_1"replacement-text.json显示正确格式的示例 paragraphs 字段:
"paragraphs": [
{
"text": "新演示文稿标题文本",
"alignment": "CENTER",
"bold": true
},
{
"text": "章节标题",
"bold": true
},
{
"text": "第一个要点,不带项目符号符号",
"bullet": true,
"level": 0
},
{
"text": "红色文本",
"color": "FF0000"
},
{
"text": "主题颜色文本",
"theme_color": "DARK_1"
},
{
"text": "没有特殊格式的普通段落文本"
}
]
替换 JSON 中未列出的形状将自动清除:
{
"slide-0": {
"shape-0": {
"paragraphs": [...] // 此形状获得新文本
}
// 清单中的 shape-1 和 shape-2 将自动清除
}
}
演示文稿的常见格式模式:
"bullet": true, "level": 0replace.py 脚本应用替换 python scripts/replace.py working.pptx replacement-text.json output.pptx
该脚本将:
示例验证错误:
错误:替换 JSON 中的无效形状:
- 'slide-0' 上未找到形状 'shape-99'。可用形状:shape-0、shape-1、shape-4
- 清单中未找到幻灯片 'slide-999'
错误:替换文本使以下形状的溢出更严重:
- slide-0/shape-2:溢出加剧 1.25"(原为 0.00",现为 1.25")
要创建 PowerPoint 幻灯片的可视化缩略图网格以便快速分析和参考:
python scripts/thumbnail.py template.pptx [output_prefix]
功能:
thumbnails.jpg(或大型演示文稿为 thumbnails-1.jpg、thumbnails-2.jpg 等)python scripts/thumbnail.py template.pptx my-gridworkspace/my-grid)--cols 4(范围:3-6,影响每个网格的幻灯片数)用例:
示例:
# 基本用法
python scripts/thumbnail.py presentation.pptx
# 组合选项:自定义名称、列数
python scripts/thumbnail.py template.pptx analysis --cols 4
要可视化分析 PowerPoint 幻灯片,使用两步过程将其转换为图片:
soffice --headless --convert-to pdf template.pptx
pdftoppm -jpeg -r 150 template.pdf slide
这会创建 slide-1.jpg、slide-2.jpg 等文件。
选项:
-r 150:设置分辨率为 150 DPI(调整以平衡质量/大小)-jpeg:输出 JPEG 格式(如需要可使用 -png 输出 PNG)-f N:要转换的第一页(例如 -f 2 从第 2 页开始)-l N:要转换的最后一页(例如 -l 5 在第 5 页停止)slide:输出文件的前缀特定范围示例:
pdftoppm -jpeg -r 150 -f 2 -l 5 template.pdf slide # 仅转换第 2-5 页
重要:生成 PPTX 操作代码时:
必需的依赖项(应该已经安装):
pip install "markitdown[pptx]"(用于从演示文稿提取文本)npm install -g pptxgenjs(用于通过 html2pptx 创建演示文稿)npm install -g playwright(用于 html2pptx 中的 HTML 渲染)npm install -g react-icons react react-dom(用于图标)npm install -g sharp(用于 SVG 光栅化和图片处理)sudo apt-get install libreoffice(用于 PDF 转换)sudo apt-get install poppler-utils(用于 pdftoppm 将 PDF 转换为图片)pip install defusedxml(用于安全的 XML 解析)Comprehensive document creation, editing, and analysis with support for tracked changes, comments, formatting preservation, and text extraction. When Claude needs to work with professional documents (.docx files) for: (1) Creating new documents, (2) Modifying or editing content, (3) Working with tracked changes, (4) Adding comments, or any other document tasks
Comprehensive PDF manipulation toolkit for extracting text and tables, creating new PDFs, merging/splitting documents, and handling forms. When Claude needs to fill in a PDF form or programmatically process, generate, or analyze PDF documents at scale.
Presentation creation, editing, and analysis. When Claude needs to work with presentations (.pptx files) for: (1) Creating new presentations, (2) Modifying or editing content, (3) Working with layouts, (4) Adding comments or speaker notes, or any other presentation tasks
Create beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations.
Use this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill.
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation.
Use this skill any time a .pptx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates, layouts, speaker notes, or comments. Trigger whenever the user mentions \"deck,\" \"slides,\" \"presentation,\" or references a .pptx filename, regardless of what they plan to do with the content afterward. If a .pptx file needs to be opened, created, or touched, use this skill.
Create and edit Obsidian Flavored Markdown with wikilinks, embeds, callouts, properties, and other Obsidian-specific syntax. Use when working with .md files in Obsidian, or when the user mentions wikilinks, callouts, frontmatter, tags, embeds, or Obsidian notes.
Take leastbit/pptx from the repository into ~/.claude/skills for personal
use, or into .claude/skills inside a project.
The agent identifies a skill by the name field in its header. Two skills with the
same name cannot sit side by side — one of them will be ignored.
The instructions reference pip, npm, apt.
Without those the skill loads but fails at the first command.