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): enforce line-end element structure
hugohe3ab14b8d698f2
diff --git a/skills/ppt-master/references/shared-standards.md b/skills/ppt-master/references/shared-standards.mdindex 9cb94663..ed86317c 100644--- a/skills/ppt-master/references/shared-standards.md+++ b/skills/ppt-master/references/shared-standards.md@@ -183,6 +183,10 @@ dropped. PPTX import likewise accepts only these five DrawingML line-end typesas a supported shape. Optional DrawingML `w` and `len` values default to `med`;explicit values must be `sm`, `med`, or `lg`, and invalid source buckets stopimport instead of being normalized to `med`.+Each imported line contains at most one direct, empty `a:headEnd` and one direct,+empty `a:tailEnd`, carrying only optional `type`, `w`, and `len`. Omitted `type`+means `none`; an explicitly empty token, duplicate endpoint, unknown attribute,+or child payload stops import instead of being ignored.---diff --git a/skills/ppt-master/scripts/pptx_to_svg/ln_to_svg.py b/skills/ppt-master/scripts/pptx_to_svg/ln_to_svg.pyindex c934c2ab..03eaf2ea 100644--- a/skills/ppt-master/scripts/pptx_to_svg/ln_to_svg.py+++ b/skills/ppt-master/scripts/pptx_to_svg/ln_to_svg.py@@ -243,9 +243,20 @@ def resolve_stroke(if id_seq is None:id_seq = [0]for which, attr in (("headEnd", "marker-start"), ("tailEnd", "marker-end")):- end_elem = ln.find(f"a:{which}", NS)- if end_elem is None:+ endpoints = ln.findall(f"a:{which}", NS)+ if len(endpoints) > 1:+ raise ValueError(+ f"DrawingML line must contain at most one {which}"+ )+ if not endpoints:continue+ end_elem = endpoints[0]+ if (+ set(end_elem.attrib) - {"type", "w", "len"}+ or list(end_elem)+ or (end_elem.text or "").strip()+ ):+ raise ValueError(f"Invalid DrawingML {which} structure")marker_color = attrs.get("stroke") or style_stroke_default or "#000000"marker_id, marker_def = _build_arrow_marker(end_elem,@@ -281,10 +292,16 @@ def _build_arrow_marker(reversed_: bool,) -> tuple[str | None, str]:"""Build an SVG <marker> def for an <a:headEnd>/<a:tailEnd>."""- typ = end_elem.attrib.get("type", "")- if typ in ("none", ""):- return None, ""- if typ not in {"triangle", "stealth", "arrow", "diamond", "oval"}:+ typ = end_elem.attrib.get("type")+ if typ not in {+ None,+ "none",+ "triangle",+ "stealth",+ "arrow",+ "diamond",+ "oval",+ }:raise ValueError(f"Unsupported DrawingML line-end type: {typ!r}")w_b = end_elem.attrib.get("w", "med")@@ -295,6 +312,8 @@ def _build_arrow_marker(f"Unsupported DrawingML line-end {dimension} bucket: "f"{bucket!r}")+ if typ is None or typ == "none":+ return None, ""mw = SIZE_BUCKET[l_b]mh = SIZE_BUCKET[w_b]diff --git a/skills/ppt-master/scripts/test_svg_quality_checker.py b/skills/ppt-master/scripts/test_svg_quality_checker.pyindex 6e748e47..2b95fb5e 100644--- a/skills/ppt-master/scripts/test_svg_quality_checker.py+++ b/skills/ppt-master/scripts/test_svg_quality_checker.py@@ -2634,6 +2634,47 @@ class SVGQualityCheckerCompatibilityTests(unittest.TestCase):):resolve_stroke(sp_pr, None)+ def test_native_line_end_structure_must_be_unique_and_empty(self):+ cases = (+ (+ '<a:tailEnd type="triangle"/>'+ '<a:tailEnd type="diamond"/>',+ 'DrawingML line must contain at most one tailEnd',+ ),+ (+ '<a:headEnd type="triangle" extra="1"/>',+ 'Invalid DrawingML headEnd structure',+ ),+ (+ '<a:tailEnd type="triangle"><a:extLst/></a:tailEnd>',+ 'Invalid DrawingML tailEnd structure',+ ),+ (+ '<a:tailEnd type=""/>',+ "Unsupported DrawingML line-end type: ''",+ ),+ (+ '<a:tailEnd w="xl"/>',+ "Unsupported DrawingML line-end width bucket: 'xl'",+ ),+ )+ for endpoint_markup, expected in cases:+ with self.subTest(endpoint_markup=endpoint_markup):+ 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:ln>{endpoint_markup}</a:ln>+</p:spPr>''')+ with self.assertRaisesRegex(ValueError, expected):+ resolve_stroke(sp_pr, None)++ omitted_type = ET.fromstring('''+<p:spPr xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main"+ xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">+ <a:ln><a:tailEnd/></a:ln>+</p:spPr>''')+ self.assertEqual(resolve_stroke(omitted_type, None).attrs, {})+def test_unknown_native_line_end_size_is_rejected_on_import(self):for attribute, dimension in (("w", "width"), ("len", "length")):with self.subTest(attribute=attribute):