重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
pptx by bbeierle12/skill-mcp-claude
npx skills add https://github.com/bbeierle12/skill-mcp-claude --skill pptx当需要时,创建、编辑或分析 .pptx 文件的内容。.pptx 文件本质上是一个包含 XML 文件和其他资源的 ZIP 归档文件。针对不同的任务,有不同的工具和工作流程可用。
在开始任何演示文稿任务之前,请完整阅读所有相关文档文件,以了解完整的工作流程:
html2pptx.md 和 css.mdooxml.mdcss.md阅读这些文件时,切勿设置任何范围限制。 在开始之前,理解完整的工作流程、约束条件和最佳实践对于生成高质量的演示文稿至关重要。部分了解会导致错误、样式不一致以及需要返工的视觉缺陷。
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
要仅读取演示文稿的文本内容,请将文档转换为 markdown:
# 将文档转换为 markdown
python -m markitdown path-to-file.pptx
对于以下内容使用原始 XML 访问:注释、演讲者备注、幻灯片版式、动画、设计元素和复杂格式。要访问这些功能,需要解包演示文稿并读取其原始 XML 内容。
python ooxml/scripts/unpack.py <office_file> <output_dir>
注意:unpack.py 脚本位于项目根目录下的 skills/public/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。
阅读文档:完整阅读 html2pptx.md 和 css.md(参见上面的“关键:首先阅读所有文档”部分)
前提条件 - 提取 html2pptx 库:
* 将库提取到脚本旁边:`mkdir -p html2pptx && tar -xzf skills/public/pptx/html2pptx.tgz -C html2pptx`
* 这将创建一个包含库文件和 CLI 二进制文件的 `html2pptx/` 目录
3. 规划演示文稿:遵循 html2pptx.md 的“设计理念”部分:
* 美学方向和大胆的设计选择
* 调色板选择(参见“创建你的调色板”)
* 字体策略
* 编写包含幻灯片布局和演讲者备注的**详细**大纲(每张幻灯片 1-3 句话)
4. 设置 CSS 变量:在共享的 .css 文件中覆盖 CSS 变量,用于颜色、字体和间距(参见 css.md 的“设计系统变量”)
* 幻灯片布局区域(标题、内容、脚注)
* 关键文本规则(正确的 HTML 标签)
* 支持的元素和样式
6. 使用 html2pptx 库创建并运行一个 JavaScript 文件,将 HTML 幻灯片转换为 PowerPoint 并保存演示文稿
* 运行:`NODE_PATH="$(npm root -g)" node your-script.js 2>&1`
* 使用 `html2pptx` 函数处理每个 HTML 文件
* 使用 PptxGenJS API 将图表和表格添加到占位符区域
* 使用 `pptx.writeFile()` 保存演示文稿
* **⚠️ 关键:** 你的脚本**必须**遵循此示例结构。在编写脚本之前请仔细思考,确保正确使用 API。**不要**调用 `pptx.addSlide`。
const pptxgen = require("pptxgenjs");
const { html2pptx } = require("./html2pptx");
// 创建一个新的 pptx 演示文稿
const pptx = new pptxgen();
pptx.layout = "LAYOUT_16x9"; // 必须匹配 HTML body 的尺寸
// 添加一个纯 HTML 幻灯片
await html2pptx("slide1.html", pptx);
// 添加一个带有图表占位符的 HTML 幻灯片
const { slide: slide2, placeholders } = await html2pptx("slide2.html", pptx);
slide.addChart(pptx.charts.LINE, chartData, placeholders[0]);
// 保存演示文稿
await pptx.writeFile("output.pptx");
7. 视觉验证:转换为图像并检查布局问题
* 首先将 PPTX 转换为 PDF:`soffice --headless --convert-to pdf output.pptx`
* 然后将 PDF 转换为图像:`pdftoppm -jpeg -r 150 output.pdf slide`
* 这将创建类似 `slide-1.jpg`、`slide-2.jpg` 等文件。
* 读取每个生成的图像文件,并仔细检查:
* **文本截断**:文本被标题栏、形状或幻灯片边缘截断
* **文本重叠**:文本与其他文本或形状重叠
* **定位问题**:内容太靠近幻灯片边界或其他元素
* **对比度问题**:文本和背景之间对比度不足
* **对齐问题**:元素之间未正确对齐
* **视觉层次**:重要内容是否得到适当强调
* **关键:所有幻灯片在交付给用户之前必须通过这些验证检查。** 不要跳过此步骤或交付带有视觉缺陷的演示文稿。
* 如果发现问题,请按以下优先级顺序修复:
1. **增加边距** - 在有问题的元素周围添加更多内边距/间距
2. **调整字体大小** - 减小文本大小以适应可用空间
3. **完全重新考虑布局** - 如果上述修复无效,则重新设计幻灯片布局
* 进行更改后重新生成演示文稿
* 重复此过程,直到所有幻灯片在视觉上都正确无误
要编辑现有 PowerPoint 演示文稿中的幻灯片,需要处理原始的 Office Open XML (OOXML) 格式。这涉及解包 .pptx 文件、编辑 XML 内容并重新打包。
ooxml.md(参见上面的“关键:首先阅读所有文档”部分)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.md`
* 完整阅读 `template-content.md` 以了解模板内容
* 创建缩略图网格:`python scripts/thumbnail.py template.pptx`
* 有关更多详细信息,请参见创建缩略图网格部分
2. 分析模板并将清单保存到文件:
* **视觉分析**:查看缩略图网格以了解幻灯片布局、设计模式和视觉结构
* 在 `template-inventory.md` 创建并保存一个模板清单文件,内容如下:
# 模板清单分析
**总幻灯片数:[count]**
**重要提示:幻灯片索引从 0 开始(第一张幻灯片 = 0,最后一张幻灯片 = count-1)**
## [类别名称]
- 幻灯片 0:[布局代码(如果可用)] - 描述/用途
- 幻灯片 1:[布局代码] - 描述/用途
- 幻灯片 2:[布局代码] - 描述/用途
[... 必须单独列出每张幻灯片及其索引 ...]
* **使用缩略图网格**:参考视觉缩略图来识别:
* 布局模式(标题幻灯片、内容布局、章节分隔符)
* 图像占位符位置和数量
* 幻灯片组之间的设计一致性
* 视觉层次和结构
* 此清单文件是下一步选择合适模板所**必需**的
3. 基于模板清单创建演示文稿大纲:
* 查看步骤 2 中可用的模板。
* 为第一张幻灯片选择一个介绍或标题模板。这应该是首批模板之一。
* 为其他幻灯片选择安全的、基于文本的布局。
* **关键:使布局结构与实际内容匹配**:
* 单列布局:用于统一的叙述或单一主题
* 双列布局:**仅当**恰好有 2 个不同的项目/概念时使用
* 三列布局:**仅当**恰好有 3 个不同的项目/概念时使用
* 图像 + 文本布局:**仅当**有实际图像要插入时使用
* 引用布局:**仅用于**人物的实际引用(需注明出处),切勿用于强调
* 切勿使用占位符数量多于可用内容的布局
* 有 2 个项目时,避免将其强行放入 3 列布局
* 有 4 个或更多项目时,考虑分成多张幻灯片或使用列表格式
* **在选择布局之前**,先计算实际的内容片段数量
* 验证所选布局中的每个占位符都将填充有意义的内容
* 为每个内容部分选择**最佳**布局选项。
* 保存 `outline.md`,其中包含内容以及利用可用设计的模板映射
* 模板映射示例:
# 要使用的模板幻灯片(基于 0 的索引)
# 警告:验证索引在范围内!包含 73 张幻灯片的模板索引为 0-72
# 映射:大纲中的幻灯片编号 -> 模板幻灯片索引
template_mapping = [
0, # 使用幻灯片 0(标题/封面)
34, # 使用幻灯片 34(B1:标题和正文)
34, # 再次使用幻灯片 34(为第二个 B1 复制)
50, # 使用幻灯片 50(E1:引用)
54, # 使用幻灯片 54(F2:结束语 + 文本)
]
4. 使用rearrange.py复制、重新排序和删除幻灯片:
* 使用 `scripts/rearrange.py` 脚本创建一个新演示文稿,其中幻灯片按所需顺序排列:
python scripts/rearrange.py template.pptx working.pptx 0,34,34,50,52
* 该脚本自动处理重复幻灯片的复制、未使用幻灯片的删除和重新排序
* 幻灯片索引从 0 开始(第一张幻灯片是 0,第二张是 1,依此类推)
* 同一幻灯片索引可以出现多次以复制该幻灯片
5. 使用inventory.py脚本提取所有文本:
* **运行清单提取**:
python scripts/inventory.py working.pptx text-inventory.json
* **完整阅读 text-inventory.json** 以了解所有形状及其属性
* 清单 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 颜色
}
]
}
}
}
* 关键特性:
* **幻灯片**:命名为 "slide-0"、"slide-1" 等。
* **形状**:按视觉位置(从上到下,从左到右)排序为 "shape-0"、"shape-1" 等。
* **占位符类型**:TITLE、CENTER_TITLE、SUBTITLE、BODY、OBJECT 或 null
* **默认字体大小**:从布局占位符提取的 `default_font_size`(点)(如果可用)
* **幻灯片编号已过滤**:具有 SLIDE_NUMBER 占位符类型的形状会自动从清单中排除
* **项目符号**:当 `bullet: true` 时,始终包含 `level`(即使为 0)
* **间距**:`space_before`、`space_after` 和 `line_spacing`(点)(仅在设置时包含)
* **颜色**:RGB 使用 `"color": "FF0000"`,主题颜色使用 `"theme_color": "DARK_1"`
* **属性**:输出中仅包含非默认值
6. 基于上一步的文本清单,生成替换文本并将数据保存到 JSON 文件:
* **关键**:首先验证清单中存在哪些形状 - 仅引用实际存在的形状
* **验证**:replace.py 脚本会验证替换 JSON 中的所有形状是否都存在于清单中
* 引用不存在的形状会产生错误,显示可用形状
* 引用不存在的幻灯片会产生错误,指示该幻灯片不存在
* 所有验证错误都会在脚本退出前一次性显示
* **重要**:replace.py 脚本在内部使用 inventory.py 来识别**所有**文本形状
* **自动清除**:除非为清单中的形状提供了 "paragraphs",否则**所有**文本形状的文本都将被清除
* 为需要内容的形状添加 "paragraphs" 字段(不是 "replacement_paragraphs")
* 替换 JSON 中没有 "paragraphs" 的形状,其文本会自动被清除
* 带有项目符号的段落会自动左对齐。当 `"bullet": true` 时,避免设置 `alignment` 属性
* 为占位符文本生成适当的替换内容
* 使用形状大小来确定适当的内容长度
* **关键**:包含原始清单中的段落属性 - 不要只提供文本
* **重要**:当 bullet: true 时,**不要**在文本中包含项目符号(•, -, *) - 它们会自动添加
* **基本格式规则**:
* 标题/标题通常应具有 `"bold": true`
* 列表项应具有 `"bullet": true, "level": 0`(当 bullet 为 true 时,level 是必需的)
* 保留任何对齐属性(例如,居中文本的 `"alignment": "CENTER"`)
* 当字体属性与默认值不同时,包含字体属性(例如,`"font_size": 14.0`、`"font_name": "Lora"`)
* 颜色:RGB 使用 `"color": "FF0000"`,主题颜色使用 `"theme_color": "DARK_1"`
* 替换脚本期望**正确格式化的段落**,而不仅仅是文本字符串
* **重叠形状**:优先选择具有较大 default_font_size 或更合适 placeholder_type 的形状
* 将包含替换内容的更新清单保存到 `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": 0`
* 正文文本:通常不需要特殊属性
* 引用:可能具有特殊的对齐或字体属性
7. 使用replace.py脚本应用替换
python scripts/replace.py working.pptx replacement-text.json output.pptx
脚本将:
* 首先使用 inventory.py 中的函数提取**所有**文本形状的清单
* 验证替换 JSON 中的所有形状是否都存在于清单中
* 清除清单中识别的**所有**形状的文本
* 仅将新文本应用于替换 JSON 中定义了 "paragraphs" 的形状
* 通过应用 JSON 中的段落属性来保留格式
* 自动处理项目符号、对齐、字体属性和颜色
* 保存更新后的演示文稿
验证错误示例:
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 幻灯片,请使用两步过程将其转换为图像:
将 PPTX 转换为 PDF:
soffice --headless --convert-to pdf template.pptx
将 PDF 页面转换为 JPEG 图像:
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(用于 SVG 格式的图标)brew install --cask libreofficesudo apt-get install libreofficesudo apt-get install poppler-utils(用于 pdftoppm 将 PDF 转换为图像)pip install defusedxml(用于安全的 XML 解析)每周安装次数
44
仓库
GitHub 星标数
7
首次出现
2026 年 1 月 23 日
安全审计
安装于
opencode40
gemini-cli39
codex37
cursor37
claude-code35
github-copilot32
Create, edit, or analyze the contents of .pptx files when requested. A .pptx file is essentially a ZIP archive containing XML files and other resources. Different tools and workflows are available for different tasks.
Before starting any presentation task , read ALL relevant documentation files completely to understand the full workflow:
html2pptx.md and css.md in their entiretyooxml.md in its entiretycss.mdNEVER set any range limits when reading these files. Understanding the complete workflow, constraints, and best practices before starting is essential for producing high-quality presentations. Partial knowledge leads to errors, inconsistent styling, and visual defects that require rework.
To read just the text content of a presentation, convert the document to markdown:
# Convert document to markdown
python -m markitdown path-to-file.pptx
Use raw XML access for: comments, speaker notes, slide layouts, animations, design elements, and complex formatting. To access these features, 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/public/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 filesTo emulate example designs , 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.
Read documentation : Read html2pptx.md and css.md completely (see "CRITICAL: Read All Documentation First" section above)
PREREQUISITE - Extract html2pptx library :
mkdir -p html2pptx && tar -xzf skills/public/pptx/html2pptx.tgz -C html2pptxhtml2pptx/ directory with the library files and CLI binariesPlan the presentation : Follow html2pptx.md "Design Philosophy" section for:
Set CSS variables : Override CSS variables in a shared file for colors, typography, and spacing (see css.md "Design System Variables")
const pptxgen = require("pptxgenjs");
const { html2pptx } = require("./html2pptx");
// Create a new pptx presentation
const pptx = new pptxgen();
pptx.layout = "LAYOUT_16x9"; // Must match HTML body dimensions
// Add an HTML-only slide
await html2pptx("slide1.html", pptx);
// Add a HTML slide with chart placeholders
const { slide: slide2, placeholders } = await html2pptx("slide2.html", pptx);
slide.addChart(pptx.charts.LINE, chartData, placeholders[0]);
// Save the presentation
await pptx.writeFile("output.pptx");
7. Visual validation : Convert to images and inspect for layout issues
* Convert PPTX to PDF first: `soffice --headless --convert-to pdf output.pptx`
* Then convert PDF to images: `pdftoppm -jpeg -r 150 output.pdf slide`
* This creates files like `slide-1.jpg`, `slide-2.jpg`, etc.
* Read each generated image file and carefully examine for:
* **Text cutoff** : Text being cut off by header bars, shapes, or slide edges
* **Text overlap** : Text overlapping with other text or shapes
* **Positioning issues** : Content too close to slide boundaries or other elements
* **Contrast issues** : Insufficient contrast between text and backgrounds
* **Alignment problems** : Elements not properly aligned with each other
* **Visual hierarchy** : Important content properly emphasized
* **CRITICAL: All slides MUST pass these validation checks before delivering to the user.** Do not skip this step or deliver presentations with visual defects.
* If issues found, fix them in the following order of priority:
1. **Increase margins** \- Add more padding/spacing around problematic elements
2. **Adjust font size** \- Reduce text size to fit within available space
3. **Rethink the layout entirely** \- If the above fixes don't work, redesign the slide layout
* Regenerate the presentation after making changes
* Repeat until all slides are visually correct
To edit slides in an existing PowerPoint presentation, work with the raw Office Open XML (OOXML) format. This involves unpacking the .pptx file, editing the XML content, and repacking it.
ooxml.md completely (see "CRITICAL: Read All Documentation First" section above)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>To create a presentation that follows an existing template's design, duplicate and re-arrange template slides before replacing placeholder content.
Extract template text AND create visual thumbnail grid :
python -m markitdown template.pptx > template-content.mdtemplate-content.md completely to understand the template contentspython 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 in SVG format)brew install --cask libreofficesudo apt-get install libreofficesudo apt-get install poppler-utils (for pdftoppm to convert PDF to images)Weekly Installs
44
Repository
GitHub Stars
7
First Seen
Jan 23, 2026
Security Audits
Gen Agent Trust HubWarnSocketPassSnykPass
Installed on
opencode40
gemini-cli39
codex37
cursor37
claude-code35
github-copilot32
GitHub Actions 官方文档查询助手 - 精准解答 CI/CD 工作流问题
53,800 周安装
Flutter并发与数据管理指南:Isolate、JSON序列化与UI性能优化
982 周安装
AI小说写作助手 - 专业小说创作全流程支持,涵盖构思、角色设计、世界观构建与章节续写
995 周安装
Cloudflare AI Agents 构建指南:创建有状态、实时通信的智能体与聊天机器人
45 周安装
TikTok营销技能:AI脚本生成、内容策略与自动化发布全流程指南
1,000 周安装
Markdown 词元优化器 - 微软 Copilot 工具,智能优化文档减少 AI 处理消耗
1,000 周安装
Flutter应用体积优化指南:分析、测量与缩减策略
999 周安装
.cssCreate HTML slides (960px × 540px for 16:9): Follow html2pptx.md for:
Create and run a JavaScript file using the html2pptx library to convert HTML slides to PowerPoint and save the presentation
Run with: NODE_PATH="$(npm root -g)" node your-script.js 2>&1
Use the html2pptx function to process each HTML file
Add charts and tables to placeholder areas using PptxGenJS API
Save the presentation using pptx.writeFile()
⚠️ CRITICAL: Your script MUST follow this example structure. Think aloud before writing the script to make sure that you correctly use the APIs. Do NOT call pptx.addSlide.
Using 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 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 completely to understand all shapes and their properties
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 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