siril9/presentation-skill / plugins/presentation-skill/skills/presentation-skill
presentation-skill
FlaggedBuild, edit, redesign, render, and verify content-led, structurally diverse, clean, editable, reproducible PowerPoint `.pptx` decks. Use for scientific, lab, clinical, consulting, board, investor, editorial, policy, and operational presentations where alignment, readability, contrast, and balanced density matter.
scripts/pack_pptx.py
View on GitHub"""Repack an unpacked .pptx directory back into a valid .pptx file.
Preserves the zip layout PowerPoint expects:
- `[Content_Types].xml` written first at the archive root.
- All other parts stored with forward-slash paths, using DEFLATE compression.
Optional `--fix-xml-space` auto-repairs the xml:space="preserve" attribute
on DrawingML text runs whose content has leading/trailing whitespace —
prevents external XML editors from silently stripping significant
whitespace (a list item like " Second tier" would otherwise collapse to
"Second tier" on save).
"""
from __future__ import annotations
import argparse
import re
import sys
import zipfile
from pathlib import Path
CONTENT_TYPES_NAME = "[Content_Types].xml"
# Matches an <a:t> element with text content. Captures:
# g1 = open tag without the closing '>' (e.g., '<a:t' or '<a:t xml:space="preserve"')
# g2 = rest of the open tag after the element name (attributes portion)
# g3 = text content
_AT_ELEMENT_RE = re.compile(r"(<a:t)((?:\s[^>]*)?)>([^<]*)</a:t>")
_XML_SPACE_ATTR_RE = re.compile(r'\bxml:space\s*=\s*"[^"]*"')
def _args() -> argparse.Namespace:
parser = argparse.ArgumentParser(
description="Repack a directory tree into a .pptx file PowerPoint can open.",
)
parser.add_argument(
"--indir",
required=True,
help="Source directory previously produced by unpack_pptx.py",
)
parser.add_argument("--output", required=True, help="Output .pptx path")
parser.add_argument(
"--overwrite",
action="store_true",
help="Allow overwriting an existing output file",
)
parser.add_argument(
"--fix-xml-space",
action="store_true",
help=(
"Before packing, scan every slide/layout/master XML for "
"<a:t> elements whose text has leading/trailing whitespace "
"and add xml:space=\"preserve\" if missing. Prevents silent "
"whitespace-stripping by external XML editors."
),
)
return parser.parse_args()
def _iter_files(indir: Path) -> list[Path]:
return sorted(p for p in indir.rglob("*") if p.is_file())
def _ensure_xml_space_preserve(text: str) -> tuple[str, int]:
"""Ensure <a:t> elements whose text has leading/trailing whitespace
carry `xml:space="preserve"`. Returns (new_text, repair_count).
Only touches `<a:t>` tags; never modifies element *content*. Elements
already carrying `xml:space="preserve"` or that don't need it are
left alone.
"""
repairs = 0
def _repair(match: re.Match[str]) -> str:
nonlocal repairs
open_prefix = match.group(1) # '<a:t'
attrs = match.group(2) or "" # existing attribute string
content = match.group(3) # text between <a:t> and </a:t>
if not content:
return match.group(0)
needs_preserve = content != content.strip()
if not needs_preserve:
return match.group(0)
if _XML_SPACE_ATTR_RE.search(attrs):
return match.group(0)
new_attrs = attrs + ' xml:space="preserve"'
repairs += 1
return f"{open_prefix}{new_attrs}>{content}</a:t>"
new_text = _AT_ELEMENT_RE.sub(_repair, text)
return new_text, repairs
def _apply_xml_space_fix(indir: Path) -> int:
total = 0
for xml_path in indir.rglob("*.xml"):
if xml_path.name == "[Content_Types].xml":
continue
try:
text = xml_path.read_text(encoding="utf-8")
except UnicodeDecodeError:
continue
new_text, repaired = _ensure_xml_space_preserve(text)
if repaired:
xml_path.write_text(new_text, encoding="utf-8")
total += repaired
return total
def main() -> int:
args = _args()
indir = Path(args.indir).expanduser().resolve()
output = Path(args.output).expanduser().resolve()
if not indir.exists():
print(f"Error: indir not found: {indir}", file=sys.stderr)
return 2
if not indir.is_dir():
print(f"Error: indir is not a directory: {indir}", file=sys.stderr)
return 2
content_types_path = indir / CONTENT_TYPES_NAME
if not content_types_path.exists():
print(
f"Error: missing {CONTENT_TYPES_NAME} in indir; this does not look "
f"like an unpacked pptx: {indir}",
file=sys.stderr,
)
return 2
if output.exists() and not args.overwrite:
print(
f"Error: output exists (use --overwrite to replace): {output}",
file=sys.stderr,
)
return 2
output.parent.mkdir(parents=True, exist_ok=True)
if args.fix_xml_space:
repaired = _apply_xml_space_fix(indir)
if repaired:
print(
f"Added xml:space=\"preserve\" to {repaired} <a:t> element(s)",
file=sys.stderr,
)
all_files = _iter_files(indir)
# Ensure [Content_Types].xml is the first entry in the archive.
ordered: list[Path] = [content_types_path]
for path in all_files:
if path == content_types_path:
continue
ordered.append(path)
try:
with zipfile.ZipFile(
output, "w", compression=zipfile.ZIP_DEFLATED, compresslevel=6
) as zf:
for path in ordered:
rel = path.relative_to(indir).as_posix()
zf.write(path, arcname=rel)
except OSError as exc:
print(f"Error: failed to write {output}: {exc}", file=sys.stderr)
return 3
print(f"Packed {indir} -> {output} ({len(ordered)} parts)")
return 0
if __name__ == "__main__":
try:
raise SystemExit(main())
except Exception as exc: # pragma: no cover - CLI error path
print(f"Error: {exc}", file=sys.stderr)
raise SystemExit(1)
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: 197k | 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: 197k | 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: 197k | 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: 197k | Updated | Claude CodeCodex | Verified | Install |