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-to-svg): validate scheme color references
hugohe38e24ae8e005f
diff --git a/skills/ppt-master/references/shared-standards.md b/skills/ppt-master/references/shared-standards.mdindex 91d8927a..d567fee0 100644--- a/skills/ppt-master/references/shared-standards.md+++ b/skills/ppt-master/references/shared-standards.md@@ -737,6 +737,13 @@ leading `#`, alpha-bearing eight-digit tokens, extra attributes, andinterleaved text stop import instead of being normalized into a differentDrawingML token. Lowercase hexadecimal digits remain equivalent input andnormalize to uppercase SVG paint.+Imported `a:schemeClr` likewise has exactly one `val` attribute and accepts only+the DrawingML scheme enum: `bg1`, `tx1`, `bg2`, `tx2`, `accent1..6`, `hlink`,+`folHlink`, `phClr`, `dk1`, `lt1`, `dk2`, or `lt2`. Unknown/case-altered+references, extra attributes, namespace aliases, and interleaved text stop+import. A registered reference that cannot be resolved from the active theme+or `phClr` placeholder context remains a resolution failure, not an unknown+enum fallback.---diff --git a/skills/ppt-master/scripts/pptx_to_svg/color_resolver.py b/skills/ppt-master/scripts/pptx_to_svg/color_resolver.pyindex 210351bd..8ea2783c 100644--- a/skills/ppt-master/scripts/pptx_to_svg/color_resolver.py+++ b/skills/ppt-master/scripts/pptx_to_svg/color_resolver.py@@ -102,6 +102,25 @@ SCHEME_ALIASES = {"tx1": "dk1", "tx2": "dk2",}_SRGB_HEX_RE = re.compile(r"[0-9A-Fa-f]{6}")+_SCHEME_COLOR_VALUES = {+ "bg1",+ "tx1",+ "bg2",+ "tx2",+ "accent1",+ "accent2",+ "accent3",+ "accent4",+ "accent5",+ "accent6",+ "hlink",+ "folHlink",+ "phClr",+ "dk1",+ "lt1",+ "dk2",+ "lt2",+}# ---------------------------------------------------------------------------@@ -241,7 +260,7 @@ def resolve_color(if tag == "srgbClr":base_hex = _srgb_hex_value(color_elem)elif tag == "schemeClr":- name = color_elem.attrib.get("val", "")+ name = _scheme_color_name(color_elem)if name == "phClr":base_hex = _normalize_hex(placeholder_hex) if placeholder_hex else Noneelif palette is not None:@@ -290,6 +309,22 @@ def _srgb_hex_value(color_elem: ET.Element) -> str:return raw.upper()+def _scheme_color_name(color_elem: ET.Element) -> str:+ """Parse one closed DrawingML scheme-color reference."""+ children = list(color_elem)+ if (+ color_elem.tag != f"{{{NS['a']}}}schemeClr"+ or set(color_elem.attrib) != {"val"}+ or (color_elem.text or "").strip()+ or any((child.tail or "").strip() for child in children)+ ):+ raise ValueError("Invalid DrawingML scheme color structure")+ name = color_elem.attrib["val"]+ if name not in _SCHEME_COLOR_VALUES:+ raise ValueError(f"Invalid DrawingML scheme color value: {name!r}")+ return name++def _apply_modifiers(hex_color: str, color_elem: ET.Element) -> tuple[str, float]:"""Apply tint / shade / lumMod / lumOff / satMod / hueMod / alpha modifiersin document order. DrawingML stacks these on the color in order.diff --git a/skills/ppt-master/scripts/test_svg_quality_checker.py b/skills/ppt-master/scripts/test_svg_quality_checker.pyindex cebe7524..14a8648e 100644--- a/skills/ppt-master/scripts/test_svg_quality_checker.py+++ b/skills/ppt-master/scripts/test_svg_quality_checker.py@@ -40,7 +40,7 @@ from pptx_to_svg.preset_authoring import (validate_authored_preset_tree,)from pptx_to_svg.emu_units import Xfrm, format_ooxml_alpha-from pptx_to_svg.color_resolver import resolve_color+from pptx_to_svg.color_resolver import ColorPalette, resolve_colorfrom pptx_to_svg.effect_to_svg import (convert_effects,unsupported_target_effect_metadata,@@ -2954,6 +2954,58 @@ class SVGQualityCheckerCompatibilityTests(unittest.TestCase):self.assertEqual(resolved.attrs['fill'], '#A1B2C3')self.assertEqual(resolved.attrs['fill-opacity'], '0.5')+ def test_native_scheme_color_requires_registered_reference(self):+ invalid_colors = (+ ('<a:schemeClr/>', 'scheme color structure'),+ (+ '<a:schemeClr val="accent1" future="x"/>',+ 'scheme color structure',+ ),+ ('<a:schemeClr val="Accent1"/>', 'scheme color value'),+ ('<a:schemeClr val="accent7"/>', 'scheme color value'),+ ('<a:schemeClr val=" accent1 "/>', 'scheme color value'),+ (+ '<a:schemeClr val="accent1">payload</a:schemeClr>',+ 'scheme color structure',+ ),+ (+ '<a:schemeClr val="accent1"><a:tint val="50000"/>payload'+ '</a:schemeClr>',+ 'scheme color structure',+ ),+ )+ namespace = (+ 'xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"'+ )+ for color, expected in invalid_colors:+ with self.subTest(color=color):+ fill = ET.fromstring(+ f'<a:solidFill {namespace}>{color}</a:solidFill>'+ )+ with self.assertRaisesRegex(ValueError, expected):+ resolve_fill(fill, None)++ foreign_color = ET.fromstring(+ '<future:schemeClr xmlns:future="urn:future" val="accent1"/>'+ )+ with self.assertRaisesRegex(ValueError, 'scheme color structure'):+ resolve_color(foreign_color, None)++ palette = ColorPalette(None, None)+ palette.scheme['accent1'] = '112233'+ accent = ET.fromstring(+ f'<a:schemeClr {namespace} val="accent1"/>'+ )+ self.assertEqual(resolve_color(accent, palette), ('#112233', 1.0))++ placeholder = ET.fromstring(+ f'<a:schemeClr {namespace} val="phClr"/>'+ )+ self.assertEqual(+ resolve_color(placeholder, None, placeholder_hex='#445566'),+ ('#445566', 1.0),+ )+def test_native_gradient_stop_position_round_trips(self):for position in (0, 1, 7, 13, 33333, 99999, 100000):with self.subTest(position=position):