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 the line-dash choice
hugohe3deef51f11566
diff --git a/skills/ppt-master/references/shared-standards.md b/skills/ppt-master/references/shared-standards.mdindex 029bdaf7..9cb94663 100644--- a/skills/ppt-master/references/shared-standards.md+++ b/skills/ppt-master/references/shared-standards.md@@ -1013,7 +1013,10 @@ join. Round and bevel are empty; miter requires the project's fixedlimit, and other miter limits stop import rather than losing corner geometry.PPTX import maps only the registered DrawingML `prstDash` values; `solid`remains an intentional line with no SVG dash array, while an unknown source-value stops import instead of being mistaken for `solid`.+value stops import instead of being mistaken for `solid`. A line contains at+most one direct `a:prstDash` or `a:custDash`; preset dash has exactly one `val`+attribute and no payload. Duplicate, mixed, or payload-bearing dash definitions+stop import instead of being resolved by document order.An imported `a:custDash` contains one or more direct, empty `a:ds` children;each stop has exactly `d` and `sp`, both positive OOXML integers. Missing orextra fields, foreign children, malformed numbers, and values outside thediff --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 26cc58d1..c934c2ab 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@@ -153,9 +153,20 @@ def resolve_stroke(attrs["stroke-opacity"] = fmt_num(alpha, 4)# Dash pattern- prst_dash = ln.find("a:prstDash", NS)- if prst_dash is not None:- preset = prst_dash.attrib.get("val", "")+ preset_tag = f"{{{NS['a']}}}prstDash"+ custom_tag = f"{{{NS['a']}}}custDash"+ dashes = [child for child in ln if child.tag in {preset_tag, custom_tag}]+ if len(dashes) > 1:+ raise ValueError("DrawingML line must contain at most one dash")+ dash = dashes[0] if dashes else None+ if dash is not None and dash.tag == preset_tag:+ if (+ set(dash.attrib) != {"val"}+ or list(dash)+ or (dash.text or "").strip()+ ):+ raise ValueError("Invalid DrawingML preset dash structure")+ preset = dash.attrib["val"]if preset not in PRST_DASH_TO_ARRAY:raise ValueError(f"Unsupported DrawingML preset dash: {preset!r}"@@ -163,43 +174,44 @@ def resolve_stroke(dasharray = PRST_DASH_TO_ARRAY[preset]if dasharray:attrs["stroke-dasharray"] = dasharray- else:- cust_dash = ln.find("a:custDash", NS)- if cust_dash is not None:- ds_parts: list[str] = []- sw = float(attrs.get("stroke-width", "1") or "1") or 1.0- dash_stops = list(cust_dash)- expected_tag = f"{{{NS['a']}}}ds"- if not dash_stops or any(- ds.tag != expected_tag- or set(ds.attrib) != {"d", "sp"}- or list(ds)- for ds in dash_stops- ):- raise ValueError("Invalid DrawingML custom dash structure")- for ds in dash_stops:- # d, sp are percentages of stroke width (1000ths)- values: dict[str, int] = {}- for name in ("d", "sp"):- raw_value = ds.attrib[name]- try:- value = int(raw_value)- except (ValueError, TypeError):- raise ValueError(- f"Invalid DrawingML custom dash {name}: "- f"{raw_value!r}"- ) from None- if not 0 < value <= _OOXML_INT_MAX:- raise ValueError(- f"DrawingML custom dash {name}={value} is "- "outside the positive OOXML integer range"- )- values[name] = value- d_pct = values["d"]- sp_pct = values["sp"]- ds_parts.append(fmt_num(d_pct / 100000.0 * sw, 10))- ds_parts.append(fmt_num(sp_pct / 100000.0 * sw, 10))- attrs["stroke-dasharray"] = " ".join(ds_parts)+ elif dash is not None:+ cust_dash = dash+ if cust_dash.attrib or (cust_dash.text or "").strip():+ raise ValueError("Invalid DrawingML custom dash structure")+ ds_parts: list[str] = []+ sw = float(attrs.get("stroke-width", "1") or "1") or 1.0+ dash_stops = list(cust_dash)+ expected_tag = f"{{{NS['a']}}}ds"+ if not dash_stops or any(+ ds.tag != expected_tag+ or set(ds.attrib) != {"d", "sp"}+ or list(ds)+ for ds in dash_stops+ ):+ raise ValueError("Invalid DrawingML custom dash structure")+ for ds in dash_stops:+ # d, sp are percentages of stroke width (1000ths)+ values: dict[str, int] = {}+ for name in ("d", "sp"):+ raw_value = ds.attrib[name]+ try:+ value = int(raw_value)+ except (ValueError, TypeError):+ raise ValueError(+ f"Invalid DrawingML custom dash {name}: "+ f"{raw_value!r}"+ ) from None+ if not 0 < value <= _OOXML_INT_MAX:+ raise ValueError(+ f"DrawingML custom dash {name}={value} is "+ "outside the positive OOXML integer range"+ )+ values[name] = value+ d_pct = values["d"]+ sp_pct = values["sp"]+ ds_parts.append(fmt_num(d_pct / 100000.0 * sw, 10))+ ds_parts.append(fmt_num(sp_pct / 100000.0 * sw, 10))+ attrs["stroke-dasharray"] = " ".join(ds_parts)# Joinjoin_names = {diff --git a/skills/ppt-master/scripts/test_svg_quality_checker.py b/skills/ppt-master/scripts/test_svg_quality_checker.pyindex 533cf8cd..6e748e47 100644--- a/skills/ppt-master/scripts/test_svg_quality_checker.py+++ b/skills/ppt-master/scripts/test_svg_quality_checker.py@@ -2836,6 +2836,37 @@ class SVGQualityCheckerCompatibilityTests(unittest.TestCase):):resolve_stroke(sp_pr, None)+ def test_native_line_dash_choice_must_be_unique_and_exact(self):+ cases = (+ (+ '<a:prstDash val="dash"/><a:custDash>'+ '<a:ds d="100000" sp="100000"/></a:custDash>',+ 'DrawingML line must contain at most one dash',+ ),+ (+ '<a:prstDash val="dash"/><a:prstDash val="dot"/>',+ 'DrawingML line must contain at most one dash',+ ),+ (+ '<a:prstDash val="dash" extra="1"/>',+ 'Invalid DrawingML preset dash structure',+ ),+ (+ '<a:custDash extra="1">'+ '<a:ds d="100000" sp="100000"/></a:custDash>',+ 'Invalid DrawingML custom dash structure',+ ),+ )+ for dash_markup, expected in cases:+ with self.subTest(dash_markup=dash_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>{dash_markup}</a:ln>+</p:spPr>''')+ with self.assertRaisesRegex(ValueError, expected):+ resolve_stroke(sp_pr, None)+def test_invalid_native_custom_dash_is_rejected_on_import(self):cases = (('', 'Invalid DrawingML custom dash structure'),