pptx by tfriedel/claude-office-skills
npx skills add https://github.com/tfriedel/claude-office-skills --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 - 主要演示文稿元数据和幻灯片引用广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
ppt/slides/slide{N}.xmlppt/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。
关键:在创建任何演示文稿之前,请分析内容并选择合适的设计元素:
要求:
创造性地选择颜色:
示例调色板(使用这些来激发创意——选择一个、调整它或创建您自己的):
几何图案:
边框与框架处理:
字体处理:
图表与数据样式:
布局创新:
背景处理:
创建包含图表或表格的幻灯片时:
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 颜色
}
]
}
}
}
"bullet": true 时,不要在段落上设置 alignment 属性"bold": true"bullet": true, "level": 0(当 bullet 为 true 时,level 是必需的)显示正确格式的 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
该脚本将:
验证错误示例:
ERROR: 替换 JSON 中存在无效形状:
- 在 'slide-0' 上未找到形状 'shape-99'。可用形状:shape-0, shape-1, shape-4
- 在清单中未找到幻灯片 'slide-999'
ERROR: 替换文本使这些形状的溢出情况恶化:
- 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-grid
workspace/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 解析)每周安装
735
仓库
GitHub 星标
428
首次出现
2026 年 1 月 24 日
安全审计
安装于
opencode676
gemini-cli652
cursor651
codex647
github-copilot634
kimi-cli623
A user may ask you to create, edit, or analyze the contents of a .pptx file. A .pptx file is essentially a ZIP archive containing XML files and other resources that you can read or edit. You have different tools and workflows available for different tasks.
If you just need to read the text contents of a presentation, you should convert the document to markdown:
# Convert document to markdown
python -m markitdown path-to-file.pptx
You need raw XML access for: comments, speaker notes, slide layouts, animations, design elements, and complex formatting. For any of these features, you'll need to unpack a presentation and read its raw XML contents.
python ooxml/scripts/unpack.py <office_file> <output_dir>
Note : The unpack.py script is located at skills/pptx/ooxml/scripts/unpack.py relative to the project root. If the script doesn't exist at this path, use find . -name "unpack.py" to locate it.
ppt/presentation.xml - Main presentation metadata and slide referencesppt/slides/slide{N}.xml - Individual slide contents (slide1.xml, slide2.xml, etc.)ppt/notesSlides/notesSlide{N}.xml - Speaker notes for each slideppt/comments/modernComment_*.xml - Comments for specific slidesppt/slideLayouts/ - Layout templates for slidesppt/slideMasters/ - Master slide templatesppt/theme/ - Theme and styling informationppt/media/ - Images and other media filesWhen given an example design to emulate : Always analyze the presentation's typography and colors first using the methods below:
ppt/theme/theme1.xml for colors (<a:clrScheme>) and fonts (<a:fontScheme>)ppt/slides/slide1.xml for actual font usage (<a:rPr>) and colors<a:solidFill>, <a:srgbClr>) and font references across all XML filesWhen creating a new PowerPoint presentation from scratch, use the html2pptx workflow to convert HTML slides to PowerPoint with accurate positioning.
CRITICAL : Before creating any presentation, analyze the content and choose appropriate design elements:
Requirements :
Choosing colors creatively :
Example color palettes (use these to spark creativity - choose one, adapt it, or create your own):
Geometric Patterns :
Border & Frame Treatments:
Typography Treatments :
Chart & Data Styling:
Layout Innovations :
Background Treatments :
When creating slides with charts or tables:
html2pptx.md completely from start to finish. NEVER set any range limits when reading this file. Read the full file content for detailed syntax, critical formatting rules, and best practices before proceeding with presentation creation.<p>, <h1>-<h6>, <ul>, <ol> for all text contentclass="placeholder" for areas where charts/tables will be added (render with gray background for visibility)When edit slides in an existing PowerPoint presentation, you need to work with the raw Office Open XML (OOXML) format. This involves unpacking the .pptx file, editing the XML content, and repacking it.
ooxml.md (~500 lines) completely from start to finish. NEVER set any range limits when reading this file. Read the full file content for detailed guidance on OOXML structure and editing workflows before any presentation editing.python ooxml/scripts/unpack.py <office_file> <output_dir>ppt/slides/slide{N}.xml and related files)python ooxml/scripts/validate.py <dir> --original <file>python ooxml/scripts/pack.py <input_directory> <office_file>When you need to create a presentation that follows an existing template's design, you'll need to duplicate and re-arrange template slides before then replacing placeholder context.
Extract template text AND create visual thumbnail grid :
python -m markitdown template.pptx > template-content.mdtemplate-content.md: Read the entire file to understand the contents of the template presentation. NEVER set any range limits when reading this file.python scripts/thumbnail.py template.pptxAnalyze template and save inventory to a file :
Visual Analysis : Review thumbnail grid(s) to understand slide layouts, design patterns, and visual structure
Create and save a template inventory file at template-inventory.md containing:
# Template Inventory Analysis
**Total Slides: [count]**
**IMPORTANT: Slides are 0-indexed (first slide = 0, last slide = count-1)**
## [Category Name]
- Slide 0: [Layout code if available] - Description/purpose
- Slide 1: [Layout code] - Description/purpose
- Slide 2: [Layout code] - Description/purpose
[... EVERY slide must be listed individually with its index ...]
Example paragraphs field showing proper formatting:
"paragraphs": [
{
"text": "New presentation title text",
"alignment": "CENTER",
"bold": true
},
{
"text": "Section Header",
"bold": true
},
{
"text": "First bullet point without bullet symbol",
"bullet": true,
"level": 0
},
{
"text": "Red colored text",
"color": "FF0000"
},
{
"text": "Theme colored text",
"theme_color": "DARK_1"
},
{
"text": "Regular paragraph text without special formatting"
}
]
Shapes not listed in the replacement JSON are automatically cleared :
{
"slide-0": {
"shape-0": {
"paragraphs": [...] // This shape gets new text
}
// shape-1 and shape-2 from inventory will be cleared automatically
}
}
Common formatting patterns for presentations :
* Title slides: Bold text, sometimes centered
* Section headers within slides: Bold text
* Bullet lists: Each item needs `"bullet": true, "level": 0`
* Body text: Usually no special properties needed
* Quotes: May have special alignment or font properties
7. Apply replacements using thereplace.py script
python scripts/replace.py working.pptx replacement-text.json output.pptx
The script will:
* First extract the inventory of ALL text shapes using functions from inventory.py
* Validate that all shapes in the replacement JSON exist in the inventory
* Clear text from ALL shapes identified in the inventory
* Apply new text only to shapes with "paragraphs" defined in the replacement JSON
* Preserve formatting by applying paragraph properties from the JSON
* Handle bullets, alignment, font properties, and colors automatically
* Save the updated presentation
Example validation errors:
ERROR: Invalid shapes in replacement JSON:
- Shape 'shape-99' not found on 'slide-0'. Available shapes: shape-0, shape-1, shape-4
- Slide 'slide-999' not found in inventory
ERROR: Replacement text made overflow worse in these shapes:
- slide-0/shape-2: overflow worsened by 1.25" (was 0.00", now 1.25")
To create visual thumbnail grids of PowerPoint slides for quick analysis and reference:
python scripts/thumbnail.py template.pptx [output_prefix]
Features :
thumbnails.jpg (or thumbnails-1.jpg, thumbnails-2.jpg, etc. for large decks)python scripts/thumbnail.py template.pptx my-grid
workspace/my-grid)--cols 4 (range: 3-6, affects slides per grid)Use cases :
Examples :
# Basic usage
python scripts/thumbnail.py presentation.pptx
# Combine options: custom name, columns
python scripts/thumbnail.py template.pptx analysis --cols 4
To visually analyze PowerPoint slides, convert them to images using a two-step process:
Convert PPTX to PDF :
soffice --headless --convert-to pdf template.pptx
Convert PDF pages to JPEG images :
pdftoppm -jpeg -r 150 template.pdf slide
This creates files like slide-1.jpg, slide-2.jpg, etc.
Options:
-r 150: Sets resolution to 150 DPI (adjust for quality/size balance)-jpeg: Output JPEG format (use -png for PNG if preferred)-f N: First page to convert (e.g., -f 2 starts from page 2)-l N: Last page to convert (e.g., -l 5 stops at page 5)slide: Prefix for output filesExample for specific range:
pdftoppm -jpeg -r 150 -f 2 -l 5 template.pdf slide # Converts only pages 2-5
IMPORTANT : When generating code for PPTX operations:
Required dependencies (should already be installed):
pip install "markitdown[pptx]" (for text extraction from presentations)npm install -g pptxgenjs (for creating presentations via html2pptx)npm install -g playwright (for HTML rendering in html2pptx)npm install -g react-icons react react-dom (for icons)npm install -g sharp (for SVG rasterization and image processing)sudo apt-get install libreoffice (for PDF conversion)sudo apt-get install poppler-utils (for pdftoppm to convert PDF to images)Weekly Installs
735
Repository
GitHub Stars
428
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubFailSocketPassSnykWarn
Installed on
opencode676
gemini-cli652
cursor651
codex647
github-copilot634
kimi-cli623
Figma MCP 集成指南:使用 OpenAI Skills 实现 Figma 到代码的自动化转换
1,000 周安装
default_font_size(点)bullet: true 时,始终包含 level(即使为 0)space_before、space_after 和 line_spacing(点)(仅在设置时包含)color(例如,"FF0000"),主题颜色使用 theme_color(例如,"DARK_1")"alignment": "CENTER")"font_size": 14.0、"font_name": "Lora")"color": "FF0000",主题颜色使用 "theme_color": "DARK_1"replacement-text.jsonhtml2pptx.js library to convert HTML slides to PowerPoint and save the presentation
html2pptx() function to process each HTML filepptx.writeFile()python scripts/thumbnail.py output.pptx workspace/thumbnails --cols 4Using the thumbnail grid : Reference the visual thumbnails to identify:
This inventory file is REQUIRED for selecting appropriate templates in the next step
Create presentation outline based on template inventory :
Review available templates from step 2.
Choose an intro or title template for the first slide. This should be one of the first templates.
Choose safe, text-based layouts for the other slides.
CRITICAL: Match layout structure to actual content :
Count your actual content pieces BEFORE selecting the layout
Verify each placeholder in the chosen layout will be filled with meaningful content
Select one option representing the best layout for each content section.
Save outline.md with content AND template mapping that leverages available designs
Example template mapping:
# Template slides to use (0-based indexing)
# WARNING: Verify indices are within range! Template with 73 slides has indices 0-72
# Mapping: slide numbers from outline -> template slide indices
template_mapping = [
0, # Use slide 0 (Title/Cover)
34, # Use slide 34 (B1: Title and body)
34, # Use slide 34 again (duplicate for second B1)
50, # Use slide 50 (E1: Quote)
54, # Use slide 54 (F2: Closing + Text)
]
Duplicate, reorder, and delete slides usingrearrange.py:
Use the scripts/rearrange.py script to create a new presentation with slides in the desired order:
python scripts/rearrange.py template.pptx working.pptx 0,34,34,50,52
The script handles duplicating repeated slides, deleting unused slides, and reordering automatically
Slide indices are 0-based (first slide is 0, second is 1, etc.)
The same slide index can appear multiple times to duplicate that slide
Extract ALL text using theinventory.py script:
Run inventory extraction :
python scripts/inventory.py working.pptx text-inventory.json
Read text-inventory.json : Read the entire text-inventory.json file to understand all shapes and their properties. NEVER set any range limits when reading this file.
The inventory JSON structure:
{
"slide-0": {
"shape-0": {
"placeholder_type": "TITLE", // or null for non-placeholders
"left": 1.5, // position in inches
"top": 2.0,
"width": 7.5,
"height": 1.2,
"paragraphs": [
{
"text": "Paragraph text",
// Optional properties (only included when non-default):
"bullet": true, // explicit bullet detected
"level": 0, // only included when bullet is true
"alignment": "CENTER", // CENTER, RIGHT (not LEFT)
"space_before": 10.0, // space before paragraph in points
"space_after": 6.0, // space after paragraph in points
"line_spacing": 22.4, // line spacing in points
"font_name": "Arial", // from first run
"font_size": 14.0, // in points
"bold": true,
"italic": false,
"underline": false,
"color": "FF0000" // RGB color
}
]
}
}
}
Key features:
default_font_size in points extracted from layout placeholders (when available)bullet: true, level is always included (even if 0)space_before, space_after, and line_spacing in points (only included when set)color for RGB (e.g., "FF0000"), for theme colors (e.g., "DARK_1")Generate replacement text and save the data to a JSON file Based on the text inventory from the previous step:
alignment property on when "bullet": true"bold": true"bullet": true, "level": 0 (level is required when bullet is true)"alignment": "CENTER" for centered text)"font_size": 14.0, "font_name": "Lora")"color": "FF0000" for RGB or "theme_color": "DARK_1" for theme colorsreplacement-text.jsonpip install defusedxml (for secure XML parsing)theme_color