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 system color fallbacks
hugohe3e307d6cc084e
diff --git a/skills/ppt-master/references/shared-standards.md b/skills/ppt-master/references/shared-standards.mdindex d567fee0..49936bf9 100644--- a/skills/ppt-master/references/shared-standards.md+++ b/skills/ppt-master/references/shared-standards.md@@ -744,6 +744,13 @@ references, extra attributes, namespace aliases, and interleaved text stopimport. A registered reference that cannot be resolved from the active themeor `phClr` placeholder context remains a resolution failure, not an unknownenum fallback.+Imported `a:sysClr` requires a registered DrawingML system-color `val` and a+six-digit `lastClr` fallback. The latter is optional in OOXML but mandatory for+this portable mapping because the converter cannot reproduce the source+machine's dynamic system palette. Missing/unknown system identities, malformed+fallbacks, extra attributes, namespace aliases, and interleaved text stop+import; a valid `lastClr` is normalized into static SVG paint, so this route is+`Native-normalized` rather than system-color-preserving.---diff --git a/skills/ppt-master/scripts/pptx_to_svg/color_resolver.py b/skills/ppt-master/scripts/pptx_to_svg/color_resolver.pyindex 8ea2783c..b46f8cf5 100644--- a/skills/ppt-master/scripts/pptx_to_svg/color_resolver.py+++ b/skills/ppt-master/scripts/pptx_to_svg/color_resolver.py@@ -121,6 +121,38 @@ _SCHEME_COLOR_VALUES = {"dk2","lt2",}+_SYSTEM_COLOR_VALUES = {+ "scrollBar",+ "background",+ "activeCaption",+ "inactiveCaption",+ "menu",+ "window",+ "windowFrame",+ "menuText",+ "windowText",+ "captionText",+ "activeBorder",+ "inactiveBorder",+ "appWorkspace",+ "highlight",+ "highlightText",+ "btnFace",+ "btnShadow",+ "grayText",+ "btnText",+ "inactiveCaptionText",+ "btnHighlight",+ "3dDkShadow",+ "3dLight",+ "infoText",+ "infoBk",+ "hotLight",+ "gradientActiveCaption",+ "gradientInactiveCaption",+ "menuHighlight",+ "menuBar",+}# ---------------------------------------------------------------------------@@ -266,8 +298,7 @@ def resolve_color(elif palette is not None:base_hex = palette.resolve_scheme(name)elif tag == "sysClr":- last = color_elem.attrib.get("lastClr") or color_elem.attrib.get("val")- base_hex = _normalize_hex(last) if last else None+ base_hex = _system_color_fallback(color_elem)elif tag == "prstClr":name = color_elem.attrib.get("val", "")base_hex = PRST_COLORS.get(name)@@ -325,6 +356,32 @@ def _scheme_color_name(color_elem: ET.Element) -> str:return name+def _system_color_fallback(color_elem: ET.Element) -> str:+ """Parse a registered system color with a portable six-digit fallback."""+ children = list(color_elem)+ if (+ color_elem.tag != f"{{{NS['a']}}}sysClr"+ or set(color_elem.attrib) - {"val", "lastClr"}+ or "val" not in color_elem.attrib+ or (color_elem.text or "").strip()+ or any((child.tail or "").strip() for child in children)+ ):+ raise ValueError("Invalid DrawingML system color structure")+ name = color_elem.attrib["val"]+ if name not in _SYSTEM_COLOR_VALUES:+ raise ValueError(f"Invalid DrawingML system color value: {name!r}")+ fallback = color_elem.get("lastClr")+ if fallback is None:+ raise ValueError(+ "DrawingML system color requires a lastClr fallback"+ )+ if _SRGB_HEX_RE.fullmatch(fallback) is None:+ raise ValueError(+ f"Invalid DrawingML system color fallback: {fallback!r}"+ )+ return fallback.upper()++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 14a8648e..6e78bb13 100644--- a/skills/ppt-master/scripts/test_svg_quality_checker.py+++ b/skills/ppt-master/scripts/test_svg_quality_checker.py@@ -3006,6 +3006,68 @@ class SVGQualityCheckerCompatibilityTests(unittest.TestCase):('#445566', 1.0),)+ def test_native_system_color_requires_registered_fallback(self):+ invalid_colors = (+ ('<a:sysClr lastClr="112233"/>', 'system color structure'),+ (+ '<a:sysClr val="futureColor" lastClr="112233"/>',+ 'system color value',+ ),+ (+ '<a:sysClr val="WindowText" lastClr="112233"/>',+ 'system color value',+ ),+ (+ '<a:sysClr val="windowText"/>',+ 'requires a lastClr fallback',+ ),+ (+ '<a:sysClr val="windowText" lastClr="ABC"/>',+ 'system color fallback',+ ),+ (+ '<a:sysClr val="windowText" lastClr="#112233"/>',+ 'system color fallback',+ ),+ (+ '<a:sysClr val="windowText" lastClr="112233" future="x"/>',+ 'system color structure',+ ),+ (+ '<a:sysClr val="windowText" lastClr="112233">payload'+ '</a:sysClr>',+ 'system color structure',+ ),+ (+ '<a:sysClr val="windowText" lastClr="112233">'+ '<a:alpha val="50000"/>payload</a:sysClr>',+ 'system 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:sysClr xmlns:future="urn:future" '+ 'val="windowText" lastClr="112233"/>'+ )+ with self.assertRaisesRegex(ValueError, 'system color structure'):+ resolve_color(foreign_color, None)++ valid = ET.fromstring(f'''+<a:sysClr {namespace} val="windowText" lastClr="a1b2c3">+ <a:alpha val="50000"/>+</a:sysClr>''')+ self.assertEqual(resolve_color(valid, None), ('#A1B2C3', 0.5))+def test_native_gradient_stop_position_round_trips(self):for position in (0, 1, 7, 13, 33333, 99999, 100000):with self.subTest(position=position):