AI turns documents or topics into real, native PowerPoint decks—with native shapes, transitions and animations, data-backed charts and tables on demand, audio narration from speaker notes, and support for your own .pptx templates. · by Hugo He
fix(beautify): keep chart titles in the frozen inventory and its verifier
hugohe3694bdacac7e6
diff --git a/skills/ppt-master/scripts/beautify_inventory.py b/skills/ppt-master/scripts/beautify_inventory.pyindex bf439669..0f26e551 100644--- a/skills/ppt-master/scripts/beautify_inventory.py+++ b/skills/ppt-master/scripts/beautify_inventory.py@@ -113,6 +113,7 @@ def build_inventory(slide_library: dict, images_by_slide: dict[int, list[dict]]){"chart_id": c.get("chart_id"),"chart_type": c.get("chart_type"),+ "title": c.get("title", ""),"category_count": c.get("category_count"),"series_count": c.get("series_count"),"categories": c.get("categories", []), # frozen data@@ -240,6 +241,8 @@ def _frozen_strings(slide: dict) -> list[str]:for row in table.get("cells", []):strings.extend(cell for cell in row if cell and cell.strip())for chart in slide.get("charts", []):+ if chart.get("title"):+ strings.append(chart["title"])strings.extend(str(c) for c in chart.get("categories", []) if str(c).strip())strings.extend(str(series.get("name")) for series in chart.get("series", []) if series.get("name"))for diagram in slide.get("diagrams", []):@@ -259,6 +262,7 @@ def _exported_text_by_slide(pptx_path: Path) -> dict[int, str]:for row in table.get("rows", []):parts.extend(cell.get("text", "") for cell in row.get("cells", []))for chart in slide.get("charts", []):+ parts.append(chart.get("title", ""))parts.extend(str(c) for c in chart.get("categories", []))parts.extend(str(series.get("name", "")) for series in chart.get("series", []))for diagram in slide.get("diagrams", []):diff --git a/skills/ppt-master/scripts/docs/conversion.md b/skills/ppt-master/scripts/docs/conversion.mdindex bede0342..89c877c2 100644--- a/skills/ppt-master/scripts/docs/conversion.md+++ b/skills/ppt-master/scripts/docs/conversion.md@@ -266,7 +266,7 @@ python3 scripts/pptx_intake.py deck.pptx -o projects/demo/analysisOutputs (per source deck, prefixed by file stem):- `<stem>.identity.json` — canvas size/aspect, theme palette/fonts, observed colors/fonts-- `<stem>.slide_library.json` — text slots, geometry, native tables, native chart display caches, and SmartArt nodes/connections+- `<stem>.slide_library.json` — text slots, geometry, native tables, native chart titles/display caches, and SmartArt nodes/connections. Chart titles include rich text and linked-string caches; Beautify carries them into its frozen inventory and verifies their presence in the exported deck.- `source_profile.json` — the single multi-deck index: a compact Strategist-facing digest per deck (over identity, tables, charts, SmartArt, and page types) under `decks[]`, with prefixed artifact pointers`project_manager.py import-sources` runs this automatically for PPTX/PPTM/PPSX/PPSM/POTX/POTM inputs and stores the bundle directly under `analysis/`. Multi-deck per project: each deck uses its archived stem, including any collision suffix, for `<stem>.*` artifacts and its `decks[]` entry in the shared `source_profile.json` index. Re-running intake for an existing archived stem replaces its entry. The beautify profile stays single-deck and reads one chosen deck's `<stem>.*` artifacts.diff --git a/skills/ppt-master/scripts/pptx_ooxml/chart_read.py b/skills/ppt-master/scripts/pptx_ooxml/chart_read.pyindex 59047be7..c4653558 100644--- a/skills/ppt-master/scripts/pptx_ooxml/chart_read.py+++ b/skills/ppt-master/scripts/pptx_ooxml/chart_read.py@@ -9,7 +9,7 @@ from __future__ import annotationsfrom typing import Anyfrom xml.etree import ElementTree as ET-from .ooxml import NS+from .ooxml import NS, _paragraph_textsdef empty_chart_data() -> dict[str, Any]:@@ -19,6 +19,7 @@ def empty_chart_data() -> dict[str, Any]:"series_count": 0,"categories": [],"series": [],+ "title": "",}@@ -74,10 +75,18 @@ def _series_name(series: ET.Element, fallback: str) -> str:def read_chart_data(chart_root: ET.Element) -> dict[str, Any]:- """Return a compact summary of chart type, categories, series, and values."""+ """Return the chart title, type, categories, series, and values."""+ title_node = chart_root.find("c:chart/c:title/c:tx", NS)+ title = ""+ if title_node is not None:+ rich = title_node.find("c:rich", NS)+ title = (+ "\n".join(_paragraph_texts(rich))+ if rich is not None else "\n".join(map(str, _cache_values(title_node)))+ )chart_types = _chart_types_with_series(chart_root)if not chart_types:- return empty_chart_data()+ return {**empty_chart_data(), "title": title}first_series = chart_types[0].find("c:ser", NS)categories = _cache_values(first_series.find("c:cat", NS)) if first_series is not None else []@@ -106,4 +115,5 @@ def read_chart_data(chart_root: ET.Element) -> dict[str, Any]:"series_count": len(series_payload),"categories": categories,"series": series_payload,+ "title": title,}diff --git a/skills/ppt-master/scripts/tests/test_beautify_chart_title_survival.py b/skills/ppt-master/scripts/tests/test_beautify_chart_title_survival.pynew file mode 100644index 00000000..fd8f301b--- /dev/null+++ b/skills/ppt-master/scripts/tests/test_beautify_chart_title_survival.py@@ -0,0 +1,124 @@+#!/usr/bin/env python3+"""Keep visible chart titles across PPTX intake and Beautify verification.++Usage:+ python3 -m unittest tests.test_beautify_chart_title_survival++Dependencies:+ python-pptx and the script runtime dependencies.+"""++from __future__ import annotations++import contextlib+import io+import json+from pathlib import Path+import sys+import tempfile+import unittest+import zipfile+from xml.etree import ElementTree as ET++from pptx import Presentation+from pptx.chart.data import ChartData+from pptx.enum.chart import XL_CHART_TYPE+from pptx.util import Inches++SCRIPTS = Path(__file__).resolve().parents[1]+if str(SCRIPTS) not in sys.path:+ sys.path.insert(0, str(SCRIPTS))++import beautify_inventory # noqa: E402+import pptx_intake # noqa: E402++NS = {+ "a": "http://schemas.openxmlformats.org/drawingml/2006/main",+ "c": "http://schemas.openxmlformats.org/drawingml/2006/chart",+}+++class BeautifyChartTitleSurvivalTests(unittest.TestCase):+ def setUp(self) -> None:+ temporary = tempfile.TemporaryDirectory()+ self.addCleanup(temporary.cleanup)+ self.root = Path(temporary.name)+ self.source = self.root / "source.pptx"+ presentation = Presentation()+ slide = presentation.slides.add_slide(presentation.slide_layouts[6])+ data = ChartData()+ data.categories = ["CATEGORY_MARKER"]+ data.add_series("SERIES_MARKER", [271])+ chart = slide.shapes.add_chart(+ XL_CHART_TYPE.COLUMN_CLUSTERED,+ Inches(1), Inches(1), Inches(8), Inches(5), data,+ ).chart+ chart.has_title = True+ chart.chart_title.text_frame.text = "TITLE_MARKER\n第二行 & <exact>"+ presentation.save(self.source)++ def _intake(self) -> tuple[Path, dict]:+ analysis = self.root / "analysis"+ inventory = analysis / "inventory.json"+ with contextlib.redirect_stdout(io.StringIO()), contextlib.redirect_stderr(io.StringIO()):+ self.assertEqual(pptx_intake.main([str(self.source), "-o", str(analysis)]), 0)+ self.assertEqual(beautify_inventory.main([+ str(analysis / "source.slide_library.json"), "-o", str(inventory),+ ]), 0)+ return inventory, json.loads(inventory.read_text(encoding="utf-8"))++ def _mutate_chart(self, mutation) -> None:+ with zipfile.ZipFile(self.source) as archive:+ entries = {name: archive.read(name) for name in archive.namelist()}+ chart = ET.fromstring(entries["ppt/charts/chart1.xml"])+ mutation(chart)+ entries["ppt/charts/chart1.xml"] = ET.tostring(chart, encoding="utf-8")+ with zipfile.ZipFile(self.source, "w") as archive:+ for name, payload in entries.items():+ archive.writestr(name, payload)++ def test_rich_title_survives_intake_and_missing_title_fails_verification(self) -> None:+ inventory, payload = self._intake()+ title = "TITLE_MARKER\n第二行 & <exact>"+ self.assertEqual(payload["slides"][0]["charts"][0]["title"], title)+ with contextlib.redirect_stdout(io.StringIO()):+ self.assertEqual(beautify_inventory.main([+ str(inventory), "--verify", str(self.source),+ ]), 0)+ presentation = Presentation(self.source)+ presentation.slides[0].shapes[0].chart.has_title = False+ missing_title = self.root / "missing-title.pptx"+ presentation.save(missing_title)+ output = io.StringIO()+ with contextlib.redirect_stdout(output):+ self.assertEqual(beautify_inventory.main([+ str(inventory), "--verify", str(missing_title),+ ]), 1)+ self.assertIn("TITLE_MARKER", output.getvalue())++ def test_linked_title_cache_survives_intake(self) -> None:+ def linked_title(root):+ tx = root.find("c:chart/c:title/c:tx", NS)+ tx.clear()+ ref = ET.SubElement(tx, f"{{{NS['c']}}}strRef")+ ET.SubElement(ref, f"{{{NS['c']}}}f").text = "Sheet1!$A$1"+ cache = ET.SubElement(ref, f"{{{NS['c']}}}strCache")+ ET.SubElement(cache, f"{{{NS['c']}}}ptCount", {"val": "1"})+ point = ET.SubElement(cache, f"{{{NS['c']}}}pt", {"idx": "0"})+ ET.SubElement(point, f"{{{NS['c']}}}v").text = "LINKED_TITLE_MARKER"++ self._mutate_chart(linked_title)+ _path, payload = self._intake()+ self.assertEqual(payload["slides"][0]["charts"][0]["title"], "LINKED_TITLE_MARKER")++ def test_title_survives_chart_without_series(self) -> None:+ def remove_series(root):+ for plot in root.findall("c:chart/c:plotArea/*", NS):+ for series in plot.findall("c:ser", NS):+ plot.remove(series)++ self._mutate_chart(remove_series)+ _path, payload = self._intake()+ chart = payload["slides"][0]["charts"][0]+ self.assertIn("TITLE_MARKER", chart["title"])+ self.assertEqual(chart["series"], [])