pptx-generator by jwynia/agent-skills
npx skills add https://github.com/jwynia/agent-skills --skill pptx-generator在以下情况下使用此技能:
在以下情况下请不要使用此技能:
{{PLACEHOLDERS}} 并用内容替换提取文本清单以了解可以替换的内容:
deno run --allow-read scripts/analyze-template.ts corporate-template.pptx > inventory.json
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
输出 (inventory.json):
{
"filename": "corporate-template.pptx",
"slideCount": 10,
"textElements": [
{
"slideNumber": 1,
"shapeId": "shape-2",
"shapeName": "Title 1",
"placeholderType": "ctrTitle",
"position": { "x": 1.5, "y": 2.0, "w": 7.0, "h": 1.2 },
"paragraphs": [
{ "text": "{{TITLE}}", "fontSize": 44, "bold": true }
]
}
]
}
创建 replacements.json:
{
"textReplacements": [
{ "tag": "{{TITLE}}", "value": "Q4 2024 Results" },
{ "tag": "{{SUBTITLE}}", "value": "Financial Overview" },
{ "tag": "{{DATE}}", "value": "December 2024" },
{ "tag": "{{AUTHOR}}", "value": "Finance Team", "slideNumbers": [1] }
]
}
deno run --allow-read --allow-write scripts/generate-from-template.ts \
corporate-template.pptx replacements.json output.pptx
获取可用幻灯片的信息:
deno run --allow-read scripts/generate-thumbnails.ts slide-library.pptx
如需视觉预览,提取缩略图:
deno run --allow-read --allow-write scripts/generate-thumbnails.ts \
slide-library.pptx --extract-thumb --output-dir ./previews
创建 selections.json:
{
"slideSelections": [
{ "slideNumber": 1 },
{ "slideNumber": 5 },
{ "slideNumber": 12 },
{ "slideNumber": 3 }
],
"textReplacements": [
{ "tag": "{{TITLE}}", "value": "Custom Presentation" }
]
}
deno run --allow-read --allow-write scripts/generate-from-template.ts \
slide-library.pptx selections.json custom-deck.pptx
创建 spec.json:
{
"title": "Product Launch 2025",
"author": "Marketing Team",
"slides": [
{
"background": { "color": "003366" },
"elements": [
{
"type": "text",
"x": 1, "y": 2.5, "w": 8, "h": 1.5,
"options": {
"text": "Product Launch 2025",
"fontSize": 44,
"bold": true,
"color": "FFFFFF",
"align": "center"
}
},
{
"type": "text",
"x": 1, "y": 4, "w": 8, "h": 0.5,
"options": {
"text": "Revolutionizing the Industry",
"fontSize": 24,
"color": "CCCCCC",
"align": "center"
}
}
]
},
{
"elements": [
{
"type": "text",
"x": 0.5, "y": 0.5, "w": 9, "h": 0.7,
"options": {
"text": "Key Features",
"fontSize": 32,
"bold": true,
"color": "003366"
}
},
{
"type": "table",
"x": 0.5, "y": 1.5, "w": 9, "h": 3,
"options": {
"rows": [
["Feature", "Description", "Benefit"],
["Speed", "2x faster processing", "Save time"],
["Quality", "HD output", "Better results"],
["Integration", "Works with existing tools", "Easy adoption"]
],
"border": { "pt": 1, "color": "CCCCCC" }
}
}
]
}
]
}
deno run --allow-read --allow-write scripts/generate-scratch.ts spec.json output.pptx
场景:根据品牌模板生成季度报告。
步骤:
# 1. 分析模板以查找可替换内容
deno run --allow-read scripts/analyze-template.ts quarterly-template.pptx --pretty
# 2. 使用 Q4 数据创建 replacements.json
# 3. 生成报告
deno run --allow-read --allow-write scripts/generate-from-template.ts \
quarterly-template.pptx replacements.json Q4-2024-Report.pptx
场景:为特定客户推介组合已批准的幻灯片。
步骤:
# 1. 查看可用幻灯片
deno run --allow-read scripts/generate-thumbnails.ts pitch-library.pptx
# 2. 创建 selections.json,选择幻灯片 1, 3, 7, 12, 15
# 3. 生成自定义文稿
deno run --allow-read --allow-write scripts/generate-from-template.ts \
pitch-library.pptx selections.json acme-pitch.pptx
场景:根据 JSON 数据(例如 API 响应)生成演示文稿。
步骤:
# 1. 将您的数据转换为 spec.json 格式
# 2. 生成演示文稿
deno run --allow-read --allow-write scripts/generate-scratch.ts data-spec.json report.pptx
| 脚本 | 用途 | 所需权限 |
|---|---|---|
analyze-template.ts | 从 PPTX 提取文本清单 | --allow-read |
generate-thumbnails.ts | 获取幻灯片信息并提取预览 | --allow-read --allow-write |
generate-from-template.ts | 修改模板(替换/组合) | --allow-read --allow-write |
generate-scratch.ts | 根据 JSON 规范创建 PPTX | --allow-read --allow-write |
| 类型 | 描述 | 关键选项 |
|---|---|---|
text | 文本框 | text, fontSize, bold, color, align |
image | 来自文件或 base64 的图像 | path, data, sizing |
table | 数据表格 | rows, colW, border, fill |
shape | 几何形状 | type, fill, line, text |
chart | 图表和图形 | type, data, title, showLegend |
症状:输出的 PPTX 仍然包含 {{PLACEHOLDER}} 标签。
解决方案:
analyze-template.ts 以验证确切的标签文本slideNumbers 过滤器症状:组合后幻灯片顺序错误。
解决方案:
slideSelections 中指定的顺序添加症状:输出中的图像元素为空白。
解决方案:
了解 PowerPoint 的 OOXML 格式如何处理占位符对于模板开发至关重要。
PowerPoint 使用分层继承模型:
Theme → Slide Master → Slide Layout → Slide
{{placeholder}} 文本不会自动出现在使用该版式的幻灯片上。<a:lstStyle/> 时,它会从版式的 <a:lstStyle> 继承格式(颜色、大小、项目符号)。<p:ph type="..." idx="..."/> 链接到版式。type(例如 "title", "body", "ctrTitle")和 idx 必须匹配。<a:buNone/>。在版式占位符中,在 <a:lstStyle>(可继承)中定义颜色,而不是在 <a:rPr>(运行特定)中:
<!-- Layout: Color in lstStyle (GOOD - inheritable) -->
<p:txBody>
<a:lstStyle>
<a:lvl1pPr algn="ctr">
<a:buNone/> <!-- Suppress bullets -->
<a:defRPr sz="4400" b="1">
<a:solidFill><a:srgbClr val="FFFFFF"/></a:solidFill>
</a:defRPr>
</a:lvl1pPr>
</a:lstStyle>
<a:p>
<a:r><a:rPr lang="en-US"/><a:t>{{placeholder}}</a:t></a:r>
</a:p>
</p:txBody>
为了使幻灯片能够正确从版式继承:
<!-- Slide: Empty lstStyle to inherit from layout -->
<p:sp>
<p:nvSpPr>
<p:cNvPr id="2" name="title 2"/>
<p:cNvSpPr><a:spLocks noGrp="1"/></p:cNvSpPr>
<p:nvPr>
<p:ph type="ctrTitle"/> <!-- Links to layout placeholder -->
</p:nvPr>
</p:nvSpPr>
<p:spPr/> <!-- Empty = inherit position from layout -->
<p:txBody>
<a:bodyPr/>
<a:lstStyle/> <!-- Empty = inherit formatting from layout -->
<a:p>
<a:r>
<a:rPr lang="en-US"/> <!-- Empty = inherit character formatting -->
<a:t>{{placeholder}}</a:t> <!-- Content must be here -->
</a:r>
</a:p>
</p:txBody>
</p:sp>
| 问题 | 原因 | 解决方案 |
|---|---|---|
| 文本显示为黑色而不是白色 | 颜色定义在 <a:rPr> 中而不是 <a:lstStyle> 中 | 将颜色移动到版式 <a:lstStyle> 中的 <a:defRPr> |
| 出现不需要的项目符号 | 母版的 bodyStyle 有项目符号,版式未覆盖 | 在版式的 <a:lvl1pPr> 中添加 <a:buNone/> |
| 占位符文本未出现 | 文本仅在版式中,不在幻灯片中 | 在幻灯片的 <p:txBody> 中包含文本内容 |
| 格式未应用 | 幻灯片有显式格式 | 使用空的 <a:lstStyle/> 和 <a:rPr lang="en-US"/> |
| 类型 | 用途 |
|---|---|
ctrTitle | 居中标题(标题幻灯片) |
title | 标准标题 |
subTitle | 副标题 |
body | 内容区域(使用 idx 表示多个) |
pic | 图片占位符 |
dt | 日期/时间 |
ftr | 页脚 |
sldNum | 幻灯片编号 |
每周安装量
240
仓库
GitHub 星标数
37
首次出现
2026年1月20日
安全审计
安装于
opencode200
codex195
gemini-cli193
cursor185
github-copilot181
cline157
Use this skill when:
Do NOT use this skill when:
Template Mode : Modify existing branded templates
{{PLACEHOLDERS}} and replace with contentScratch Mode : Create presentations from nothing using JSON specifications
Extract text inventory to understand what can be replaced:
deno run --allow-read scripts/analyze-template.ts corporate-template.pptx > inventory.json
Output (inventory.json):
{
"filename": "corporate-template.pptx",
"slideCount": 10,
"textElements": [
{
"slideNumber": 1,
"shapeId": "shape-2",
"shapeName": "Title 1",
"placeholderType": "ctrTitle",
"position": { "x": 1.5, "y": 2.0, "w": 7.0, "h": 1.2 },
"paragraphs": [
{ "text": "{{TITLE}}", "fontSize": 44, "bold": true }
]
}
]
}
Create replacements.json:
{
"textReplacements": [
{ "tag": "{{TITLE}}", "value": "Q4 2024 Results" },
{ "tag": "{{SUBTITLE}}", "value": "Financial Overview" },
{ "tag": "{{DATE}}", "value": "December 2024" },
{ "tag": "{{AUTHOR}}", "value": "Finance Team", "slideNumbers": [1] }
]
}
deno run --allow-read --allow-write scripts/generate-from-template.ts \
corporate-template.pptx replacements.json output.pptx
Get information about available slides:
deno run --allow-read scripts/generate-thumbnails.ts slide-library.pptx
For visual preview, extract the thumbnail:
deno run --allow-read --allow-write scripts/generate-thumbnails.ts \
slide-library.pptx --extract-thumb --output-dir ./previews
Create selections.json:
{
"slideSelections": [
{ "slideNumber": 1 },
{ "slideNumber": 5 },
{ "slideNumber": 12 },
{ "slideNumber": 3 }
],
"textReplacements": [
{ "tag": "{{TITLE}}", "value": "Custom Presentation" }
]
}
deno run --allow-read --allow-write scripts/generate-from-template.ts \
slide-library.pptx selections.json custom-deck.pptx
Create spec.json:
{
"title": "Product Launch 2025",
"author": "Marketing Team",
"slides": [
{
"background": { "color": "003366" },
"elements": [
{
"type": "text",
"x": 1, "y": 2.5, "w": 8, "h": 1.5,
"options": {
"text": "Product Launch 2025",
"fontSize": 44,
"bold": true,
"color": "FFFFFF",
"align": "center"
}
},
{
"type": "text",
"x": 1, "y": 4, "w": 8, "h": 0.5,
"options": {
"text": "Revolutionizing the Industry",
"fontSize": 24,
"color": "CCCCCC",
"align": "center"
}
}
]
},
{
"elements": [
{
"type": "text",
"x": 0.5, "y": 0.5, "w": 9, "h": 0.7,
"options": {
"text": "Key Features",
"fontSize": 32,
"bold": true,
"color": "003366"
}
},
{
"type": "table",
"x": 0.5, "y": 1.5, "w": 9, "h": 3,
"options": {
"rows": [
["Feature", "Description", "Benefit"],
["Speed", "2x faster processing", "Save time"],
["Quality", "HD output", "Better results"],
["Integration", "Works with existing tools", "Easy adoption"]
],
"border": { "pt": 1, "color": "CCCCCC" }
}
}
]
}
]
}
deno run --allow-read --allow-write scripts/generate-scratch.ts spec.json output.pptx
Scenario : Generate quarterly report from branded template.
Steps :
# 1. Analyze template for replaceable content
deno run --allow-read scripts/analyze-template.ts quarterly-template.pptx --pretty
# 2. Create replacements.json with Q4 data
# 3. Generate report
deno run --allow-read --allow-write scripts/generate-from-template.ts \
quarterly-template.pptx replacements.json Q4-2024-Report.pptx
Scenario : Combine approved slides for a specific client pitch.
Steps :
# 1. View available slides
deno run --allow-read scripts/generate-thumbnails.ts pitch-library.pptx
# 2. Create selections.json picking slides 1, 3, 7, 12, 15
# 3. Generate custom deck
deno run --allow-read --allow-write scripts/generate-from-template.ts \
pitch-library.pptx selections.json acme-pitch.pptx
Scenario : Generate presentation from JSON data (e.g., API response).
Steps :
# 1. Transform your data into spec.json format
# 2. Generate presentation
deno run --allow-read --allow-write scripts/generate-scratch.ts data-spec.json report.pptx
| Script | Purpose | Permissions |
|---|---|---|
analyze-template.ts | Extract text inventory from PPTX | --allow-read |
generate-thumbnails.ts | Get slide info and extract previews | --allow-read --allow-write |
generate-from-template.ts | Modify templates (replace/combine) | --allow-read --allow-write |
| Type | Description | Key Options |
|---|---|---|
text | Text box | text, fontSize, bold, color, align |
image | Image from file or base64 | path, data, |
Symptoms : Output PPTX still contains {{PLACEHOLDER}} tags.
Solution :
analyze-template.ts to verify exact tag textslideNumbers filter in replacementsSymptoms : Slides appear in wrong order after combining.
Solution :
slideSelectionsSymptoms : Image elements are blank in output.
Solution :
Understanding how PowerPoint's OOXML format handles placeholders is crucial for template development.
PowerPoint uses a hierarchical inheritance model:
Theme → Slide Master → Slide Layout → Slide
Text Content Does NOT Inherit : Slides must contain their own text content. The {{placeholder}} text in a layout does NOT automatically appear on slides using that layout.
Text Formatting CAN Inherit : When a slide shape has an empty <a:lstStyle/>, it inherits formatting (color, size, bullets) from the layout's <a:lstStyle>.
Placeholder Linking : Slides link to layouts via <p:ph type="..." idx="..."/>. The type (e.g., "title", "body", "ctrTitle") and idx must match.
Bullet Suppression : To prevent bullets on a placeholder that would normally inherit them from the master's bodyStyle, add <a:buNone/> in the layout's lstStyle.
In layout placeholders, define colors in <a:lstStyle> (inheritable), not in <a:rPr> (run-specific):
<!-- Layout: Color in lstStyle (GOOD - inheritable) -->
<p:txBody>
<a:lstStyle>
<a:lvl1pPr algn="ctr">
<a:buNone/> <!-- Suppress bullets -->
<a:defRPr sz="4400" b="1">
<a:solidFill><a:srgbClr val="FFFFFF"/></a:solidFill>
</a:defRPr>
</a:lvl1pPr>
</a:lstStyle>
<a:p>
<a:r><a:rPr lang="en-US"/><a:t>{{placeholder}}</a:t></a:r>
</a:p>
</p:txBody>
For slides to properly inherit from layouts:
<!-- Slide: Empty lstStyle to inherit from layout -->
<p:sp>
<p:nvSpPr>
<p:cNvPr id="2" name="title 2"/>
<p:cNvSpPr><a:spLocks noGrp="1"/></p:cNvSpPr>
<p:nvPr>
<p:ph type="ctrTitle"/> <!-- Links to layout placeholder -->
</p:nvPr>
</p:nvSpPr>
<p:spPr/> <!-- Empty = inherit position from layout -->
<p:txBody>
<a:bodyPr/>
<a:lstStyle/> <!-- Empty = inherit formatting from layout -->
<a:p>
<a:r>
<a:rPr lang="en-US"/> <!-- Empty = inherit character formatting -->
<a:t>{{placeholder}}</a:t> <!-- Content must be here -->
</a:r>
</a:p>
</p:txBody>
</p:sp>
| Issue | Cause | Solution |
|---|---|---|
| Text shows as black instead of white | Color defined in <a:rPr> not <a:lstStyle> | Move color to layout's <a:defRPr> in <a:lstStyle> |
| Unwanted bullets appearing | Master's bodyStyle has bullets, layout doesn't override | Add <a:buNone/> to layout's <a:lvl1pPr> |
| Placeholder text not appearing | Text only in layout, not in slide | Include text content in slide's <p:txBody> |
| Type | Usage |
|---|---|
ctrTitle | Centered title (title slides) |
title | Standard title |
subTitle | Subtitle |
body | Content area (use idx for multiple) |
pic | Picture placeholder |
dt |
Weekly Installs
240
Repository
GitHub Stars
37
First Seen
Jan 20, 2026
Security Audits
Gen Agent Trust HubFailSocketPassSnykPass
Installed on
opencode200
codex195
gemini-cli193
cursor185
github-copilot181
cline157
Skills CLI 使用指南:AI Agent 技能包管理器安装与管理教程
27,400 周安装
generate-scratch.ts| Create PPTX from JSON specification |
--allow-read --allow-write |
sizingtable | Data table | rows, colW, border, fill |
shape | Geometric shapes | type, fill, line, text |
chart | Charts and graphs | type, data, title, showLegend |
| Formatting not applying | Slide has explicit formatting | Use empty <a:lstStyle/> and <a:rPr lang="en-US"/> |
| Date/time |
ftr | Footer |
sldNum | Slide number |