powerpoint
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePowerPoint Skill
PowerPoint 自动化技能组件
Generates, updates, and manages PowerPoint slide decks using with YAML-driven content and styling definitions.
python-pptx通过结合YAML驱动的内容与样式定义,实现PowerPoint演示文稿的生成、更新与管理。
python-pptxOverview
概述
This skill provides Python scripts that consume YAML configuration files to produce PowerPoint slide decks. Each slide is defined by a file describing its layout, text, and shapes. A file defines dimensions, template configuration, layout mappings, metadata, and defaults.
content.yamlstyle.yamlSKILL.md covers technical reference: prerequisites, commands, script architecture, API constraints, and troubleshooting. For conventions and design rules (element positioning, visual quality, color and contrast, contextual styling), follow .
pptx.instructions.md本技能提供Python脚本,可读取YAML配置文件来生成PowerPoint演示文稿。每张幻灯片由描述其布局、文本和形状的文件定义。文件则定义尺寸、模板配置、布局映射、元数据及默认设置。
content.yamlstyle.yamlSKILL.md包含技术参考内容:前置要求、命令、脚本架构、API约束及故障排除。如需了解规范与设计规则(元素定位、视觉质量、颜色与对比度、上下文样式),请参考。
pptx.instructions.mdPrerequisites
前置要求
PowerShell
PowerShell
The script handles virtual environment creation and dependency installation automatically via . Requires , Python 3.11+, and PowerShell 7+.
Invoke-PptxPipeline.ps1uv syncuvInvoke-PptxPipeline.ps1uv syncuvInstalling uv
安装uv
If is not installed:
uvbash
undefined若未安装:
uvbash
undefinedmacOS / Linux
macOS / Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
curl -LsSf https://astral.sh/uv/install.sh | sh
Windows
Windows
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
Via pip (fallback)
Via pip (备用方案)
pip install uv
undefinedpip install uv
undefinedSystem Dependencies (Export and Validation)
系统依赖(导出与验证)
The Export and Validate actions require LibreOffice for PPTX-to-PDF conversion and optionally from poppler for PDF-to-JPG rendering. When is not available, PyMuPDF handles the image rendering.
pdftoppmpdftoppmThe Validate action's vision-based checks require the GitHub Copilot CLI for model access.
bash
undefined导出和验证操作需要LibreOffice来实现PPTX转PDF转换,可选使用poppler中的来实现PDF转JPG渲染。当不可用时,将由PyMuPDF处理图像渲染。
pdftoppmpdftoppm验证操作中的视觉检查需要GitHub Copilot CLI来访问模型。
bash
undefinedmacOS
macOS
brew install --cask libreoffice
brew install poppler # optional, provides pdftoppm
brew install --cask libreoffice
brew install poppler # 可选,提供pdftoppm
Linux
Linux
sudo apt-get install libreoffice poppler-utils
sudo apt-get install libreoffice poppler-utils
Windows (winget preferred, choco fallback)
Windows(优先使用winget,choco作为备选)
winget install TheDocumentFoundation.LibreOffice
winget install TheDocumentFoundation.LibreOffice
choco install libreoffice-still # alternative
choco install libreoffice-still # 替代方案
poppler: no winget package; use choco install poppler (optional, provides pdftoppm)
poppler:暂无winget包;可使用choco install poppler(可选,提供pdftoppm)
undefinedundefinedCopilot CLI (Vision Validation)
Copilot CLI(视觉验证)
The script uses the GitHub Copilot SDK to send slide images to vision-capable models. The Copilot CLI must be installed and authenticated:
validate_slides.pybash
undefinedvalidate_slides.pybash
undefinedInstall Copilot CLI
安装Copilot CLI
npm install -g @github/copilot-cli
npm install -g @github/copilot-cli
Authenticate (uses the same GitHub account as VS Code Copilot)
认证(使用与VS Code Copilot相同的GitHub账户)
copilot auth login
copilot auth login
Verify
验证
copilot --version
undefinedcopilot --version
undefinedRequired Files
必需文件
- — Dimensions, defaults, template configuration, and metadata
style.yaml - — Per-slide content definition (text, shapes, images, layout)
content.yaml - (Optional) — Custom Python for complex slide drawings
content-extra.py
- — 尺寸、默认设置、模板配置及元数据
style.yaml - — 单张幻灯片的内容定义(文本、形状、图像、布局)
content.yaml - (可选)— 用于复杂幻灯片绘制的自定义Python脚本
content-extra.py
Content Directory Structure
内容目录结构
All slide content lives under the working directory's folder:
content/text
content/
├── global/
│ ├── style.yaml # Dimensions, defaults, template config, and theme metadata
│ └── voice-guide.md # Voice and tone guidelines
├── slide-001/
│ ├── content.yaml # Slide 1 content and layout
│ └── images/ # Slide-specific images
│ ├── background.png
│ └── background.yaml # Image metadata sidecar
├── slide-002/
│ ├── content.yaml # Slide 2 content and layout
│ ├── content-extra.py # Custom Python for complex drawings
│ └── images/
│ └── screenshot.png
├── slide-003/
│ ├── content.yaml
│ └── images/
│ ├── diagram.png
│ └── diagram.yaml
└── ...所有幻灯片内容存储在工作目录的文件夹下:
content/text
content/
├── global/
│ ├── style.yaml # 尺寸、默认设置、模板配置及主题元数据
│ └── voice-guide.md # 语气与语调指南
├── slide-001/
│ ├── content.yaml # 幻灯片1的内容与布局
│ └── images/ # 幻灯片专属图片
│ ├── background.png
│ └── background.yaml # 图片元数据辅助文件
├── slide-002/
│ ├── content.yaml # 幻灯片2的内容与布局
│ ├── content-extra.py # 用于复杂绘制的自定义Python脚本
│ └── images/
│ └── screenshot.png
├── slide-003/
│ ├── content.yaml
│ └── images/
│ ├── diagram.png
│ └── diagram.yaml
└── ...Global Style Definition (style.yaml
)
style.yaml全局样式定义(style.yaml
)
style.yamlThe global defines dimensions, template configuration, layout mappings, metadata, and defaults. Color and font choices are specified per-element in each slide's rather than centralized in the style file.
style.yamlcontent.yamlSee the style.yaml template for the full template, field reference, and usage instructions.
全局定义尺寸、模板配置、布局映射、元数据及默认设置。颜色与字体选择在每张幻灯片的中按元素单独指定,而非集中在样式文件中。
style.yamlcontent.yaml完整模板、字段参考及使用说明请查看style.yaml 模板。
Per-Slide Content Definition (content.yaml
)
content.yaml单张幻灯片内容定义(content.yaml
)
content.yamlEach slide's defines layout, text, shapes, and positioning. All position and size values are in inches. Color values use hex format or references.
content.yaml#RRGGBB@theme_nameSee the content.yaml template for the full template, supported element types, supported shape types, and usage instructions.
每张幻灯片的定义布局、文本、形状及定位。所有位置与尺寸值以英寸为单位。颜色值使用十六进制格式或主题引用。
content.yaml#RRGGBB@theme_name完整模板、支持的元素类型、形状类型及使用说明请查看content.yaml 模板。
Complex Drawings (content-extra.py
)
content-extra.py复杂绘制(content-extra.py
)
content-extra.pyWhen a slide requires complex drawings that cannot be expressed through element definitions, create a file in the slide folder. The function signature is fixed. The build script calls it after placing standard elements.
content.yamlcontent-extra.pyrender()content.yamlSee the content-extra.py template for the full template, function parameters, and usage guidelines.
当幻灯片需要无法通过元素定义实现的复杂绘制时,可在幻灯片文件夹中创建文件。函数签名固定,构建脚本会在放置完标准元素后调用该函数。
content.yamlcontent-extra.pyrender()content.yaml完整模板、函数参数及使用指南请查看content-extra.py 模板。
Security Validation
安全验证
Before executing a file, the build script performs AST-based static analysis to reject dangerous code. Validation runs automatically unless the flag is passed.
content-extra.py--allow-scriptsAllowed imports:
- and all
pptxsubmodulespptx.* - Safe standard-library modules (e.g., ,
math,copy,json,re,pathlib,collections,itertools,functools,typing,enum,dataclasses,decimal,fractions,string)textwrap
Blocked imports:
- ,
subprocess,os,shutil,socket,ctypes,signal,multiprocessing,threading,http,urllib,ftplib,smtplib,imaplib,poplib,xmlrpc,webbrowser,code,codeop,compileall,py_compile,zipimport,pkgutil,runpy,ensurepip,venv,sqlite3,tempfile,shelve,dbm,pickle,marshal,importlib,systelnetlib - Any third-party package not on the allowlist
Blocked builtins:
- Dangerous: ,
eval,exec,__import__,compilebreakpoint - Indirect bypass: ,
getattr,setattr,delattr,globals,localsvars
Runtime namespace restriction:
Even after AST validation passes, the executed module runs in a restricted namespace where is limited to safe builtins only. The dangerous and indirect-bypass builtins listed above are removed from the module namespace before execution ( is kept because the import machinery requires it; the AST checker blocks direct calls).
__builtins____import____import__()--allow-scriptsPass to skip AST validation and namespace restriction for trusted content. This flag is required when a script legitimately needs blocked imports or builtins.
--allow-scriptscontent-extra.pybash
python scripts/build_deck.py \
--content-dir content/ \
--style content/global/style.yaml \
--output slide-deck/presentation.pptx \
--allow-scriptsWhen validation fails, the build raises with a message identifying the violation and file path.
ContentExtraError在执行文件前,构建脚本会基于AST进行静态分析,拒绝危险代码。除非传入参数,否则验证会自动运行。
content-extra.py--allow-scripts允许的导入:
- 及其所有
pptx子模块pptx.* - 安全的标准库模块(如、
math、copy、json、re、pathlib、collections、itertools、functools、typing、enum、dataclasses、decimal、fractions、string)textwrap
禁止的导入:
- 、
subprocess、os、shutil、socket、ctypes、signal、multiprocessing、threading、http、urllib、ftplib、smtplib、imaplib、poplib、xmlrpc、webbrowser、code、codeop、compileall、py_compile、zipimport、pkgutil、runpy、ensurepip、venv、sqlite3、tempfile、shelve、dbm、pickle、marshal、importlib、systelnetlib - 不在允许列表中的任何第三方包
禁止的内置函数:
- 危险函数:、
eval、exec、__import__、compilebreakpoint - 间接绕过函数:、
getattr、setattr、delattr、globals、localsvars
运行时命名空间限制:
即使AST验证通过,执行的模块仍会在受限命名空间中运行,其中仅包含安全的内置函数。上述危险函数和间接绕过函数会在执行前从模块命名空间中移除(会保留,因为导入机制需要它;AST检查器会阻止直接调用)。
__builtins____import____import__()--allow-scripts传入可跳过AST验证和命名空间限制,适用于可信内容。当脚本确实需要使用被禁止的导入或内置函数时,必须使用该参数。
--allow-scriptscontent-extra.pybash
python scripts/build_deck.py \
--content-dir content/ \
--style content/global/style.yaml \
--output slide-deck/presentation.pptx \
--allow-scripts当验证失败时,构建过程会抛出,并显示包含违规内容和文件路径的提示信息。
ContentExtraErrorScript Reference
脚本参考
All operations are available through the PowerShell orchestrator () or directly via the Python scripts. The PowerShell script manages the Python virtual environment and dependency installation automatically via .
Invoke-PptxPipeline.ps1uv sync所有操作可通过PowerShell编排器()或直接通过Python脚本执行。PowerShell脚本会通过自动管理Python虚拟环境和依赖安装。
Invoke-PptxPipeline.ps1uv syncBuild a Slide Deck
构建演示文稿
powershell
./scripts/Invoke-PptxPipeline.ps1 -Action Build `
-ContentDir content/ `
-StylePath content/global/style.yaml `
-OutputPath slide-deck/presentation.pptxbash
python scripts/build_deck.py \
--content-dir content/ \
--style content/global/style.yaml \
--output slide-deck/presentation.pptxReads all files in numeric order and generates the complete deck. Executes files when present.
content/slide-*/content.yamlcontent-extra.pypowershell
./scripts/Invoke-PptxPipeline.ps1 -Action Build `
-ContentDir content/ `
-StylePath content/global/style.yaml `
-OutputPath slide-deck/presentation.pptxbash
python scripts/build_deck.py \
--content-dir content/ \
--style content/global/style.yaml \
--output slide-deck/presentation.pptx按数字顺序读取所有文件,生成完整的演示文稿。若存在文件则会执行。
content/slide-*/content.yamlcontent-extra.pyBuild from a Template
从模板构建
[!WARNING]creates a NEW presentation inheriting only slide masters, layouts, and theme from the template. All existing slides are discarded. Use--templatefor partial rebuilds.--source
powershell
./scripts/Invoke-PptxPipeline.ps1 -Action Build `
-ContentDir content/ `
-StylePath content/global/style.yaml `
-OutputPath slide-deck/presentation.pptx `
-TemplatePath corporate-template.pptxbash
python scripts/build_deck.py \
--content-dir content/ \
--style content/global/style.yaml \
--output slide-deck/presentation.pptx \
--template corporate-template.pptxLoads slide masters and layouts from the template PPTX. Layout names in each slide's resolve against the template's layouts, with optional name mapping via the section in . Populate themed layout placeholders using the section in content YAML.
content.yamllayoutsstyle.yamlplaceholders[!WARNING]会创建一个新的演示文稿,仅从模板继承幻灯片母版、布局和主题。所有现有幻灯片会被丢弃。如需部分重建,请使用--template参数。--source
powershell
./scripts/Invoke-PptxPipeline.ps1 -Action Build `
-ContentDir content/ `
-StylePath content/global/style.yaml `
-OutputPath slide-deck/presentation.pptx `
-TemplatePath corporate-template.pptxbash
python scripts/build_deck.py \
--content-dir content/ \
--style content/global/style.yaml \
--output slide-deck/presentation.pptx \
--template corporate-template.pptx从模板PPTX加载幻灯片母版和布局。每张幻灯片中的布局名称会与模板中的布局匹配,也可通过的部分进行名称映射。使用内容YAML中的部分填充主题布局占位符。
content.yamlstyle.yamllayoutsplaceholdersUpdate Specific Slides
更新特定幻灯片
[!IMPORTANT] Use(not--source) for partial rebuilds. Combining--templateand--templateis not supported.--source
powershell
./scripts/Invoke-PptxPipeline.ps1 -Action Build `
-ContentDir content/ `
-StylePath content/global/style.yaml `
-OutputPath slide-deck/presentation.pptx `
-SourcePath slide-deck/presentation.pptx `
-Slides "3,7,15"bash
python scripts/build_deck.py \
--content-dir content/ \
--style content/global/style.yaml \
--source slide-deck/presentation.pptx \
--output slide-deck/presentation.pptx \
--slides 3,7,15Opens the existing deck, clears shapes on the specified slides, rebuilds them in-place from their , and saves. All other slides remain untouched. After building, verify the output slide count matches the original deck.
content.yaml[!IMPORTANT] 如需部分重建,请使用(而非--source)。不支持同时使用--template和--template参数。--source
powershell
./scripts/Invoke-PptxPipeline.ps1 -Action Build `
-ContentDir content/ `
-StylePath content/global/style.yaml `
-OutputPath slide-deck/presentation.pptx `
-SourcePath slide-deck/presentation.pptx `
-Slides "3,7,15"bash
python scripts/build_deck.py \
--content-dir content/ \
--style content/global/style.yaml \
--source slide-deck/presentation.pptx \
--output slide-deck/presentation.pptx \
--slides 3,7,15打开现有演示文稿,清除指定幻灯片上的形状,根据其原地重建,然后保存。其他所有幻灯片保持不变。构建完成后,请验证输出幻灯片数量与原演示文稿一致。
content.yamlExtract Content from Existing PPTX
从现有PPTX提取内容
powershell
./scripts/Invoke-PptxPipeline.ps1 -Action Extract `
-InputPath existing-deck.pptx `
-OutputDir content/bash
python scripts/extract_content.py \
--input existing-deck.pptx \
--output-dir content/Extracts text, shapes, images, and styling from an existing PPTX into the folder structure. Creates files for each slide and populates the from detected patterns.
content/content.yamlglobal/style.yamlpowershell
./scripts/Invoke-PptxPipeline.ps1 -Action Extract `
-InputPath existing-deck.pptx `
-OutputDir content/bash
python scripts/extract_content.py \
--input existing-deck.pptx \
--output-dir content/从现有PPTX中提取文本、形状、图像和样式,保存到文件夹结构中。为每张幻灯片创建文件,并根据检测到的模式填充。
content/content.yamlglobal/style.yamlExtract Specific Slides
提取特定幻灯片
powershell
./scripts/Invoke-PptxPipeline.ps1 -Action Extract `
-InputPath existing-deck.pptx `
-OutputDir content/ `
-Slides "3,7,15"bash
python scripts/extract_content.py \
--input existing-deck.pptx \
--output-dir content/ \
--slides 3,7,15Extracts only the specified slides (plus the global style). Useful for targeted updates on large decks.
powershell
./scripts/Invoke-PptxPipeline.ps1 -Action Extract `
-InputPath existing-deck.pptx `
-OutputDir content/ `
-Slides "3,7,15"bash
python scripts/extract_content.py \
--input existing-deck.pptx \
--output-dir content/ \
--slides 3,7,15仅提取指定幻灯片(加上全局样式)。适用于对大型演示文稿进行针对性更新。
Extraction Limitations
提取限制
- Picture shapes that reference external (linked) images instead of embedded blobs are recorded with . The script does not crash but the image must be re-embedded manually.
path: LINKED_IMAGE_NOT_EMBEDDED - When text elements inherit font, size, or color from the slide master or layout, the extraction records no inline styling. Content YAML for these elements needs explicit font properties added before rebuild.
- The function uses frequency analysis across all slides. For decks with mixed styling, review and adjust
detect_global_style()values manually after extraction.style.yaml
- 引用外部(链接)图像而非嵌入 blob 的图片形状会被记录为。脚本不会崩溃,但需要手动重新嵌入图像。
path: LINKED_IMAGE_NOT_EMBEDDED - 当文本元素从幻灯片母版或布局继承样式时,提取结果中不会包含内联样式。重建前需要在内容YAML中添加明确的字体属性。
- 函数通过对所有幻灯片进行频率分析来生成结果。对于样式混杂的演示文稿,提取后需要手动检查并调整
detect_global_style()的值。style.yaml
Validate a Deck
验证演示文稿
powershell
./scripts/Invoke-PptxPipeline.ps1 -Action Validate `
-InputPath slide-deck/presentation.pptx `
-ContentDir content/The Validate action runs a two- or three-step pipeline:
- Export — Clears stale slide images from the output directory, then renders slides to JPG images via LibreOffice (PPTX → PDF → JPG). When is used, output images are named to match original slide numbers (e.g.,
-Slidesfor slide 23), not sequential PDF page numbers.slide-023.jpg - PPTX validation — Checks PPTX-only properties () for speaker notes and slide count.
validate_deck.py - Vision validation (optional) — Sends slide images to a vision-capable model via the Copilot SDK () for visual quality checks. Runs when
validate_slides.pyor-ValidationPromptis provided.-ValidationPromptFile
For validation criteria (element positioning, visual quality, color contrast, content completeness), see Validation Criteria.
pptx.instructions.mdpowershell
./scripts/Invoke-PptxPipeline.ps1 -Action Validate `
-InputPath slide-deck/presentation.pptx `
-ContentDir content/验证操作会运行两步或三步流程:
- 导出 — 清除输出目录中的旧幻灯片图像,然后通过LibreOffice将幻灯片渲染为JPG图像(PPTX → PDF → JPG)。当使用参数时,输出图像会以原幻灯片编号命名(例如,幻灯片23命名为
-Slides),而非按PDF页码顺序命名。slide-023.jpg - PPTX验证 — 检查仅针对PPTX的属性(),如演讲者备注和幻灯片数量。
validate_deck.py - 视觉验证(可选) — 通过Copilot SDK将幻灯片图像发送至支持视觉的模型(),进行视觉质量检查。当提供
validate_slides.py或-ValidationPrompt参数时运行。-ValidationPromptFile
验证标准(元素定位、视觉质量、颜色对比度、内容完整性)请查看中的验证标准部分。
pptx.instructions.mdBuilt-in System Message
内置系统提示
The script includes a built-in system message that focuses on issue detection only (not full slide description). It checks overlapping elements, text overflow/cutoff, decorative line mismatch after title wraps, citation/footer collisions, tight spacing, uneven gaps, insufficient edge margins, alignment inconsistencies, low contrast, narrow text boxes, and leftover placeholders. For dense slides, near-edge placement or tight boundaries are acceptable when readability is not materially affected. The parameter provides supplementary user-level context and does not need to repeat these checks.
validate_slides.py-ValidationPromptvalidate_slides.py-ValidationPromptValidate with Vision Checks
结合视觉检查进行验证
powershell
./scripts/Invoke-PptxPipeline.ps1 -Action Validate `
-InputPath slide-deck/presentation.pptx `
-ContentDir content/ `
-ValidationPrompt "Validate visual quality. Focus on recently modified slides for content accuracy." `
-ValidationModel claude-haiku-4.5Vision validation results are written to in the image output directory, containing raw model responses per slide with quality findings. Per-slide response text is also written to files next to each slide image.
validation-results.jsonslide-NNN-validation.txtpowershell
./scripts/Invoke-PptxPipeline.ps1 -Action Validate `
-InputPath slide-deck/presentation.pptx `
-ContentDir content/ `
-ValidationPrompt "验证视觉质量。重点检查最近修改的幻灯片内容准确性。" `
-ValidationModel claude-haiku-4.5视觉验证结果会写入图像输出目录中的,包含每张幻灯片的原始模型响应及质量问题。每张幻灯片的响应文本也会写入对应幻灯片图像旁的文件。
validation-results.jsonslide-NNN-validation.txtValidate Specific Slides
验证特定幻灯片
powershell
./scripts/Invoke-PptxPipeline.ps1 -Action Validate `
-InputPath slide-deck/presentation.pptx `
-ContentDir content/ `
-Slides "3,7,15"Validates only the specified slides. When content directories cover fewer slides than the PPTX, the slide count check reports an informational note rather than an error.
powershell
./scripts/Invoke-PptxPipeline.ps1 -Action Validate `
-InputPath slide-deck/presentation.pptx `
-ContentDir content/ `
-Slides "3,7,15"仅验证指定幻灯片。当内容目录中的幻灯片数量少于PPTX中的数量时,幻灯片数量检查会显示信息性提示而非错误。
validate_slides.py CLI Reference
validate_slides.py 命令行参考
| Flag | Required | Default | Description |
|---|---|---|---|
| Yes | — | Directory containing |
| One of | — | Validation prompt text |
| One of | — | Path to file containing the validation prompt |
| No | | Vision model ID |
| No | stdout | JSON results file path |
| No | all | Comma-separated slide numbers to validate |
| No | — | Enable debug-level logging |
| 参数 | 是否必填 | 默认值 | 描述 |
|---|---|---|---|
| 是 | — | 包含 |
| | — | 验证提示文本 |
| | — | 包含验证提示的文件路径 |
| 否 | | 视觉模型ID |
| 否 | stdout | JSON结果文件路径 |
| 否 | 全部 | 要验证的幻灯片编号(逗号分隔) |
| 否 | — | 启用调试级日志 |
validate_deck.py CLI Reference
validate_deck.py 命令行参考
| Flag | Required | Default | Description |
|---|---|---|---|
| Yes | — | Input PPTX file path |
| No | — | Content directory for slide count comparison |
| No | all | Comma-separated slide numbers to validate |
| No | stdout | JSON results file path |
| No | — | Markdown report file path |
| No | — | Directory for per-slide JSON files ( |
| 参数 | 是否必填 | 默认值 | 描述 |
|---|---|---|---|
| 是 | — | 输入PPTX文件路径 |
| 否 | — | 用于幻灯片数量对比的内容目录 |
| 否 | 全部 | 要验证的幻灯片编号(逗号分隔) |
| 否 | stdout | JSON结果文件路径 |
| 否 | — | Markdown报告文件路径 |
| 否 | — | 存储单张幻灯片JSON文件的目录( |
Validation Outputs
验证输出
When run through the pipeline, validation produces these files in the image output directory:
| File | Format | Content |
|---|---|---|
| JSON | Per-slide PPTX property issues (speaker notes, slide count) |
| Markdown | Human-readable report for PPTX property validation |
| JSON | Consolidated vision model responses with quality findings |
| Text | Per-slide vision response text (next to |
| JSON | Per-slide PPTX property validation result (next to |
Per-slide vision text files are written alongside their corresponding images, enabling agents to read validation findings for individual slides without parsing the consolidated JSON file.
slide-NNN.jpg通过编排器运行验证时,会在图像输出目录中生成以下文件:
| 文件 | 格式 | 内容 |
|---|---|---|
| JSON | 单张幻灯片的PPTX属性问题(演讲者备注、幻灯片数量) |
| Markdown | PPTX属性验证的人类可读报告 |
| JSON | 整合后的视觉模型响应及质量问题 |
| 文本 | 单张幻灯片的视觉响应文本(位于 |
| JSON | 单张幻灯片的PPTX属性验证结果(位于 |
单张幻灯片的视觉文本文件会与对应的图像放在一起,方便工具读取单张幻灯片的验证结果,无需解析整合后的JSON文件。
slide-NNN.jpgValidation Scope for Changed Slides
变更幻灯片的验证范围
When validating after modifying or adding specific slides, always validate a block that includes one slide before and one slide after the changed or added slides. This catches edge-proximity issues, transition inconsistencies, and spacing problems that arise between adjacent slides.
For example, when slides 5 and 6 were changed, validate slides 4 through 7:
powershell
./scripts/Invoke-PptxPipeline.ps1 -Action Validate `
-InputPath slide-deck/presentation.pptx `
-ContentDir content/ `
-Slides "4,5,6,7" `
-ValidationPrompt "Check for text overlay, overflow, margin issues, color contrast"在修改或添加特定幻灯片后进行验证时,应始终验证包含变更/添加幻灯片的前一张和后一张的范围。这样可以捕获相邻幻灯片之间出现的边缘 proximity 问题、过渡不一致及间距问题。
例如,当修改了幻灯片5和6时,验证幻灯片4至7:
powershell
./scripts/Invoke-PptxPipeline.ps1 -Action Validate `
-InputPath slide-deck/presentation.pptx `
-ContentDir content/ `
-Slides "4,5,6,7" `
-ValidationPrompt "检查文本重叠、溢出、边距问题、颜色对比度"Export Slides to Images
将幻灯片导出为图像
powershell
./scripts/Invoke-PptxPipeline.ps1 -Action Export `
-InputPath slide-deck/presentation.pptx `
-ImageOutputDir slide-deck/validation/ `
-Slides "1,3,5" `
-Resolution 150bash
undefinedpowershell
./scripts/Invoke-PptxPipeline.ps1 -Action Export `
-InputPath slide-deck/presentation.pptx `
-ImageOutputDir slide-deck/validation/ `
-Slides "1,3,5" `
-Resolution 150bash
undefinedStep 1: PPTX to PDF
步骤1:PPTX转PDF
python scripts/export_slides.py
--input slide-deck/presentation.pptx
--output slide-deck/validation/slides.pdf
--slides 1,3,5
--input slide-deck/presentation.pptx
--output slide-deck/validation/slides.pdf
--slides 1,3,5
python scripts/export_slides.py
--input slide-deck/presentation.pptx
--output slide-deck/validation/slides.pdf
--slides 1,3,5
--input slide-deck/presentation.pptx
--output slide-deck/validation/slides.pdf
--slides 1,3,5
Step 2: PDF to JPG (pdftoppm from poppler)
步骤2:PDF转JPG(使用poppler中的pdftoppm)
pdftoppm -jpeg -r 150 slide-deck/validation/slides.pdf slide-deck/validation/slide
Converts specified slides to JPG images for visual inspection. The PowerShell orchestrator handles both steps automatically, clears stale images before exporting, names output images to match original slide numbers when `-Slides` is used, and uses a PyMuPDF fallback when `pdftoppm` is not installed.
When running the two-step process manually (outside the pipeline), note that `render_pdf_images.py` uses sequential numbering by default. Pass `--slide-numbers` to map output images to original slide positions:
```bash
python scripts/render_pdf_images.py \
--input slide-deck/validation/slides.pdf \
--output-dir slide-deck/validation/ \
--dpi 150 \
--slide-numbers 1,3,5Dependencies: Requires LibreOffice for PPTX-to-PDF conversion and either (from ) or (pip) for PDF-to-JPG rendering.
pdftoppmpopplerpymupdfpdftoppm -jpeg -r 150 slide-deck/validation/slides.pdf slide-deck/validation/slide
将指定幻灯片转换为JPG图像,用于视觉检查。PowerShell编排器会自动处理这两个步骤,导出前清除旧图像,当使用`-Slides`参数时输出图像以原幻灯片编号命名,当`pdftoppm`不可用时会使用PyMuPDF作为备选方案。
当手动运行两步流程(在编排器外)时,注意`render_pdf_images.py`默认按顺序编号。传入`--slide-numbers`参数可将输出图像映射到原幻灯片位置:
```bash
python scripts/render_pdf_images.py \
--input slide-deck/validation/slides.pdf \
--output-dir slide-deck/validation/ \
--dpi 150 \
--slide-numbers 1,3,5依赖:需要LibreOffice实现PPTX转PDF转换,需要(来自)或(通过pip安装)实现PDF转JPG渲染。
pdftoppmpopplerpymupdfScript Architecture
脚本架构
The build and extraction scripts use shared modules in the directory:
scripts/| Module | Purpose |
|---|---|
| Shared utilities: exit codes, logging configuration, slide filter parsing, unit conversion ( |
| Color resolution ( |
| Font resolution, family normalization, weight suffix handling, alignment mapping |
| Shape constant map (29 entries + circle alias), auto-shape name mapping, rotation utilities |
| Solid, gradient, and pattern fill application/extraction; line/border styling with dash styles |
| Text frame properties (margins, auto-size, vertical anchor), paragraph properties (spacing, level), run properties (underline, hyperlink) |
| Table element creation and extraction with cell merging, banding, and per-cell styling |
| Chart element creation and extraction for 12 chart types (column, bar, line, pie, scatter, bubble, etc.) |
| PPTX-only validation for speaker notes and slide count |
| Vision-based slide issue detection and quality validation via Copilot SDK with built-in checks and plain-text per-slide output |
| PDF-to-JPG rendering via PyMuPDF with optional slide-number-based naming |
构建和提取脚本使用目录下的共享模块:
scripts/| 模块 | 用途 |
|---|---|
| 共享工具:退出码、日志配置、幻灯片过滤器解析、单位转换( |
| 颜色解析( |
| 字体解析、家族标准化、字重后缀处理、对齐映射 |
| 形状常量映射(29个条目+圆形别名)、自动形状名称映射、旋转工具 |
| 纯色、渐变和图案填充的应用/提取;带虚线样式的线条/边框样式 |
| 文本框属性(边距、自动大小、垂直锚点)、段落属性(间距、级别)、文本片段属性(下划线、超链接) |
| 表格元素的创建与提取,支持单元格合并、条纹样式和单元格级样式 |
| 12种图表类型(柱状图、条形图、折线图、饼图、散点图、气泡图等)的创建与提取 |
| 仅针对PPTX的验证,检查演讲者备注和幻灯片数量 |
| 通过Copilot SDK进行基于视觉的幻灯片问题检测和质量验证,包含内置检查和单张幻灯片纯文本输出 |
| 通过PyMuPDF实现PDF转JPG渲染,支持基于幻灯片编号的命名 |
python-pptx Constraints
python-pptx 约束
- python-pptx does NOT support SVG images. Always convert to PNG via or
cairosvg.Pillow - python-pptx cannot create new slide masters or layouts programmatically. Use blank layouts or start from a template PPTX with the argument.
--template - Transitions and animations are preserved when opening and saving existing files, but cannot be created or modified via the API.
- When extracting content, slide master and layout inheritance means many text elements have no inline styling. Add explicit font properties in content YAML before rebuilding.
- The Export and Validate actions require LibreOffice for PPTX-to-PDF conversion. The PowerShell orchestrator checks for LibreOffice availability before starting and provides platform-specific install instructions if missing.
- Accessing on slides with inherited backgrounds replaces them with
background.fill. CheckNoFillbefore accessing the fill property.slide.follow_master_background - Gradient fills use the python-pptx API with
GradientFillobjects. Each stop specifies a position (0–100) and a color.GradientStop - Theme colors resolve via enum. Brightness adjustments apply through the color format's
MSO_THEME_COLORproperty.brightness - Template-based builds load layouts by name or index. Layout name resolution falls back to index 6 (blank) when no match is found.
- python-pptx 不支持SVG图像。请通过或
cairosvg转换为PNG格式。Pillow - python-pptx无法通过编程方式创建新的幻灯片母版或布局。请使用空白布局,或通过参数从模板PPTX开始构建。
--template - 打开和保存现有文件时会保留切换效果和动画,但无法通过API创建或修改它们。
- 提取内容时,由于幻灯片母版和布局的继承关系,许多文本元素没有内联样式。重建前需要在内容YAML中添加明确的字体属性。
- 导出和验证操作需要LibreOffice实现PPTX转PDF转换。PowerShell编排器会在启动前检查LibreOffice是否可用,若缺失会提供平台专属的安装说明。
- 对继承背景的幻灯片访问会将其替换为
background.fill。访问填充属性前请检查NoFill。slide.follow_master_background - 渐变填充使用python-pptx的API和
GradientFill对象。每个停止点指定位置(0–100)和颜色。GradientStop - 主题颜色通过枚举解析。亮度调整通过颜色格式的
MSO_THEME_COLOR属性实现。brightness - 基于模板的构建通过名称或索引加载布局。当未找到匹配项时,布局名称解析会回退到索引6(空白布局)。
Troubleshooting
故障排除
| Issue | Cause | Solution |
|---|---|---|
| SVG runtime error | python-pptx cannot embed SVG | Convert to PNG via |
| Text overlay between elements | Insufficient vertical spacing | Follow element positioning conventions in |
| Width overflow off-slide | Element extends beyond slide boundary | Follow element positioning conventions in |
| Bright accent color unreadable as fill | White text on bright background | Darken accent to ~60% saturation for box fills |
| Background fill replaced with NoFill | Accessed | Check |
| Missing speaker notes | Notes not specified in | Add |
| LibreOffice not found during Validate | Validate exports slides to images first | Install LibreOffice: |
| uv package manager not installed | Install uv: |
| Python not found by uv | No Python 3.11+ on PATH | Install via |
| Missing or corrupt | Delete |
| Import errors in scripts | Dependencies not installed or stale venv | Run |
| 问题 | 原因 | 解决方案 |
|---|---|---|
| SVG运行时错误 | python-pptx无法嵌入SVG | 添加前通过 |
| 元素间文本重叠 | 垂直间距不足 | 遵循 |
| 宽度超出幻灯片边界 | 元素延伸至幻灯片边界之外 | 遵循 |
| 亮色强调色作为填充时可读性差 | 亮色背景上使用白色文本 | 将强调色饱和度降低至约60%用于框填充 |
| 背景填充被替换为NoFill | 对继承背景的幻灯片访问了 | 访问前检查 |
| 缺失演讲者备注 | | 为所有内容幻灯片添加 |
| 验证时未找到LibreOffice | 验证操作需要先将幻灯片导出为图像 | 安装LibreOffice:macOS使用 |
未找到 | 未安装uv包管理器 | 安装uv:macOS/Linux使用 |
| uv无法找到Python | PATH中没有Python 3.11+ | 通过 |
| | 删除技能根目录下的 |
| 脚本导入错误 | 依赖未安装或虚拟环境过时 | 从技能根目录运行 |
Environment Recovery
环境恢复
When scripts fail due to missing modules, import errors, or a corrupt virtual environment, recover with:
bash
cd .github/skills/experimental/powerpoint
rm -rf .venv
uv syncThis recreates the virtual environment from scratch using as the single source of truth. The orchestrator runs automatically on each invocation unless is passed.
pyproject.tomlInvoke-PptxPipeline.ps1uv sync-SkipVenvSetupWhen itself is not available, install it first (see Installing uv above), then retry. When Python 3.11+ is not available, run to have uv fetch and manage the interpreter.
uvuv python install 3.11Brought to you by microsoft/hve-core
🤖 Crafted with precision by ✨Copilot following brilliant human instruction, then carefully refined by our team of discerning human reviewers.
当脚本因缺失模块、导入错误或虚拟环境损坏而失败时,可通过以下步骤恢复:
bash
cd .github/skills/experimental/powerpoint
rm -rf .venv
uv sync此步骤会以为唯一可信源,从头重新创建虚拟环境。编排器在每次调用时都会自动运行,除非传入参数。
pyproject.tomlInvoke-PptxPipeline.ps1uv sync-SkipVenvSetup当本身不可用时,请先安装uv(见上方安装uv部分),然后重试。当Python 3.11+不可用时,运行让uv获取并管理解释器。
uvuv python install 3.11由microsoft/hve-core提供
🤖 由✨Copilot根据出色的人类指令精准打造,再经我们挑剔的人工审核团队精心优化。