anbeime/skill / skills/pptx-generator/pptx-generator
pptx-generator
Verified产品经理与运营专员在准备汇报展示时,将 JSON 数据一键转换为标准 .pptx 文件。自动应用多种布局、图表与表格样式,快速生成专业 PPT,彻底告别繁琐手工排版,让内容产出与展示更高效!
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 8.3 KB |
| assets/styles/business.json | config | 167 B |
| assets/styles/minimal.json | config | 169 B |
| assets/styles/modern.json | config | 165 B |
| assets/templates/ppt_data_template.json | config | 749 B |
| references/collaboration_guide.md | markdown | 10.2 KB |
| references/json_format_spec.md | markdown | 4.5 KB |
| references/layout_guide.md | markdown | 6.6 KB |
| scripts/json_validator.py | script | 5.9 KB |
| scripts/pptx_builder.py | script | 9.6 KB |
| scripts/pptx_validator.py | script | 4.4 KB |
scripts/pptx_validator.py
View on GitHub#!/usr/bin/env python3
"""
PPTX Validator - Validate generated .pptx files.
This module validates .pptx files to ensure they are
correctly generated and can be opened in PowerPoint.
"""
import argparse
import sys
from pathlib import Path
from typing import Optional
try:
from pptx import Presentation
except ImportError:
print("错误: 未安装 python-pptx")
print("请运行: pip install python-pptx")
sys.exit(1)
# =============================================================================
# PPTX Validator
# =============================================================================
class PPTXValidator:
"""Validator for .pptx files."""
def __init__(self):
"""Initialize PPTX validator."""
self.errors = []
self.warnings = []
def validate(self, pptx_path: str) -> bool:
"""
Validate .pptx file.
Args:
pptx_path: Path to .pptx file.
Returns:
True if valid, False otherwise.
"""
print(f"验证 PPTX 文件: {pptx_path}\n")
# Check file exists
if not Path(pptx_path).exists():
self.errors.append(f"文件不存在: {pptx_path}")
self._print_results()
return False
# Check file extension
if not pptx_path.lower().endswith('.pptx'):
self.warnings.append("文件扩展名不是 .pptx")
try:
# Open presentation
presentation = Presentation(pptx_path)
except Exception as e:
self.errors.append(f"无法打开 PPTX 文件: {e}")
self._print_results()
return False
# Validate slides
self._validate_slides(presentation)
# Print results
self._print_results()
return len(self.errors) == 0
def _validate_slides(self, presentation) -> None:
"""
Validate slides in presentation.
Args:
presentation: Presentation object.
"""
slide_count = len(presentation.slides)
if slide_count == 0:
self.errors.append("演示文稿中没有幻灯片")
else:
print(f"✓ 幻灯片数量: {slide_count}\n")
# Validate each slide
for i, slide in enumerate(presentation.slides, 1):
self._validate_slide(slide, i)
def _validate_slide(self, slide, index: int) -> None:
"""
Validate a slide.
Args:
slide: Slide object.
index: Slide index.
"""
shape_count = len(slide.shapes)
if shape_count == 0:
self.warnings.append(f"幻灯片 {index} 没有内容")
else:
# Check for title
has_title = False
for shape in slide.shapes:
if hasattr(shape, 'text_frame'):
if shape.has_text_frame:
text = shape.text_frame.text.strip()
if text and shape == slide.shapes.title:
has_title = True
break
if not has_title:
self.warnings.append(f"幻灯片 {index} 没有标题")
def _print_results(self) -> None:
"""Print validation results."""
if self.errors:
print(f"❌ 发现 {len(self.errors)} 个错误:\n")
for i, error in enumerate(self.errors, 1):
print(f" {i}. {error}")
print()
if self.warnings:
print(f"⚠️ 发现 {len(self.warnings)} 个警告:\n")
for i, warning in enumerate(self.warnings, 1):
print(f" {i}. {warning}")
print()
if not self.errors and not self.warnings:
print("✓ PPTX 文件验证通过!\n")
# =============================================================================
# Main Function
# =============================================================================
def main():
"""Main entry point."""
parser = argparse.ArgumentParser(
description='Validate generated .pptx files'
)
parser.add_argument(
'--input', '-i',
required=True,
help='Input .pptx file path'
)
args = parser.parse_args()
# Create validator
validator = PPTXValidator()
# Validate
is_valid = validator.validate(args.input)
# Exit with appropriate code
sys.exit(0 if is_valid else 1)
if __name__ == '__main__':
main()
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| canvas-designanthropics/skillsCreate beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| docxanthropics/skillsUse this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| pdfanthropics/skillsUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |
| pptxanthropics/skillsUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill. | Stars: 196k | Updated | Claude CodeCodex | Verified | Install |