PPT creation, editing, and analysis
Quick Setup
bash "$SKILL_DIR/setup.sh" # Interactive environment check + install
Routing: Academic / Paper-Based Presentations → Beamer
STOP — check this before doing any work.
If the request matches any trigger below, skip the PPTX workflow entirely.
Read beamer.md in this directory and follow its instructions.
| Trigger |
Typical phrasing |
| Reading / summarizing a paper to make slides |
"read this PDF and make slides", "make slides from this paper" |
| Academic / scientific / research presentation |
"conference talk", "research presentation", "academic presentation" |
| Thesis or dissertation defense |
"thesis defense", "proposal defense", "defense slides" |
| Any scholarly audience presentation |
"academic PPT", "paper presentation", "research talk" |
| STEM / science courseware |
"STEM slides", "science lecture", "math/physics/chemistry courseware" |
| User mentions a "paper" or "thesis" in any language |
"present this paper", "talk about this thesis", "summarize this article into slides" |
| Uploaded file is clearly an academic paper |
"make slides from this", "help me present this" — where the uploaded PDF contains academic indicators (abstract, keywords, references, DOI, author affiliations, journal name) in the first 3 pages |
Beamer output format: PDF-style slides only.
Routing decision rule: The trigger table above applies to all languages. For non-English requests, match by semantic meaning — mentally translate the user's intent into English and check against the triggers.
Important: In many languages (e.g., Chinese, Japanese, Korean), "PPT" is a generic colloquial word for "slides" or "presentation" — it does NOT indicate a preference for .pptx format. Only route to the PPTX workflow when the user explicitly requests .pptx format (e.g., "I need a .pptx file", "export as pptx") or the content is clearly non-academic (e.g., marketing, business, teaching children).
Overview
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.
Reading and analyzing content
Text extraction
To read the text content of a presentation, convert it to markdown:
python -m markitdown path-to-file.pptx
Raw XML access
For comments, speaker notes, slide layouts, animations, design elements, or complex formatting, unpack the presentation and inspect its raw XML.
Unpacking a file
python ooxml/scripts/unpack.py <office_file> <output_dir>
Note: unpack.py is at skills/pptx/ooxml/scripts/unpack.py relative to the project root. If not found, run find . -name "unpack.py" to locate it.
Key file structures
| Path |
Contents |
ppt/presentation.xml |
Main metadata and slide references |
ppt/slides/slide{N}.xml |
Per-slide content |
ppt/notesSlides/notesSlide{N}.xml |
Speaker notes |
ppt/comments/modernComment_*.xml |
Slide comments |
ppt/slideLayouts/ |
Layout templates |
ppt/slideMasters/ |
Master slide templates |
ppt/theme/ |
Theme and styling |
ppt/media/ |
Images and other media |
Typography and color extraction
When emulating an existing design, extract typography and colors before starting:
- Theme file —
ppt/theme/theme1.xml: colors (<a:clrScheme>), fonts (<a:fontScheme>)
- Slide content —
ppt/slides/slide1.xml: actual font usage (<a:rPr>) and colors
- Global search — grep for
<a:solidFill>, <a:srgbClr>, and font references across all XML files
Creating a new PowerPoint presentation using a template
When the user upload a pptx file,and do not ask you to create a fully new pptx,you must create a presentation that follows an existing template's design, you'll need to duplicate and re-arrange template slides before then replacing placeholder content.
Workflow
Extract template text AND create visual thumbnail grid:
- Extract text:
python -m markitdown template.pptx > template-content.md
- Read
template-content.md: Read the entire file. NEVER set any range limits.
- Create thumbnail grids:
python scripts/thumbnail.py template.pptx
- See Creating Thumbnail Grids section for details
Analyze template and save inventory to a file:
Create presentation outline based on template inventory:
- Choose layouts that match your content structure
- CRITICAL: Match layout structure to actual content:
- Single-column layouts: Use for unified narrative or single topic
- Two-column layouts: Use ONLY when you have exactly 2 distinct items
- Three-column layouts: Use ONLY when you have exactly 3 distinct items
- Image + text layouts: Use ONLY when you have actual images
- Count your actual content pieces BEFORE selecting layout
- Save
outline.md with content AND template mapping
Duplicate, reorder, and delete slides using rearrange.py:
python scripts/rearrange.py template.pptx working.pptx 0,34,34,50,52
Extract ALL text using the inventory.py script:
python scripts/inventory.py working.pptx text-inventory.json
Read text-inventory.json entirely. NEVER set range limits.
Generate replacement text and save to JSON file:
- Verify which shapes exist in inventory — only reference shapes that are present
- Add
"paragraphs" field to shapes that need content
- ALL text shapes from inventory will be cleared unless you provide "paragraphs"
- Paragraphs with bullets are automatically left-aligned
- Do NOT include bullet symbols (bullet, -, *) in text — they're added automatically
- Save to
replacement-text.json
CRITICAL — JSON generation rules (learned from practice):
- Always use
json.dump() to write the file — never write raw JSON strings in Python code.
Raw strings may embed unescaped " characters (e.g. "三遥", "线上+线下") that silently
break JSON parsing. json.dump(data, f, ensure_ascii=False, indent=2) handles all escaping
automatically.
- Respect small box character limits — check
width and font_size from inventory before
writing text for numeric/label shapes. A box of width ≤ 0.7" at font_size ≥ 16pt can hold
roughly 3–4 characters max. Keep percentage values like "99.7%" to ≤ 4 chars, or shorten
(e.g. "100%" instead of "99.96%").
- Match replacement length to original — for body text boxes, count characters in the
original inventory text. Replacements significantly longer than the original will overflow.
When in doubt, err shorter rather than longer.
- Test incrementally — validate with a 5-slide subset before writing the full deck.
replace.py blocks on overflow errors; fix them slide-by-slide rather than all at once.
Apply replacements:
python scripts/replace.py working.pptx replacement-text.json output.pptx
Creating a new PowerPoint presentation without a template
When creating a new PowerPoint presentation from scratch, use the Design System + Component workflow.
Step 0 — Scene Classification (MANDATORY)
Before ANY design work, classify the presentation into one of the five scenes below:
| Scene |
Keywords / Triggers |
| Teaching / Training |
course, teaching, training, lecture, courseware, knowledge points, lesson plan |
| Work Report / Review |
report, review, summary, retrospective, OKR, KPI, quarterly, annual |
| Proposal / Pitch |
proposal, plan, pitch, investor, roadshow, business plan |
| Thesis Defense / Academic |
thesis, defense, research, academic, topic, graduation project — → if source is a paper/PDF or audience is academic, read beamer.md instead |
| General |
None of the above, or user did not specify |
Step 1 — Select Theme (MANDATORY)
Read themes.md and select a theme based on scene and content tone.
Output: State your chosen theme name, your chosen accent variant (A/B/C), and the full color palette (primary-80, primary-90, primary-5, accent, etc.) before writing any code.
Accent variant selection: Each theme offers 3 accent colors (A = default, B, C). Choose the variant that best matches the content tone. You may also mix — e.g., use accent-A for most slides and accent-B for emphasis pages — but keep the primary palette constant.
Theme selection tips:
- Work report → Ocean or Graphite
- Proposal / pitch → Ocean, Sandstone, or Twilight
- Teaching / courseware → Forest or Ocean
- Thesis defense → read
beamer.md (PDF output); if .pptx is explicitly required, use Graphite or Forest
- Tech keynote / product launch → Deep Mineral or Mono
- Cultural / lifestyle / brand → Warm Retro
- ESG / sustainability → Deep Forest or Forest
- Consumer / lifestyle / female audience → Coral
- Healthcare / wellness / eco → Mint
- SaaS / AI / onboarding → Azure
- Annual events / launches / high-energy → Ember
- General → any theme that fits the content
After selecting a theme, note its Image Keywords and Mask Color — you will need them in Step 5.5.
Step 2 — Read Design System (MANDATORY)
Read design-system.md. Understand the color system (mandatory) and creative principles (guidelines). The color scale is the only hard constraint — everything else (spacing, font sizes, layout) is flexible.
Step 3 — Read HTML-to-PPTX Guide (MANDATORY)
Read html2pptx.md completely from start to finish. NEVER set any range limits when reading this file.
Step 4 — Plan Slide Sequence
For each slide, decide:
- Which component from
components.md to use as a starting point (or design from scratch)
- What content to fill in — be generous with content; fill the slide
- How to remix the component — change spacing, font sizes, card styles, backgrounds, proportions to create variety
KEY PRINCIPLES:
- Read
components.md for available starting points
- Also read
data-viz-components.md for data visualization components
- Adjacent slides MUST look distinctly different — vary layout structure, background, card treatment
- Fill the slide: Avoid large empty areas. If content is sparse, use larger typography, more generous spacing, bigger visual elements, or add decorative elements to create visual richness
- Every content slide should have at least one non-text visual element (color block, stat number, chart, icon, accent bar, photo, shape)
- Alternate between high-density and low-density pages for rhythm
- Use data visualization components when content contains numbers, comparisons, percentages
- Tables are a great way to enrich content — use
content-table* or content-chart-* from components.md whenever content involves structured data, feature comparisons, schedules, or multi-attribute lists
Anti-whitespace strategies (use when a slide feels empty):
- Increase font sizes (e.g., body from 15pt to 17pt, headings from 22pt to 26pt)
- Add colored background blocks or sections
- Use a darker or tinted background instead of pure white
- Add decorative elements (accent bars, shapes, gradient bands)
- Expand card padding and spacing
- Use a photo background with mask overlay
- Switch from a text-heavy layout to a visual-heavy one
Note: Not all whitespace is bad. KPI pages, quote pages, and big-number focus pages are designed to have generous whitespace — that's intentional emphasis. Only fix whitespace on content-heavy pages (bullet lists, card grids, text blocks) where it looks accidental. See design-system.md §2.2 for the full distinction.
Slide sequence pattern (recommended):
1. Cover → PREFER cover-photo-mask (with downloaded photo + theme mask)
→ Fallback: cover-dark-hero (no photo needed) or cover-split
2. TOC → toc-card-grid (surface bg) / toc-big-number (visual variety)
3. Section divider (optional) → divider-photo-mask (different photo from cover)
→ or divider-gradient / divider-bold-center
4. Content page A → light background, visually rich component
5. Content page B → ★ DARK BACKGROUND ★ (content-dark-bullets / dark-kpi / dark-split)
6. Section divider (optional) → different variant from #3
7. Content page C → image-based (split-text-visual, photo-cards, etc.)
8. Content page D → data-focused (kpi-row, big-number-focus, etc.)
9. Closing → dark background echoing cover color
Background rhythm target: ~40% white, ~25% surface/tinted, ~20% dark, ~15% photo
Step 5 — Generate HTML from Components
For each slide:
- Start from a component template in
components.md, or design from scratch
- Replace all
${variable} placeholders with actual theme color values
- Replace placeholder text with actual content
- Adjust element count (add/remove cards, list items) as needed
- Before writing each slide's HTML: Check the Card Style Cookbook at the top of components.md. Pick a different card style from the previous slide. Also check if this slide should use a Dark Background Content Template.
- Be creative: Freely modify spacing, font sizes, card styles, proportions, background treatments, and decorative elements across pages. The only hard constraints are the html2pptx engine limitations (no flex-wrap, no negative margins, no DIV background-image, no CSS gradients). Use the design-system.md Quick Reference for suggested ranges, but treat them as starting points, not limits.
- Card styles: Use the Card Style Cookbook in components.md to swap between shadow/outline/solid/accent-bar/dark card styles. No 2 adjacent slides should use the same card style.
- Title bars: All content slides must use the same header style — pick one title bar variant from components.md and apply it consistently across every content page.
- Dark pages: Use the Dark Background Content Templates in components.md for rhythm-breaking dark slides. Aim for at least 1 dark content page per 4 slides.
- Fill the slide: If there's visible empty space, increase font sizes, add visual elements, expand padding, or use a colored/photo background. A well-filled slide looks professional; excessive whitespace looks unfinished.
Step 5.8 — Visual Diversity Check (RECOMMENDED)
Before converting to PPTX, do a quick scan of your slide sequence:
- Are adjacent slides visually distinct (different layout, background, card style)?
- Is there enough variety across the deck (multiple layout structures, card treatments, background approaches)?
- Is there at least one dramatic "rhythm breaker" page?
- Do real photographs appear on covers and at least one other slide?
If the answer to any is "no", revise before proceeding.
Step 6 — Convert and Validate
Create and run a JavaScript file using html2pptx.js to convert HTML slides to PowerPoint:
const pptxgen = require('pptxgenjs');
const html2pptx = require('./html2pptx');
const pptx = new pptxgen();
pptx.layout = 'LAYOUT_16x9';
// Optional: custom font configuration
const fontConfig = { cjk: 'Microsoft YaHei', latin: 'Corbel' };
// Process ALL slides with warnings collection
const allWarnings = [];
for (const htmlFile of slideFiles) {
const { slide, placeholders, warnings } = await html2pptx(htmlFile, pptx, { fontConfig });
allWarnings.push(...warnings);
}
// Add charts to placeholder areas if any
if (placeholders.length > 0) {
slide.addChart(pptx.charts.LINE, chartData, placeholders[0]);
}
await pptx.writeFile('output.pptx');
Check warnings: Review warnings output. Blocking issues (overflow, font < 11pt) must be fixed. Non-blocking warnings (bounds, balance, density) are suggestions — use judgment on whether to fix them.
Visual validation: Generate thumbnails and inspect for layout issues:
python scripts/thumbnail.py output.pptx workspace/thumbnails --cols 4
- Read and carefully examine the thumbnail image 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
- Consistency check: All body text same font and size? All page margins consistent? All content slides use the same header style?
- If issues found, adjust HTML and regenerate
- Repeat until all slides are visually correct
Step 6.5 — Final Quality Check (RECOMMENDED)
Before finalizing, do a quick visual quality scan:
- ✅ Real photographs used (cover + at least 1 other slide)
- ✅ Background variety (at least 3 different treatments)
- ✅ No 2 consecutive slides look the same
- ✅ Multiple layout structures used (aim for 5+)
- ✅ Card styles vary across pages
- ✅ Every slide has a clear visual focal point
- ✅ At least 1 dramatic full-bleed or dark page exists
- ✅ All referenced image files exist and are > 10KB
If major issues are found, fix and regenerate. Minor imperfections are acceptable — don't over-optimize at the cost of creativity.
Design Hard Rules (ALWAYS ENFORCED)
These rules are split into engine constraints (violating them causes broken output) and design principles (ensuring quality).
Engine Constraints (technical — cannot be violated):
[ENGINE] Slide canvas is 720×405pt — content exceeding this overflows
[ENGINE] All colors must come from the theme color scale — no arbitrary grays (#666 #999 #DDD)
[ENGINE] font-family must include a CJK font name to trigger correct mapping
[ENGINE] Do not use flex-wrap — multi-row layouts must use separate flex containers
[ENGINE] Do not use negative margins — they cause text stacking in PPT
[ENGINE] Multi-column equal-width cards must use fixed width + flex-shrink:0, not flex:1
[ENGINE] Background images only work on <body>, not <div> — DIV background-image is not supported
[ENGINE] Images must be local file paths, not URLs
[ENGINE] Titles and short labels (<10 characters) should use white-space:nowrap
[ENGINE] Numeric sequences (e.g. 01/02/03, $12M) should use white-space:nowrap
Design Principles (creative quality — strongly encouraged):
[DESIGN] Adjacent slides should use different layouts, backgrounds, and card styles
[DESIGN] Every content slide should have at least one visual focal point
[DESIGN] Cover and closing page should echo each other
[DESIGN] Prefer cutting content over shrinking fonts — only when a slide is already well-filled and overflow is imminent; never cut content preemptively
[DESIGN] Aim for 5+ layout structures, 3+ card styles, 3+ background treatments across the deck
[DESIGN] Insert a rhythm-breaking page every 3-4 slides
[DESIGN] Background images should have a mask overlay for text readability
[DESIGN] Content should be vertically balanced, not crammed at the top
[DESIGN] Accent colors must have HSL saturation ≤ 65% — high-saturation colors look garish on projection
[DESIGN] Large color blocks (>15% page area) should use S ≤ 50% — only small accents can be vivid
[DESIGN] All content slides must use the same header style — pick one title bar variant and apply it consistently across all content pages
Editing an existing PowerPoint presentation
When editing slides in an existing PowerPoint presentation, work with raw Office Open XML (OOXML) format.
Workflow
- MANDATORY - READ ENTIRE FILE: Read
ooxml.md (~500 lines) completely from start to finish. NEVER set any range limits when reading this file.
- Unpack the presentation:
python ooxml/scripts/unpack.py <office_file> <output_dir>
- Edit the XML files (primarily
ppt/slides/slide{N}.xml and related files)
- CRITICAL: Validate immediately after each edit:
python ooxml/scripts/validate.py <dir> --original <file>
- Pack the final presentation:
python ooxml/scripts/pack.py <input_directory> <office_file>
Creating Thumbnail Grids
python scripts/thumbnail.py template.pptx [output_prefix]
Features:
- Creates:
thumbnails.jpg (or thumbnails-1.jpg, thumbnails-2.jpg for large decks)
- Default: 5 columns, max 30 slides per grid (5x6)
- Custom prefix:
python scripts/thumbnail.py template.pptx my-grid
- Adjust columns:
--cols 4 (range: 3-6)
- Slides are zero-indexed (Slide 0, Slide 1, etc.)
Converting Slides to Images
Convert PPTX to PDF:
soffice --headless --convert-to pdf template.pptx
Convert PDF pages to JPEG images:
pdftoppm -jpeg -r 150 template.pdf slide
Code Style Guidelines
IMPORTANT: When generating code for PPTX operations:
- Write concise code
- Avoid verbose variable names and redundant operations
- Avoid unnecessary print statements
Dependencies
Required dependencies (should already be installed):
- markitdown:
pip install "markitdown[pptx]" (text extraction)
- pptxgenjs:
npm install -g pptxgenjs (creating presentations)
- playwright:
npm install -g playwright (HTML rendering)
- react-icons:
npm install -g react-icons react react-dom (icons)
- sharp:
npm install -g sharp (SVG rasterization and image processing)
- LibreOffice:
sudo apt-get install libreoffice (PDF conversion)
- Poppler:
sudo apt-get install poppler-utils (pdftoppm)
- defusedxml:
pip install defusedxml (secure XML parsing)
1---2name: ppt3description: Presentation creation, editing, and analysis for .pptx files: (1) Creating new presentations, (2) Modifying or editing content, (3) Working with layouts, (4) Adding comments or speaker notes. Academic/paper-based presentations use the embedded Beamer module at end of this file (PDF output only).4license: Proprietary. LICENSE.txt has complete terms5---67# PPT creation, editing, and analysis89## Quick Setup1011```bash12bash "$SKILL_DIR/setup.sh" # Interactive environment check + install13```1415---1617## Routing: Academic / Paper-Based Presentations → Beamer1819> **STOP — check this before doing any work.**20>21> If the request matches **any** trigger below, **skip the PPTX workflow entirely**.22> Read **[`beamer.md`](beamer.md)** in this directory and follow its instructions.2324| Trigger | Typical phrasing |25|---------|-----------------|26| Reading / summarizing a paper to make slides | "read this PDF and make slides", "make slides from this paper" |27| Academic / scientific / research presentation | "conference talk", "research presentation", "academic presentation" |28| Thesis or dissertation defense | "thesis defense", "proposal defense", "defense slides" |29| Any scholarly audience presentation | "academic PPT", "paper presentation", "research talk" |30| STEM / science courseware | "STEM slides", "science lecture", "math/physics/chemistry courseware" |31| User mentions a "paper" or "thesis" in any language | "present this paper", "talk about this thesis", "summarize this article into slides" |32| Uploaded file is clearly an academic paper | "make slides from this", "help me present this" — where the uploaded PDF contains academic indicators (abstract, keywords, references, DOI, author affiliations, journal name) in the first 3 pages |333435> **Beamer output format: PDF-style slides only.**36>37> **Routing decision rule:** The trigger table above applies to **all languages**. For non-English requests, match by semantic meaning — mentally translate the user's intent into English and check against the triggers.38>39> **Important:** In many languages (e.g., Chinese, Japanese, Korean), "PPT" is a generic colloquial word for "slides" or "presentation" — it does NOT indicate a preference for `.pptx` format. Only route to the PPTX workflow when the user **explicitly** requests `.pptx` format (e.g., "I need a .pptx file", "export as pptx") or the content is clearly non-academic (e.g., marketing, business, teaching children).4041---4243## Overview4445A 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.4647## Reading and analyzing content4849### Text extraction5051To read the text content of a presentation, convert it to markdown:5253```bash54python -m markitdown path-to-file.pptx55```5657### Raw XML access5859For comments, speaker notes, slide layouts, animations, design elements, or complex formatting, unpack the presentation and inspect its raw XML.6061#### Unpacking a file6263```64python ooxml/scripts/unpack.py <office_file> <output_dir>65```6667**Note**: `unpack.py` is at `skills/pptx/ooxml/scripts/unpack.py` relative to the project root. If not found, run `find . -name "unpack.py"` to locate it.6869#### Key file structures7071| Path | Contents |72|------|----------|73| `ppt/presentation.xml` | Main metadata and slide references |74| `ppt/slides/slide{N}.xml` | Per-slide content |75| `ppt/notesSlides/notesSlide{N}.xml` | Speaker notes |76| `ppt/comments/modernComment_*.xml` | Slide comments |77| `ppt/slideLayouts/` | Layout templates |78| `ppt/slideMasters/` | Master slide templates |79| `ppt/theme/` | Theme and styling |80| `ppt/media/` | Images and other media |8182#### Typography and color extraction8384**When emulating an existing design**, extract typography and colors before starting:85861. **Theme file** — `ppt/theme/theme1.xml`: colors (`<a:clrScheme>`), fonts (`<a:fontScheme>`)872. **Slide content** — `ppt/slides/slide1.xml`: actual font usage (`<a:rPr>`) and colors883. **Global search** — grep for `<a:solidFill>`, `<a:srgbClr>`, and font references across all XML files8990---919293## Creating a new PowerPoint presentation **using a template**9495When the user upload a pptx file,and do not ask you to create a fully new pptx,you must create a presentation that follows an existing template's design, you'll need to duplicate and re-arrange template slides before then replacing placeholder content.9697### Workflow981. **Extract template text AND create visual thumbnail grid**:99 * Extract text: `python -m markitdown template.pptx > template-content.md`100 * Read `template-content.md`: Read the entire file. **NEVER set any range limits.**101 * Create thumbnail grids: `python scripts/thumbnail.py template.pptx`102 * See [Creating Thumbnail Grids](#creating-thumbnail-grids) section for details1031042. **Analyze template and save inventory to a file**:105 * **Visual Analysis**: Review thumbnail grid(s) to understand layouts and design patterns106 * Create and save `template-inventory.md` containing:107 ```markdown108 # Template Inventory Analysis109 **Total Slides: [count]**110 **IMPORTANT: Slides are 0-indexed (first slide = 0, last slide = count-1)**111112 ## [Category Name]113 - Slide 0: [Layout code if available] - Description/purpose114 - Slide 1: [Layout code] - Description/purpose115 [... EVERY slide must be listed ...]116 ```1171183. **Create presentation outline based on template inventory**:119 * Choose layouts that match your content structure120 * **CRITICAL: Match layout structure to actual content**:121 - Single-column layouts: Use for unified narrative or single topic122 - Two-column layouts: Use ONLY when you have exactly 2 distinct items123 - Three-column layouts: Use ONLY when you have exactly 3 distinct items124 - Image + text layouts: Use ONLY when you have actual images125 - Count your actual content pieces BEFORE selecting layout126 * Save `outline.md` with content AND template mapping1271284. **Duplicate, reorder, and delete slides using `rearrange.py`**:129 ```bash130 python scripts/rearrange.py template.pptx working.pptx 0,34,34,50,52131 ```1321335. **Extract ALL text using the `inventory.py` script**:134 ```bash135 python scripts/inventory.py working.pptx text-inventory.json136 ```137 Read `text-inventory.json` entirely. **NEVER set range limits.**1381396. **Generate replacement text and save to JSON file**:140 - Verify which shapes exist in inventory — only reference shapes that are present141 - Add `"paragraphs"` field to shapes that need content142 - **ALL text shapes from inventory will be cleared** unless you provide "paragraphs"143 - Paragraphs with bullets are automatically left-aligned144 - **Do NOT include bullet symbols** (bullet, -, *) in text — they're added automatically145 - Save to `replacement-text.json`146147 **CRITICAL — JSON generation rules (learned from practice):**148 - **Always use `json.dump()` to write the file** — never write raw JSON strings in Python code.149 Raw strings may embed unescaped `"` characters (e.g. `"三遥"`, `"线上+线下"`) that silently150 break JSON parsing. `json.dump(data, f, ensure_ascii=False, indent=2)` handles all escaping151 automatically.152 - **Respect small box character limits** — check `width` and `font_size` from inventory before153 writing text for numeric/label shapes. A box of `width ≤ 0.7"` at `font_size ≥ 16pt` can hold154 roughly 3–4 characters max. Keep percentage values like `"99.7%"` to ≤ 4 chars, or shorten155 (e.g. `"100%"` instead of `"99.96%"`).156 - **Match replacement length to original** — for body text boxes, count characters in the157 original inventory text. Replacements significantly longer than the original will overflow.158 When in doubt, err shorter rather than longer.159 - **Test incrementally** — validate with a 5-slide subset before writing the full deck.160 `replace.py` blocks on overflow errors; fix them slide-by-slide rather than all at once.1611627. **Apply replacements**:163 ```bash164 python scripts/replace.py working.pptx replacement-text.json output.pptx165 ```166167## Creating a new PowerPoint presentation **without a template**168169When creating a new PowerPoint presentation from scratch, use the **Design System + Component** workflow.170171### Step 0 — Scene Classification (MANDATORY)172173Before ANY design work, classify the presentation into one of the five scenes below:174175| Scene | Keywords / Triggers |176|-------|-------------------|177| **Teaching / Training** | course, teaching, training, lecture, courseware, knowledge points, lesson plan |178| **Work Report / Review** | report, review, summary, retrospective, OKR, KPI, quarterly, annual |179| **Proposal / Pitch** | proposal, plan, pitch, investor, roadshow, business plan |180| **Thesis Defense / Academic** | thesis, defense, research, academic, topic, graduation project — **→ if source is a paper/PDF or audience is academic, read [`beamer.md`](beamer.md) instead** |181| **General** | None of the above, or user did not specify |182183### Step 1 — Select Theme (MANDATORY)184185Read [`themes.md`](themes.md) and select a theme based on scene and content tone.186187**Output**: State your chosen theme name, your chosen **accent variant** (A/B/C), and the full color palette (primary-80, primary-90, primary-5, accent, etc.) before writing any code.188189**Accent variant selection**: Each theme offers 3 accent colors (A = default, B, C). Choose the variant that best matches the content tone. You may also mix — e.g., use accent-A for most slides and accent-B for emphasis pages — but keep the primary palette constant.190191Theme selection tips:192- Work report → Ocean or Graphite193- Proposal / pitch → Ocean, Sandstone, or Twilight194- Teaching / courseware → Forest or Ocean195- Thesis defense → read [`beamer.md`](beamer.md) (PDF output); if `.pptx` is explicitly required, use Graphite or Forest196- Tech keynote / product launch → Deep Mineral or Mono197- Cultural / lifestyle / brand → Warm Retro198- ESG / sustainability → Deep Forest or Forest199- Consumer / lifestyle / female audience → Coral200- Healthcare / wellness / eco → Mint201- SaaS / AI / onboarding → Azure202- Annual events / launches / high-energy → Ember203- General → any theme that fits the content204205**After selecting a theme, note its Image Keywords and Mask Color** — you will need them in Step 5.5.206207### Step 2 — Read Design System (MANDATORY)208209Read [`design-system.md`](design-system.md). Understand the color system (mandatory) and creative principles (guidelines). The color scale is the only hard constraint — everything else (spacing, font sizes, layout) is flexible.210211### Step 3 — Read HTML-to-PPTX Guide (MANDATORY)212213Read [`html2pptx.md`](html2pptx.md) completely from start to finish. **NEVER set any range limits when reading this file.**214215### Step 4 — Plan Slide Sequence216217For each slide, decide:2181. Which **component** from [`components.md`](components.md) to use as a starting point (or design from scratch)2192. What **content** to fill in — **be generous with content; fill the slide**2203. How to **remix** the component — change spacing, font sizes, card styles, backgrounds, proportions to create variety221222**KEY PRINCIPLES**:223- Read [`components.md`](components.md) for available starting points224- Also read [`data-viz-components.md`](data-viz-components.md) for data visualization components225- **Adjacent slides MUST look distinctly different** — vary layout structure, background, card treatment226- **Fill the slide**: Avoid large empty areas. If content is sparse, use larger typography, more generous spacing, bigger visual elements, or add decorative elements to create visual richness227- **Every content slide should have at least one non-text visual element** (color block, stat number, chart, icon, accent bar, photo, shape)228- Alternate between high-density and low-density pages for rhythm229- Use data visualization components when content contains numbers, comparisons, percentages230- **Tables are a great way to enrich content** — use `content-table*` or `content-chart-*` from components.md whenever content involves structured data, feature comparisons, schedules, or multi-attribute lists231232**Anti-whitespace strategies** (use when a slide feels empty):233- Increase font sizes (e.g., body from 15pt to 17pt, headings from 22pt to 26pt)234- Add colored background blocks or sections235- Use a darker or tinted background instead of pure white236- Add decorative elements (accent bars, shapes, gradient bands)237- Expand card padding and spacing238- Use a photo background with mask overlay239- Switch from a text-heavy layout to a visual-heavy one240241**Note: Not all whitespace is bad.** KPI pages, quote pages, and big-number focus pages are *designed* to have generous whitespace — that's intentional emphasis. Only fix whitespace on content-heavy pages (bullet lists, card grids, text blocks) where it looks accidental. See design-system.md §2.2 for the full distinction.242243**Slide sequence pattern** (recommended):244```2451. Cover → PREFER cover-photo-mask (with downloaded photo + theme mask)246 → Fallback: cover-dark-hero (no photo needed) or cover-split2472. TOC → toc-card-grid (surface bg) / toc-big-number (visual variety)2483. Section divider (optional) → divider-photo-mask (different photo from cover)249 → or divider-gradient / divider-bold-center2504. Content page A → light background, visually rich component2515. Content page B → ★ DARK BACKGROUND ★ (content-dark-bullets / dark-kpi / dark-split)2526. Section divider (optional) → different variant from #32537. Content page C → image-based (split-text-visual, photo-cards, etc.)2548. Content page D → data-focused (kpi-row, big-number-focus, etc.)2559. Closing → dark background echoing cover color256257Background rhythm target: ~40% white, ~25% surface/tinted, ~20% dark, ~15% photo258```259260### Step 5 — Generate HTML from Components261262For each slide:2631. Start from a component template in `components.md`, or design from scratch2642. Replace all `${variable}` placeholders with actual theme color values2653. Replace placeholder text with actual content2664. Adjust element count (add/remove cards, list items) as needed2675. **Before writing each slide's HTML**: Check the **Card Style Cookbook** at the top of components.md. Pick a different card style from the previous slide. Also check if this slide should use a **Dark Background Content Template**.2686. **Be creative**: Freely modify spacing, font sizes, card styles, proportions, background treatments, and decorative elements across pages. The only hard constraints are the html2pptx engine limitations (no flex-wrap, no negative margins, no DIV background-image, no CSS gradients). Use the design-system.md Quick Reference for suggested ranges, but treat them as starting points, not limits.269 - **Card styles**: Use the **Card Style Cookbook** in components.md to swap between shadow/outline/solid/accent-bar/dark card styles. No 2 adjacent slides should use the same card style.270 - **Title bars**: All content slides must use the **same header style** — pick one title bar variant from components.md and apply it consistently across every content page.271 - **Dark pages**: Use the **Dark Background Content Templates** in components.md for rhythm-breaking dark slides. Aim for at least 1 dark content page per 4 slides.2726. **Fill the slide**: If there's visible empty space, increase font sizes, add visual elements, expand padding, or use a colored/photo background. A well-filled slide looks professional; excessive whitespace looks unfinished.273274275### Step 5.8 — Visual Diversity Check (RECOMMENDED)276277Before converting to PPTX, do a quick scan of your slide sequence:278- Are adjacent slides visually distinct (different layout, background, card style)?279- Is there enough variety across the deck (multiple layout structures, card treatments, background approaches)?280- Is there at least one dramatic "rhythm breaker" page?281- Do real photographs appear on covers and at least one other slide?282283If the answer to any is "no", revise before proceeding.284285### Step 6 — Convert and Validate2862871. Create and run a JavaScript file using [`html2pptx.js`](scripts/html2pptx.js) to convert HTML slides to PowerPoint:288 ```javascript289 const pptxgen = require('pptxgenjs');290 const html2pptx = require('./html2pptx');291 292 const pptx = new pptxgen();293 pptx.layout = 'LAYOUT_16x9';294 295 // Optional: custom font configuration296 const fontConfig = { cjk: 'Microsoft YaHei', latin: 'Corbel' };297 298 // Process ALL slides with warnings collection299 const allWarnings = [];300 for (const htmlFile of slideFiles) {301 const { slide, placeholders, warnings } = await html2pptx(htmlFile, pptx, { fontConfig });302 allWarnings.push(...warnings);303 }304 305 // Add charts to placeholder areas if any306 if (placeholders.length > 0) {307 slide.addChart(pptx.charts.LINE, chartData, placeholders[0]);308 }309 310 await pptx.writeFile('output.pptx');311 ```3123132. **Check warnings**: Review `warnings` output. **Blocking issues** (overflow, font < 11pt) must be fixed. **Non-blocking warnings** (bounds, balance, density) are suggestions — use judgment on whether to fix them.3143153. **Visual validation**: Generate thumbnails and inspect for layout issues:316 ```bash317 python scripts/thumbnail.py output.pptx workspace/thumbnails --cols 4318 ```319 - Read and carefully examine the thumbnail image for:320 - **Text cutoff**: Text being cut off by header bars, shapes, or slide edges321 - **Text overlap**: Text overlapping with other text or shapes322 - **Positioning issues**: Content too close to slide boundaries or other elements323 - **Contrast issues**: Insufficient contrast between text and backgrounds324 - **Consistency check**: All body text same font and size? All page margins consistent? All content slides use the same header style?325 - If issues found, adjust HTML and regenerate326 - Repeat until all slides are visually correct327328### Step 6.5 — Final Quality Check (RECOMMENDED)329330Before finalizing, do a quick visual quality scan:331332- ✅ Real photographs used (cover + at least 1 other slide)333- ✅ Background variety (at least 3 different treatments)334- ✅ No 2 consecutive slides look the same335- ✅ Multiple layout structures used (aim for 5+)336- ✅ Card styles vary across pages337- ✅ Every slide has a clear visual focal point338- ✅ At least 1 dramatic full-bleed or dark page exists339- ✅ All referenced image files exist and are > 10KB340341If major issues are found, fix and regenerate. Minor imperfections are acceptable — don't over-optimize at the cost of creativity.342343### Design Hard Rules (ALWAYS ENFORCED)344345These rules are split into **engine constraints** (violating them causes broken output) and **design principles** (ensuring quality).346347**Engine Constraints (technical — cannot be violated):**348```349[ENGINE] Slide canvas is 720×405pt — content exceeding this overflows350[ENGINE] All colors must come from the theme color scale — no arbitrary grays (#666 #999 #DDD)351[ENGINE] font-family must include a CJK font name to trigger correct mapping352[ENGINE] Do not use flex-wrap — multi-row layouts must use separate flex containers353[ENGINE] Do not use negative margins — they cause text stacking in PPT354[ENGINE] Multi-column equal-width cards must use fixed width + flex-shrink:0, not flex:1355[ENGINE] Background images only work on <body>, not <div> — DIV background-image is not supported356[ENGINE] Images must be local file paths, not URLs357[ENGINE] Titles and short labels (<10 characters) should use white-space:nowrap358[ENGINE] Numeric sequences (e.g. 01/02/03, $12M) should use white-space:nowrap359```360361**Design Principles (creative quality — strongly encouraged):**362```363[DESIGN] Adjacent slides should use different layouts, backgrounds, and card styles364[DESIGN] Every content slide should have at least one visual focal point365[DESIGN] Cover and closing page should echo each other366[DESIGN] Prefer cutting content over shrinking fonts — only when a slide is already well-filled and overflow is imminent; never cut content preemptively367[DESIGN] Aim for 5+ layout structures, 3+ card styles, 3+ background treatments across the deck368[DESIGN] Insert a rhythm-breaking page every 3-4 slides369[DESIGN] Background images should have a mask overlay for text readability370[DESIGN] Content should be vertically balanced, not crammed at the top371[DESIGN] Accent colors must have HSL saturation ≤ 65% — high-saturation colors look garish on projection372[DESIGN] Large color blocks (>15% page area) should use S ≤ 50% — only small accents can be vivid373[DESIGN] All content slides must use the same header style — pick one title bar variant and apply it consistently across all content pages374```375376---377378## Editing an existing PowerPoint presentation379380When editing slides in an existing PowerPoint presentation, work with raw Office Open XML (OOXML) format.381382### Workflow3831. **MANDATORY - READ ENTIRE FILE**: Read [`ooxml.md`](ooxml.md) (~500 lines) completely from start to finish. **NEVER set any range limits when reading this file.**3842. Unpack the presentation: `python ooxml/scripts/unpack.py <office_file> <output_dir>`3853. Edit the XML files (primarily `ppt/slides/slide{N}.xml` and related files)3864. **CRITICAL**: Validate immediately after each edit: `python ooxml/scripts/validate.py <dir> --original <file>`3875. Pack the final presentation: `python ooxml/scripts/pack.py <input_directory> <office_file>`388389390391## Creating Thumbnail Grids392393```bash394python scripts/thumbnail.py template.pptx [output_prefix]395```396397**Features**:398- Creates: `thumbnails.jpg` (or `thumbnails-1.jpg`, `thumbnails-2.jpg` for large decks)399- Default: 5 columns, max 30 slides per grid (5x6)400- Custom prefix: `python scripts/thumbnail.py template.pptx my-grid`401- Adjust columns: `--cols 4` (range: 3-6)402- Slides are zero-indexed (Slide 0, Slide 1, etc.)403404## Converting Slides to Images4054061. **Convert PPTX to PDF**:407 ```bash408 soffice --headless --convert-to pdf template.pptx409 ```4104112. **Convert PDF pages to JPEG images**:412 ```bash413 pdftoppm -jpeg -r 150 template.pdf slide414 ```415416## Code Style Guidelines417**IMPORTANT**: When generating code for PPTX operations:418- Write concise code419- Avoid verbose variable names and redundant operations420- Avoid unnecessary print statements421422## Dependencies423424Required dependencies (should already be installed):425426- **markitdown**: `pip install "markitdown[pptx]"` (text extraction)427- **pptxgenjs**: `npm install -g pptxgenjs` (creating presentations)428- **playwright**: `npm install -g playwright` (HTML rendering)429- **react-icons**: `npm install -g react-icons react react-dom` (icons)430- **sharp**: `npm install -g sharp` (SVG rasterization and image processing)431- **LibreOffice**: `sudo apt-get install libreoffice` (PDF conversion)432- **Poppler**: `sudo apt-get install poppler-utils` (pdftoppm)433- **defusedxml**: `pip install defusedxml` (secure XML parsing)