pptx by dedalus-erp-pas/foundation-skills
npx skills add https://github.com/dedalus-erp-pas/foundation-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}.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。
关键:在创建任何演示文稿之前,分析内容并选择合适的设计元素:
要求:
创造性地选择颜色:
示例调色板(使用这些来激发创造力——选择一个、调整它或创建您自己的):
几何图案:
边框与框架处理:
字体处理:
图表与数据样式:
布局创新:
背景处理:
创建包含图表或表格的幻灯片时:
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 4pptx.writeFile('presentation.pptx') 保存演示文稿此工作流程用于从包含占位符文本的模板创建演示文稿,这些占位符文本将被替换为真实内容。
ooxml.md 以获取 XML 参考。cp template.pptx working.pptxpython scripts/thumbnail.py template.pptx workspace/thumbnails --cols 4
python scripts/rearrange.py template.pptx working.pptx 0,5,12,12,23
12,12 使用幻灯片 12 两次)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": "Paragraph 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 时,不要设置 alignment 属性"bold": true"bullet": true, "level": 0(当 bullet 为 true 时,level 是必需的)显示正确格式的示例 paragraphs 字段:
"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"
}
]
未在替换 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: 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")
为 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 解析)每周安装
60
仓库
GitHub 星标
2
首次出现
2026年1月21日
安全审计
安装于
github-copilot47
opencode46
claude-code44
cursor44
gemini-cli43
codex43
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)This workflow is for creating presentations from templates that contain placeholder text to be replaced with real content.
MANDATORY - READ ENTIRE FILE : Read ooxml.md completely first for XML reference.
Copy the template to a working file Create a working copy of the template to modify: cp template.pptx working.pptx
Create a thumbnail grid of the template to see all available slides
python scripts/thumbnail.py template.pptx workspace/thumbnails --cols 4
Rearrange slides based on content requirements
python scripts/rearrange.py template.pptx working.pptx 0,5,12,12,23
12,12 uses slide 12 twice)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
60
Repository
GitHub Stars
2
First Seen
Jan 21, 2026
Security Audits
Gen Agent Trust HubWarnSocketPassSnykWarn
Installed on
github-copilot47
opencode46
claude-code44
cursor44
gemini-cli43
codex43
Skills CLI 使用指南:AI Agent 技能包管理器安装与管理教程
44,900 周安装
bullet: true 时,始终包含 level(即使为 0)space_before、space_after 和 line_spacing(点)(仅在设置时包含)color 用于 RGB(例如,"FF0000"),theme_color 用于主题颜色(例如,"DARK_1")"alignment": "CENTER")"font_size": 14.0、"font_name": "Lora")"color": "FF0000" 表示 RGB,或 "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 4pptx.writeFile('presentation.pptx')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"), theme_color 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)