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(pptx): exclude and report author-hidden content across intake paths
hugohe32cdae00379aa
diff --git a/skills/ppt-master/scripts/docs/conversion.md b/skills/ppt-master/scripts/docs/conversion.mdindex 010b9044..bede0342 100644--- a/skills/ppt-master/scripts/docs/conversion.md+++ b/skills/ppt-master/scripts/docs/conversion.md@@ -247,6 +247,7 @@ Behavior:Dependency:+- excludes author-hidden shapes and groups (`cNvPr/@hidden`) with warnings; their text, pictures, tables, charts, and SmartArt descendants do not enter Markdown or the Beautify intake inventory```bashpip install python-pptx```diff --git a/skills/ppt-master/scripts/docs/svg-pipeline.md b/skills/ppt-master/scripts/docs/svg-pipeline.mdindex c8775f0e..0d3adcb4 100644--- a/skills/ppt-master/scripts/docs/svg-pipeline.md+++ b/skills/ppt-master/scripts/docs/svg-pipeline.md@@ -224,6 +224,11 @@ notes and an absent file keeps them. Deleting inherited source notes only on acopy is not supported in v1. The same output-stem rule applies to narrationaudio.+Imported notes Markdown excludes text in author-hidden notes shapes or groups+and records a `hidden-notes-content` diagnostic. Unchanged round-trip notes+still retain their original native XML, including its hidden state; editing a+visible note does not promote the excluded text into the replacement notes.+When a round-trip recorded-narration export omits `--animation-config`, it reads the workspace `animations.json` the importer wrote; that sidecar is part of the workspace contract, so deleting it fails export rather than restoring source motion.Narration audio is keyed by the output SVG stem. A copied output page uses itsdiff --git a/skills/ppt-master/scripts/docs/template-tools.md b/skills/ppt-master/scripts/docs/template-tools.mdindex a04495b1..31885b39 100644--- a/skills/ppt-master/scripts/docs/template-tools.md+++ b/skills/ppt-master/scripts/docs/template-tools.md@@ -22,6 +22,17 @@ Produces one import workspace (default `<pptx_stem>_template_import/` beside the| `svg-flat/slide_NN.svg` | Optional (`--inheritance-mode both`) self-contained verification view of each complete page || `authoring-svg/` (+ `authoring-svg-flat/` with `both`) | Canonical compact editable SVG projected from parsed evidence, with model-readable `authoring_summary.json` and tool-only `authoring_manifest.json` |+Shapes or groups marked hidden by the source author stay out of imported SVG+views and emit `author-hidden-omitted` diagnostics, including their source part+and shape identity. This does not remove objects from an Edit Native source+package or alter unchanged-page passthrough.++Source slides hidden from the slide show (`p:sld/@show="0"`) are retained, but+template preview export does not preserve their slide-hidden state. Template+import warns on stderr with the affected slide index and source part. Use Edit+Native roundtrip when source slide-show visibility must survive; the warning+does not claim that template previews preserve it.+- `layered` (default) emits only the canonical layered view; `both` adds the flat verification tree; `flat` emits a projection-only self-contained `svg/` tree without master/layout/inheritance files. Imported-deck round-trip uses the separate `authoring-svg-flat/` contract of `pptx_to_svg.py --roundtrip`.- Placeholder metadata lives in the manifest; master/layout SVGs show lightweight dashed guides with labels only in `svg/`. Charts, SmartArt, diagrams, and OLE objects are typed placeholders in `svg/` and preview images with a badge in `svg-flat/`; tables are converted to real SVG. Missing media and external linked images fail the import; EMF/WMF convert to PNG previews when the local toolchain supports it, otherwise the import fails.- The import transaction publishes `authoring-svg/` already normalized and decoration-factored: large non-semantic decorative vector groups become one canonical asset under `<import_workspace>/icons/imported/` referenced as `<use data-icon="imported/..." data-pptx-asset-role="decoration"/>`; do not run a second readability or compaction pass. `--inheritance-mode both` reuses the layered inventory (`--reuse-inventory`) so only genuinely flat-only vectors create another asset under the `flat` prefix; `--clean-stale` removes obsolete `flat_*` duplicates. Every asset root, placeholder, and v2 inventory record declares the `decoration` role; any subtree with a semantic marker, text, table, chart, or relationship stays inline, and extraction and both consumers fail closed if that boundary is crossed. Eligible records may retain `data-pptx-source-ref` so re-inlining re-establishes their object mapping; referenced defs (`gradient` / `pattern` / `filter` / `clipPath` / `marker`) are copied into each asset and namespaced.diff --git a/skills/ppt-master/scripts/pptx_ooxml/analyzer.py b/skills/ppt-master/scripts/pptx_ooxml/analyzer.pyindex 6c0d98a7..198826cd 100644--- a/skills/ppt-master/scripts/pptx_ooxml/analyzer.py+++ b/skills/ppt-master/scripts/pptx_ooxml/analyzer.py@@ -3,6 +3,7 @@from __future__ import annotationsimport re+import sysimport zipfilefrom pathlib import Pathfrom typing import Any@@ -28,6 +29,7 @@ from .ooxml import (_paragraph_texts,_parse_slide_refs,_read_xml,+ _remove_author_hidden_shapes,_shape_identity,_slide_relationships,_table_containers,@@ -253,6 +255,18 @@ def analyze_pptx(pptx_path: Path) -> dict[str, Any]:slides: list[dict[str, Any]] = []for slide_ref in slide_refs:slide_root = _read_xml(zf, slide_ref.part_name)+ hidden_shapes = _remove_author_hidden_shapes(slide_root)+ hidden_ids = {+ node.get("id") for shape in hidden_shapes+ for node in shape.iter(f"{{{NS['p']}}}cNvPr")+ }+ for shape in hidden_shapes:+ shape_id, shape_name = _shape_identity(shape, 0)+ print(+ f"Warning: slide {slide_ref.index}: excluded author-hidden shape "+ f"{shape_name!r} (id={shape_id}) and its children from PPTX intake",+ file=sys.stderr,+ )slots: list[dict[str, Any]] = []for order, container in enumerate(_text_containers(slide_root), start=1):shape_id, shape_name = _shape_identity(container, order)@@ -281,7 +295,10 @@ def analyze_pptx(pptx_path: Path) -> dict[str, Any]:tables = _analyze_tables(slide_root, slide_ref.index)charts = _analyze_charts(zf, slide_root, slide_ref)- diagrams = read_smartart_diagrams(zf, slide_ref.part_name, slide_ref.index)+ diagrams = [+ item for item in read_smartart_diagrams(zf, slide_ref.part_name, slide_ref.index)+ if str(item.get("shape_id")) not in hidden_ids+ ]slide_text = "\n".join([slot["text"] for slot in slots if slot["text"]]+ [diff --git a/skills/ppt-master/scripts/pptx_ooxml/ooxml.py b/skills/ppt-master/scripts/pptx_ooxml/ooxml.pyindex d8f60b23..a2f9773b 100644--- a/skills/ppt-master/scripts/pptx_ooxml/ooxml.py+++ b/skills/ppt-master/scripts/pptx_ooxml/ooxml.py@@ -253,6 +253,24 @@ def _container_geometry(return {"x": _px(x), "y": _px(y), "width": _px(width), "height": _px(height)}+def _remove_author_hidden_shapes(root: ET.Element) -> list[ET.Element]:+ """Remove author-hidden shape subtrees from an in-memory extraction view."""+ removed: list[ET.Element] = []+ shape_tags = {f"{{{NS['p']}}}{name}" for name in ("sp", "pic", "cxnSp", "grpSp", "graphicFrame")}++ def visit(parent: ET.Element) -> None:+ for child in list(parent):+ properties = child.find("./*/p:cNvPr", NS) if child.tag in shape_tags else None+ if properties is not None and properties.get("hidden", "").strip().lower() in {"1", "true", "on"}:+ parent.remove(child)+ removed.append(child)+ else:+ visit(child)++ visit(root)+ return removed++def _text_containers(slide_root: ET.Element) -> list[ET.Element]:# mc:Fallback repeats its Choice for other clients; it is not slide content.fallback_nodes = {diff --git a/skills/ppt-master/scripts/pptx_to_svg/converter.py b/skills/ppt-master/scripts/pptx_to_svg/converter.pyindex aff682a8..82753e2a 100644--- a/skills/ppt-master/scripts/pptx_to_svg/converter.py+++ b/skills/ppt-master/scripts/pptx_to_svg/converter.py@@ -531,7 +531,7 @@ def convert_pptx_to_svg(image_name_map = result.resource_inventory.image_name_map()image_name_map.update(options.asset_name_map)options = replace(options, asset_name_map=image_name_map)- result.speaker_notes = import_speaker_notes(pkg)+ result.speaker_notes = import_speaker_notes(pkg, result.diagnostics)result.canvas_px = pkg.slide_size_px# Default theme summary is kept for compatibility; conversion itselfdiff --git a/skills/ppt-master/scripts/pptx_to_svg/notes_import.py b/skills/ppt-master/scripts/pptx_to_svg/notes_import.pyindex 995c9bfa..ac9739cb 100644--- a/skills/ppt-master/scripts/pptx_to_svg/notes_import.py+++ b/skills/ppt-master/scripts/pptx_to_svg/notes_import.py@@ -6,7 +6,8 @@ import hashlibfrom dataclasses import dataclassfrom xml.etree import ElementTree as ET-from .emu_units import NS+from .emu_units import NS, ooxml_bool+from .import_diagnostics import ImportDiagnostic, append_diagnosticfrom .ooxml_loader import OoxmlPackage@@ -57,8 +58,9 @@ def _paragraph_text(paragraph: ET.Element) -> str:return text-def _notes_markdown(root: ET.Element) -> str:+def _notes_markdown(root: ET.Element, hidden_shapes: list[ET.Element]) -> str:blocks: list[str] = []+ parents = {child: parent for parent in root.iter() for child in parent}for shape in root.findall(".//p:sp", NS):placeholder = shape.find("p:nvSpPr/p:nvPr/p:ph", NS)placeholder_type = placeholder.get("type") if placeholder is not None else None@@ -73,11 +75,22 @@ def _notes_markdown(root: ET.Element) -> str:if (text := _paragraph_text(paragraph))]if paragraphs:- blocks.append("\n".join(paragraphs))+ ancestor = shape+ while ancestor is not None:+ properties = ancestor.find("./*/p:cNvPr", NS)+ if properties is not None and ooxml_bool(properties.get("hidden")):+ hidden_shapes.append(shape)+ break+ ancestor = parents.get(ancestor)+ else:+ blocks.append("\n".join(paragraphs))return "\n\n".join(blocks).strip()-def import_speaker_notes(pkg: OoxmlPackage) -> tuple[ImportedSpeakerNote, ...]:+def import_speaker_notes(+ pkg: OoxmlPackage,+ diagnostics: list[ImportDiagnostic] | None = None,+) -> tuple[ImportedSpeakerNote, ...]:"""Return every non-empty source speaker note in presentation order."""notes: list[ImportedSpeakerNote] = []for slide in pkg.iter_slides():@@ -99,7 +112,21 @@ def import_speaker_notes(pkg: OoxmlPackage) -> tuple[ImportedSpeakerNote, ...]:root = ET.fromstring(payload)except ET.ParseError:continue- markdown = _notes_markdown(root)+ hidden_shapes: list[ET.Element] = []+ markdown = _notes_markdown(root, hidden_shapes)+ if diagnostics is not None:+ for shape in hidden_shapes:+ properties = shape.find("p:nvSpPr/p:cNvPr", NS)+ append_diagnostic(diagnostics, ImportDiagnostic(+ code="hidden-notes-content",+ message="Author-hidden speaker-note text was excluded from Markdown",+ fallback="retain hidden source XML on untouched round-trip notes",+ part_path=source_part,+ slide_index=slide.index,+ shape_id=properties.get("id", "") if properties is not None else "",+ shape_name=properties.get("name", "") if properties is not None else "",+ shape_kind="notes-shape",+ ))if not markdown:continuenotes.append(ImportedSpeakerNote(diff --git a/skills/ppt-master/scripts/pptx_to_svg/slide_to_svg.py b/skills/ppt-master/scripts/pptx_to_svg/slide_to_svg.pyindex 655490cf..b742c1d5 100644--- a/skills/ppt-master/scripts/pptx_to_svg/slide_to_svg.py+++ b/skills/ppt-master/scripts/pptx_to_svg/slide_to_svg.py@@ -462,6 +462,11 @@ def _convert_node(node: ShapeNode, ctx: AssemblyContext, *, top_level: bool) ->ctx.current_node = nodetry:if node.hidden and not ctx.keep_hidden:+ ctx.diagnose(+ "author-hidden-omitted",+ "Source shape is marked hidden by its author",+ "exclude the hidden shape and its children from the SVG view",+ )return ""if node.kind == SHAPE:return _convert_shape(node, ctx, top_level=top_level)diff --git a/skills/ppt-master/scripts/source_to_md/ppt_to_md.py b/skills/ppt-master/scripts/source_to_md/ppt_to_md.pyindex a5cedf9d..28de36c1 100644--- a/skills/ppt-master/scripts/source_to_md/ppt_to_md.py+++ b/skills/ppt-master/scripts/source_to_md/ppt_to_md.py@@ -50,6 +50,7 @@ from pptx_ooxml.diagram_read import ( # noqa: E402read_smartart_diagrams,smartart_to_markdown,)+from pptx_ooxml.ooxml import _remove_author_hidden_shapes, _shape_identity # noqa: E402configure_utf8_stdio()@@ -1323,8 +1324,24 @@ def convert_presentation_to_markdown(with zipfile.ZipFile(input_file) as package:for slide_index, slide in enumerate(presentation.slides, 1):slide_part = str(slide.part.partname).lstrip("/")+ hidden_shapes = _remove_author_hidden_shapes(slide._element)+ hidden_ids = {+ node.get("id") for shape in hidden_shapes+ for node in shape.iter(f"{{{PRESENTATIONML_NS}}}cNvPr")+ }+ for shape in hidden_shapes:+ shape_id, shape_name = _shape_identity(shape, 0)+ warning = (+ f"Slide {slide_index}: excluded author-hidden shape "+ f"{shape_name!r} (id={shape_id}) and its children"+ )+ conversion_warnings.append(warning)+ print(f"[WARN] ppt_to_md: {warning}", file=sys.stderr)try:- diagrams = read_smartart_diagrams(package, slide_part, slide_index)+ diagrams = [+ item for item in read_smartart_diagrams(package, slide_part, slide_index)+ if str(item.get("shape_id")) not in hidden_ids+ ]except (OSError, RuntimeError, zipfile.BadZipFile, ET.ParseError) as exc:diagrams_by_slide[slide_index] = []diagram_scan_failures[slide_index] = str(exc)diff --git a/skills/ppt-master/scripts/template_import/manifest.py b/skills/ppt-master/scripts/template_import/manifest.pyindex 1f685c97..2230138d 100644--- a/skills/ppt-master/scripts/template_import/manifest.py+++ b/skills/ppt-master/scripts/template_import/manifest.py@@ -21,6 +21,7 @@ from __future__ import annotationsimport posixpathimport re+import sysimport zipfilefrom collections import Counter, defaultdictfrom dataclasses import dataclass@@ -574,6 +575,13 @@ def build_manifest(for index, slide_path in enumerate(slide_parts, 1):slide_root = load_xml_from_zip(zf, slide_path)+ if slide_root is not None and slide_root.get("show", "").strip().lower() in {"0", "false", "off"}:+ print(+ f"Warning: source slide {index} ({slide_path}) is hidden from the slide show; "+ "template preview export does not preserve this slide-hidden state. "+ "The slide is retained; use Edit Native roundtrip to preserve its source visibility.",+ file=sys.stderr,+ )slide_rels = parse_relationships(zf, slide_path)layout_path = Nonediff --git a/skills/ppt-master/scripts/tests/test_beautify_hidden_content.py b/skills/ppt-master/scripts/tests/test_beautify_hidden_content.pynew file mode 100644index 00000000..03fb3b8a--- /dev/null+++ b/skills/ppt-master/scripts/tests/test_beautify_hidden_content.py@@ -0,0 +1,149 @@+#!/usr/bin/env python3+"""Exclude author-hidden objects from both Beautify content-source paths.++Usage:+ python3 -m unittest tests.test_beautify_hidden_content++Dependencies:+ python-pptx, Pillow, 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 PIL import Image+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]+for directory in (SCRIPTS, SCRIPTS / "source_to_md"):+ if str(directory) not in sys.path:+ sys.path.insert(0, str(directory))++import beautify_inventory # noqa: E402+import ppt_to_md # noqa: E402+import pptx_intake # noqa: E402++NS = {+ "p": "http://schemas.openxmlformats.org/presentationml/2006/main",+ "a": "http://schemas.openxmlformats.org/drawingml/2006/main",+ "r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships",+ "dgm": "http://schemas.openxmlformats.org/drawingml/2006/diagram",+}+++class BeautifyHiddenContentTests(unittest.TestCase):+ def test_hidden_subtrees_are_absent_from_markdown_inventory_and_images(self) -> None:+ with tempfile.TemporaryDirectory() as temporary:+ root = Path(temporary)+ presentation = Presentation()+ slide = presentation.slides.add_slide(presentation.slide_layouts[6])++ def textbox(shapes, text):+ shape = shapes.add_textbox(Inches(1), Inches(1), Inches(4), Inches(1))+ shape.text = text+ return shape++ def hide(shape, value="1"):+ shape.element.xpath("./*/p:cNvPr")[0].set("hidden", value)++ visible = textbox(slide.shapes, "VISIBLE_FALSE_MARKER")+ hide(visible, "false")+ hide(textbox(slide.shapes, "SECRET_TEXT_MARKER"))+ group = slide.shapes.add_group_shape()+ textbox(group.shapes, "SECRET_GROUP_MARKER")+ hide(group, "true")+ table = slide.shapes.add_table(1, 1, Inches(1), Inches(2), Inches(4), Inches(1))+ table.table.cell(0, 0).text = "SECRET_TABLE_MARKER"+ hide(table)+ data = ChartData()+ data.categories = ["SECRET_CATEGORY_MARKER"]+ data.add_series("SECRET_SERIES_MARKER", [271])+ chart = slide.shapes.add_chart(+ XL_CHART_TYPE.COLUMN_CLUSTERED,+ Inches(1), Inches(1), Inches(8), Inches(4), data,+ )+ chart.chart.has_title = True+ chart.chart.chart_title.text_frame.text = "SECRET_TITLE_MARKER"+ hide(chart)+ image = root / "picture.png"+ Image.new("RGB", (30, 30), "red").save(image)+ slide.shapes.add_picture(str(image), Inches(1), Inches(5))+ hidden_picture = slide.shapes.add_picture(str(image), Inches(2), Inches(5))+ hidden_picture.element.xpath("./*/p:cNvPr")[0].set("descr", "SECRET_IMAGE_MARKER")+ hide(hidden_picture, "on")+ source = root / "source.pptx"+ presentation.save(source)++ with zipfile.ZipFile(source) as archive:+ entries = {name: archive.read(name) for name in archive.namelist()}+ slide_xml = ET.fromstring(entries["ppt/slides/slide1.xml"])+ group_xml = slide_xml.find(".//p:grpSp", NS)+ group_xml.append(ET.fromstring(+ f'<p:graphicFrame xmlns:p="{NS["p"]}" xmlns:a="{NS["a"]}" '+ f'xmlns:r="{NS["r"]}" xmlns:dgm="{NS["dgm"]}">'+ '<p:nvGraphicFramePr><p:cNvPr id="90" name="Hidden diagram"/>'+ '<p:cNvGraphicFramePr/><p:nvPr/></p:nvGraphicFramePr>'+ '<p:xfrm><a:off x="0" y="0"/><a:ext cx="1000000" cy="1000000"/></p:xfrm>'+ f'<a:graphic><a:graphicData uri="{NS["dgm"]}">'+ '<dgm:relIds r:dm="rIdHiddenDiagram"/></a:graphicData></a:graphic>'+ '</p:graphicFrame>'+ ))+ entries["ppt/slides/slide1.xml"] = ET.tostring(slide_xml)+ rel_name = "ppt/slides/_rels/slide1.xml.rels"+ rels = ET.fromstring(entries[rel_name])+ rel_namespace = "http://schemas.openxmlformats.org/package/2006/relationships"+ ET.SubElement(rels, f"{{{rel_namespace}}}Relationship", {+ "Id": "rIdHiddenDiagram", "Type": NS["r"] + "/diagramData",+ "Target": "../diagrams/data1.xml",+ })+ entries[rel_name] = ET.tostring(rels)+ entries["ppt/diagrams/data1.xml"] = (+ f'<dgm:dataModel xmlns:dgm="{NS["dgm"]}" xmlns:a="{NS["a"]}">'+ '<dgm:ptLst><dgm:pt modelId="1" type="node"><dgm:prSet/>'+ '<dgm:t><a:bodyPr/><a:lstStyle/><a:p><a:r>'+ '<a:t>SECRET_DIAGRAM_MARKER</a:t></a:r></a:p></dgm:t>'+ '</dgm:pt></dgm:ptLst><dgm:cxnLst/></dgm:dataModel>'+ ).encode()+ content_types = ET.fromstring(entries["[Content_Types].xml"])+ ET.SubElement(content_types, "{http://schemas.openxmlformats.org/package/2006/content-types}Override", {+ "PartName": "/ppt/diagrams/data1.xml",+ "ContentType": "application/vnd.openxmlformats-officedocument.drawingml.diagramData+xml",+ })+ entries["[Content_Types].xml"] = ET.tostring(content_types)+ with zipfile.ZipFile(source, "w") as archive:+ for name, payload in entries.items():+ archive.writestr(name, payload)+ original = source.read_bytes()+ warnings = io.StringIO()+ with contextlib.redirect_stdout(io.StringIO()), contextlib.redirect_stderr(warnings):+ self.assertEqual(ppt_to_md.main([str(source), "-o", str(root / "source.md")]), 0)+ self.assertEqual(pptx_intake.main([str(source), "-o", str(root / "analysis")]), 0)+ self.assertEqual(beautify_inventory.main([+ str(root / "analysis/source.slide_library.json"),+ "--images", str(root / "source_files/image_manifest.json"),+ "-o", str(root / "inventory.json"),+ ]), 0)+ markdown = (root / "source.md").read_text(encoding="utf-8")+ inventory_text = (root / "inventory.json").read_text(encoding="utf-8")+ for text in (markdown, inventory_text):+ self.assertIn("VISIBLE_FALSE_MARKER", text)+ self.assertNotIn("SECRET_", text)+ inventory = json.loads(inventory_text)+ self.assertEqual(len(inventory["slides"][0]["images"]), 1)+ self.assertEqual(inventory["slides"][0]["tables"], [])+ self.assertEqual(inventory["slides"][0]["charts"], [])+ self.assertEqual(inventory["slides"][0]["diagrams"], [])+ self.assertIn("excluded author-hidden", warnings.getvalue())+ self.assertEqual(source.read_bytes(), original)diff --git a/skills/ppt-master/scripts/tests/test_pptx_geometry_import_losses.py b/skills/ppt-master/scripts/tests/test_pptx_geometry_import_losses.pyindex 828b3e37..99aeae2f 100644--- a/skills/ppt-master/scripts/tests/test_pptx_geometry_import_losses.py+++ b/skills/ppt-master/scripts/tests/test_pptx_geometry_import_losses.py@@ -141,7 +141,8 @@ class GeometryImportLossTests(unittest.TestCase):for frame, hidden in ((_frame(300, 100), False), (_frame(0, 0), True)):with self.subTest(hidden=hidden):_, report = self._import(_shape('<a:prstGeom prst="rect"/>', frame, hidden=hidden))- self.assertEqual(report['diagnostics'], [])+ expected = ['author-hidden-omitted'] if hidden else []+ self.assertEqual([item['code'] for item in report['diagnostics']], expected)def test_existing_zero_axis_connector_does_not_report_geometry_loss(self) -> None:svg, report = self._import(_shape(diff --git a/skills/ppt-master/scripts/tests/test_pptx_hidden_shape_diagnostics.py b/skills/ppt-master/scripts/tests/test_pptx_hidden_shape_diagnostics.pynew file mode 100644index 00000000..a0908255--- /dev/null+++ b/skills/ppt-master/scripts/tests/test_pptx_hidden_shape_diagnostics.py@@ -0,0 +1,62 @@+#!/usr/bin/env python3+"""Report intentional hidden-shape exclusions without changing source objects.++Usage:+ python3 -m unittest tests.test_pptx_hidden_shape_diagnostics++Dependencies:+ python-pptx and the script runtime dependencies.+"""++from __future__ import annotations++import contextlib+import io+from pathlib import Path+import tempfile+import unittest++from pptx import Presentation+from pptx.util import Inches++from pptx_to_svg.converter import ConvertOptions, convert_pptx_to_svg+++class HiddenShapeDiagnosticTests(unittest.TestCase):+ def test_hidden_shape_and_group_are_excluded_with_diagnostics(self) -> None:+ with tempfile.TemporaryDirectory() as temporary:+ root = Path(temporary)+ presentation = Presentation()+ slide = presentation.slides.add_slide(presentation.slide_layouts[6])+ visible = slide.shapes.add_textbox(Inches(1), Inches(1), Inches(4), Inches(1))+ visible.text = "VISIBLE_MARKER"+ hidden = slide.shapes.add_textbox(Inches(1), Inches(2), Inches(4), Inches(1))+ hidden.text = "HIDDEN_SHAPE_MARKER"+ hidden.element.xpath(".//p:cNvPr")[0].set("hidden", "1")+ group = slide.shapes.add_group_shape()+ child = group.shapes.add_textbox(Inches(1), Inches(3), Inches(4), Inches(1))+ child.text = "HIDDEN_GROUP_MARKER"+ group.element.xpath("./p:nvGrpSpPr/p:cNvPr")[0].set("hidden", "true")+ source = root / "source.pptx"+ presentation.save(source)+ before = source.read_bytes()+ for keep_hidden in (False, True):+ destination = root / str(keep_hidden)+ with contextlib.redirect_stdout(io.StringIO()), contextlib.redirect_stderr(io.StringIO()):+ result = convert_pptx_to_svg(+ source, destination,+ ConvertOptions(inheritance_mode="both", keep_hidden=keep_hidden),+ )+ text = (destination / "svg-flat/slide_01.svg").read_text(encoding="utf-8")+ self.assertIn("VISIBLE_MARKER", text)+ warnings = [d for d in result.diagnostics if d.code == "author-hidden-omitted"]+ if keep_hidden:+ self.assertIn("HIDDEN_SHAPE_MARKER", text)+ self.assertIn("HIDDEN_GROUP_MARKER", text)+ self.assertEqual(warnings, [])+ else:+ self.assertNotIn("HIDDEN_SHAPE_MARKER", text)+ self.assertNotIn("HIDDEN_GROUP_MARKER", text)+ self.assertEqual({d.shape_id for d in warnings}, {str(hidden.shape_id), str(group.shape_id)})+ self.assertTrue(all(d.part_path == "ppt/slides/slide1.xml" for d in warnings))+ self.assertEqual(source.read_bytes(), before)diff --git a/skills/ppt-master/scripts/tests/test_roundtrip_hidden_notes.py b/skills/ppt-master/scripts/tests/test_roundtrip_hidden_notes.pynew file mode 100644index 00000000..cd33c4f2--- /dev/null+++ b/skills/ppt-master/scripts/tests/test_roundtrip_hidden_notes.py@@ -0,0 +1,125 @@+#!/usr/bin/env python3+"""PPT Master - Hidden Speaker Notes Regression Tests++Keep author-hidden source notes out of editable Markdown and note overlays.++Usage:+ python3 -m unittest tests.test_roundtrip_hidden_notes++Examples:+ Run the module from the scripts directory.++Dependencies:+ python-pptx and the local PPTX import/export pipeline.+"""++from __future__ import annotations++import copy+import io+import tempfile+import unittest+import zipfile+from contextlib import redirect_stderr, redirect_stdout+from pathlib import Path+from xml.etree import ElementTree as ET++from pptx import Presentation++from pptx_to_svg.converter import ConvertOptions, convert_pptx_to_svg+from svg_to_pptx.pptx_package.cli import main as export_main+++NS = {+ "p": "http://schemas.openxmlformats.org/presentationml/2006/main",+ "a": "http://schemas.openxmlformats.org/drawingml/2006/main",+}+NOTES_PART = "ppt/notesSlides/notesSlide1.xml"+++class RoundtripHiddenNotesTests(unittest.TestCase):+ def setUp(self) -> None:+ temporary = tempfile.TemporaryDirectory()+ self.addCleanup(temporary.cleanup)+ self.root = Path(temporary.name)+ self.source = self.root / "source.pptx"+ self.workspace = self.root / "workspace"++ def _import(self, *, grouped: bool = False, visible: bool = True) -> None:+ deck = Presentation()+ slide = deck.slides.add_slide(deck.slide_layouts[6])+ slide.notes_slide.notes_text_frame.text = "VISIBLE_NOTES"+ deck.save(self.source)+ with zipfile.ZipFile(self.source) as archive:+ parts = {name: archive.read(name) for name in archive.namelist()}+ root = ET.fromstring(parts[NOTES_PART])+ tree = root.find("p:cSld/p:spTree", NS)+ body = next(shape for shape in tree if shape.find(+ 'p:nvSpPr/p:nvPr/p:ph[@type="body"]', NS,+ ) is not None)+ hidden = copy.deepcopy(body)+ properties = hidden.find("p:nvSpPr/p:cNvPr", NS)+ properties.set("id", "90")+ properties.set("name", "Hidden note")+ hidden.find(".//a:t", NS).text = "HIDDEN_NOTES"+ if grouped:+ group = ET.fromstring(+ f'<p:grpSp xmlns:p="{NS["p"]}"><p:nvGrpSpPr>'+ '<p:cNvPr id="91" name="Hidden group" hidden="true"/>'+ '<p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr><p:grpSpPr/></p:grpSp>'+ )+ group.append(hidden)+ tree.append(group)+ else:+ properties.set("hidden", "1")+ tree.append(hidden)+ if not visible:+ tree.remove(body)+ parts[NOTES_PART] = ET.tostring(root)+ with zipfile.ZipFile(self.source, "w", zipfile.ZIP_DEFLATED) as archive:+ for name, payload in parts.items():+ archive.writestr(name, payload)+ self.source_parts = parts+ with redirect_stdout(io.StringIO()), redirect_stderr(io.StringIO()):+ self.result = convert_pptx_to_svg(+ self.source, self.workspace, ConvertOptions(inheritance_mode="both", roundtrip=True),+ )+ warnings = [item for item in self.result.diagnostics if item.code == "hidden-notes-content"]+ self.assertEqual(len(warnings), 1)+ self.assertEqual(warnings[0].part_path, NOTES_PART)+ self.assertEqual(warnings[0].shape_id, "90")++ def _export(self) -> dict[str, bytes]:+ output = self.root / "output.pptx"+ stdout, stderr = io.StringIO(), io.StringIO()+ with redirect_stdout(stdout), redirect_stderr(stderr):+ result = export_main([str(self.workspace), "--roundtrip", "-o", str(output)])+ self.assertEqual(result, 0, stdout.getvalue() + stderr.getvalue())+ self.assertIn("rebuilt=0", stdout.getvalue())+ with zipfile.ZipFile(output) as archive:+ return {name: archive.read(name) for name in archive.namelist()}++ def test_hidden_shape_does_not_leak_when_visible_notes_are_edited(self) -> None:+ self._import()+ note = self.workspace / "notes/slide_01.md"+ self.assertEqual(note.read_text(encoding="utf-8").strip(), "VISIBLE_NOTES")+ note.write_text(note.read_text(encoding="utf-8") + "\nNOTE_EDIT\n", encoding="utf-8")+ parts = self._export()+ self.assertIn(b"VISIBLE_NOTES", parts[NOTES_PART])+ self.assertIn(b"NOTE_EDIT", parts[NOTES_PART])+ self.assertNotIn(b"HIDDEN_NOTES", parts[NOTES_PART])++ def test_hidden_group_notes_stay_hidden_and_untouched_native_notes_are_exact(self) -> None:+ self._import(grouped=True)+ note = self.workspace / "notes/slide_01.md"+ self.assertNotIn("HIDDEN_NOTES", note.read_text(encoding="utf-8"))+ parts = self._export()+ self.assertEqual(parts[NOTES_PART], self.source_parts[NOTES_PART])+ self.assertEqual(parts["ppt/slides/slide1.xml"], self.source_parts["ppt/slides/slide1.xml"])++ def test_all_hidden_notes_warn_without_creating_markdown(self) -> None:+ self._import(visible=False)+ self.assertFalse((self.workspace / "notes/slide_01.md").exists())+ self.assertEqual(self.result.speaker_notes, ())+ parts = self._export()+ self.assertEqual(parts[NOTES_PART], self.source_parts[NOTES_PART])diff --git a/skills/ppt-master/scripts/tests/test_template_hidden_slide_diagnostic.py b/skills/ppt-master/scripts/tests/test_template_hidden_slide_diagnostic.pynew file mode 100644index 00000000..48a2be8a--- /dev/null+++ b/skills/ppt-master/scripts/tests/test_template_hidden_slide_diagnostic.py@@ -0,0 +1,55 @@+#!/usr/bin/env python3+"""Diagnose hidden-slide visibility unsupported by template preview export.++Usage:+ python3 -m unittest tests.test_template_hidden_slide_diagnostic++Dependencies:+ python-pptx and the script runtime dependencies.+"""++from __future__ import annotations++import contextlib+import io+from pathlib import Path+import sys+import tempfile+import unittest+from unittest.mock import patch++from pptx import Presentation+from pptx.util import Inches++import pptx_template_import+from pptx_to_svg.converter import ConvertOptions, convert_pptx_to_svg+++class TemplateHiddenSlideDiagnosticTests(unittest.TestCase):+ def test_template_warns_without_dropping_slide_or_warning_about_roundtrip(self) -> None:+ with tempfile.TemporaryDirectory() as temporary:+ root = Path(temporary)+ presentation = Presentation()+ slide = presentation.slides.add_slide(presentation.slide_layouts[6])+ slide.element.set("show", "0")+ textbox = slide.shapes.add_textbox(Inches(1), Inches(1), Inches(4), Inches(1))+ textbox.text = "HIDDEN_SLIDE_MARKER"+ source = root / "source.pptx"+ presentation.save(source)+ warnings = io.StringIO()+ imported = root / "template"+ with contextlib.redirect_stdout(io.StringIO()), contextlib.redirect_stderr(warnings), patch.object(+ sys, "argv", ["pptx_template_import.py", str(source), "-o", str(imported)],+ ):+ self.assertEqual(pptx_template_import.main(), 0)+ self.assertIn("source slide 1 (ppt/slides/slide1.xml)", warnings.getvalue())+ self.assertIn("template preview export does not preserve", warnings.getvalue())+ self.assertIn("HIDDEN_SLIDE_MARKER", (imported / "svg/slide_01.svg").read_text(encoding="utf-8"))+ self.assertEqual((imported / "sources/source.pptx").read_bytes(), source.read_bytes())+ native_warnings = io.StringIO()+ with contextlib.redirect_stdout(io.StringIO()), contextlib.redirect_stderr(native_warnings):+ converted = convert_pptx_to_svg(+ source, root / "roundtrip", ConvertOptions(roundtrip=True),+ )+ self.assertEqual(len(converted.slides), 1)+ self.assertNotIn("template preview export", native_warnings.getvalue())