Skip to content

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(template-import): use explicit text-style precedence

hugohe360fe3f0d40d7
diff --git a/skills/ppt-master/scripts/template_import/manifest.py b/skills/ppt-master/scripts/template_import/manifest.py
index f34f78a8..018700ec 100644
--- a/skills/ppt-master/scripts/template_import/manifest.py
+++ b/skills/ppt-master/scripts/template_import/manifest.py
@@ -311,7 +311,9 @@ def count_drawable_shapes(root: ET.Element | None) -> int:
def extract_placeholder_text_style(sp: ET.Element) -> dict[str, Any]:
style: dict[str, Any] = {}
- rpr = sp.find(".//a:rPr", NS) or sp.find(".//a:endParaRPr", NS)
+ rpr = sp.find(".//a:rPr", NS)
+ if rpr is None:
+ rpr = sp.find(".//a:endParaRPr", NS)
if rpr is None:
return style
if rpr.attrib.get("sz"):
diff --git a/skills/ppt-master/scripts/test_svg_quality_checker.py b/skills/ppt-master/scripts/test_svg_quality_checker.py
index 01f69ccb..011f882e 100644
--- a/skills/ppt-master/scripts/test_svg_quality_checker.py
+++ b/skills/ppt-master/scripts/test_svg_quality_checker.py
@@ -11,6 +11,7 @@ import re
import sys
import tempfile
import unittest
+import warnings
import zipfile
from pathlib import Path
from unittest.mock import patch
@@ -90,6 +91,7 @@ from template_preview_pptx import _canvas_viewbox as preview_canvas_viewbox
from template_import.manifest import (
_effective_inherited_image_assets,
build_manifest,
+ extract_placeholder_text_style,
)
from template_import.native_structure import build_native_structure
from pptx_effects import project_effect_status_errors, txbody_has_run_effects
@@ -1185,6 +1187,33 @@ class SVGQualityCheckerCompatibilityTests(unittest.TestCase):
{'layout-shape.png', 'master-shared.png'},
)
+ def test_manifest_text_style_uses_explicit_element_precedence(self):
+ pml = 'http://schemas.openxmlformats.org/presentationml/2006/main'
+ dml = 'http://schemas.openxmlformats.org/drawingml/2006/main'
+ shape = ET.fromstring(f'''<p:sp xmlns:p="{pml}" xmlns:a="{dml}">
+ <p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:r>
+ <a:rPr sz="2400" b="1"/><a:t>Primary</a:t>
+ </a:r><a:endParaRPr sz="1200" i="1"/></a:p></p:txBody>
+</p:sp>''')
+ fallback_shape = ET.fromstring(
+ f'''<p:sp xmlns:p="{pml}" xmlns:a="{dml}">
+ <p:txBody><a:bodyPr/><a:lstStyle/><a:p>
+ <a:endParaRPr sz="1200" i="1"/>
+ </a:p></p:txBody>
+</p:sp>'''
+ )
+
+ with warnings.catch_warnings():
+ warnings.simplefilter('error', DeprecationWarning)
+ primary = extract_placeholder_text_style(shape)
+ fallback = extract_placeholder_text_style(fallback_shape)
+
+ self.assertEqual(primary['fontSizePx'], 32.0)
+ self.assertTrue(primary['bold'])
+ self.assertNotIn('italic', primary)
+ self.assertEqual(fallback['fontSizePx'], 16.0)
+ self.assertTrue(fallback['italic'])
+
def test_top_level_group_ids_are_unique_animation_anchors(self):
duplicate = '''<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
<g id="card"><rect x="10" y="10" width="20" height="20" fill="#000000"/></g>