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 gradient stop positions
hugohe32f7efc8b3edf
diff --git a/skills/ppt-master/references/shared-standards.md b/skills/ppt-master/references/shared-standards.mdindex 729fe912..eeaf5055 100644--- a/skills/ppt-master/references/shared-standards.md+++ b/skills/ppt-master/references/shared-standards.md@@ -741,6 +741,9 @@ PPTX import writes stop offsets with five decimal places, and export parses theshared unitless/percentage grammar before half-up quantization to 1/100000.Thus small positions and values such as `1%` round-trip without truncation orpercentage reinterpretation.+Each imported `a:gs` requires an integer `pos` from `0` through `100000`.+Missing, malformed, or out-of-range source positions stop import instead of+being silently relocated to the start of the gradient.The quality checker and exporter preflight both validate definition location,references, gradient structure, and paint context from the same closed contract.diff --git a/skills/ppt-master/scripts/pptx_to_svg/fill_to_svg.py b/skills/ppt-master/scripts/pptx_to_svg/fill_to_svg.pyindex ba8f0a3b..e7b71127 100644--- a/skills/ppt-master/scripts/pptx_to_svg/fill_to_svg.py+++ b/skills/ppt-master/scripts/pptx_to_svg/fill_to_svg.py@@ -13,19 +13,23 @@ slide assembler can collect gradient defs without conflicting IDs.from __future__ import annotationsimport math+import refrom dataclasses import dataclass, fieldfrom xml.etree import ElementTree as ETfrom .color_resolver import ColorPalette, find_color_elem, resolve_colorfrom .emu_units import (NS,+ PERCENT_UNIT,fmt_num,format_ooxml_alpha,format_ooxml_unit_ratio,- percent_to_ratio,)+_OOXML_INTEGER_RE = re.compile(r"[+-]?[0-9]+")++@dataclassclass FillResult:"""Resolved fill: SVG attributes to apply + optional <defs> entries."""@@ -124,7 +128,7 @@ def _resolve_grad_fill(elem: ET.Element, palette: ColorPalette | None,return FillResult.inherit()stops_xml = []for gs in gs_lst.findall("a:gs", NS):- pos_pct = percent_to_ratio(gs.attrib.get("pos"), default=0.0)+ pos_pct = _gradient_stop_position(gs)color_elem = find_color_elem(gs)hex_, alpha = resolve_color(color_elem, palette, placeholder_hex=placeholder_hex)if hex_ is None:@@ -181,6 +185,25 @@ def _resolve_grad_fill(elem: ET.Element, palette: ColorPalette | None,)+def _gradient_stop_position(gs: ET.Element) -> float:+ """Parse one required DrawingML fixed-percentage stop position."""+ raw = gs.get("pos")+ if raw is None:+ raise ValueError("DrawingML gradient stop requires a pos attribute")+ token = raw.strip()+ if _OOXML_INTEGER_RE.fullmatch(token) is None:+ raise ValueError(+ f"Invalid DrawingML gradient stop position: {raw!r}"+ )+ position = int(token)+ if not 0 <= position <= PERCENT_UNIT:+ raise ValueError(+ f"DrawingML gradient stop position={position} is outside "+ f"0..{PERCENT_UNIT}"+ )+ return position / PERCENT_UNIT++def _resolve_blip_fill(_elem, _palette, _prefix, _seq, _placeholder_hex) -> FillResult:"""blipFill on <p:spPr> means a shape filled with an image — handled atpic_to_svg level. For now mark as transparent so the shape's outlinediff --git a/skills/ppt-master/scripts/test_svg_quality_checker.py b/skills/ppt-master/scripts/test_svg_quality_checker.pyindex 67195aac..a3594051 100644--- a/skills/ppt-master/scripts/test_svg_quality_checker.py+++ b/skills/ppt-master/scripts/test_svg_quality_checker.py@@ -2785,7 +2785,7 @@ class SVGQualityCheckerCompatibilityTests(unittest.TestCase):)def test_native_gradient_stop_position_round_trips(self):- for position in (1, 7, 13, 33333, 99999):+ for position in (0, 1, 7, 13, 33333, 99999, 100000):with self.subTest(position=position):sp_pr = ET.fromstring(f'''<p:spPr xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main"@@ -2813,6 +2813,31 @@ class SVGQualityCheckerCompatibilityTests(unittest.TestCase):</linearGradient>''')self.assertIn('<a:gs pos="1000">', build_gradient_fill(percentage))+ def test_native_gradient_stop_position_must_be_valid(self):+ invalid_positions = (+ (None, 'requires a pos attribute'),+ ('', 'Invalid DrawingML gradient stop position'),+ ('1.5', 'Invalid DrawingML gradient stop position'),+ ('1e2', 'Invalid DrawingML gradient stop position'),+ ('NaN', 'Invalid DrawingML gradient stop position'),+ ('-1', 'position=-1 is outside 0..100000'),+ ('100001', 'position=100001 is outside 0..100000'),+ )+ for position, expected in invalid_positions:+ with self.subTest(position=position):+ pos_attr = '' if position is None else f' pos="{position}"'+ sp_pr = ET.fromstring(f'''+<p:spPr xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main"+ xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">+ <a:gradFill>+ <a:gsLst>+ <a:gs{pos_attr}><a:srgbClr val="112233"/></a:gs>+ </a:gsLst>+ </a:gradFill>+</p:spPr>''')+ with self.assertRaisesRegex(ValueError, expected):+ resolve_fill(sp_pr, None)+def test_compound_native_line_is_rejected_on_import(self):for compound in ('dbl', 'thickThin', 'thinThick', 'tri'):with self.subTest(compound=compound):