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
feat(svg_to_pptx): map SVG marker-start/marker-end to native DrawingML arrow heads
hugohe3251b0bab39a6
diff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml_styles.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml_styles.pyindex 1d9f3f66..85bd5b16 100644--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml_styles.py+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml_styles.py@@ -132,6 +132,125 @@ def build_fill_xml(return '<a:noFill/>'+# ---------------------------------------------------------------------------+# Marker (arrow-head) support+# ---------------------------------------------------------------------------++# Matches an (x, y) pair in a path "d" attribute: "M 10, 20" / "L -5 7.5" / etc.+_MARKER_POINT_RE = re.compile(+ r'[MLml]\s*(-?\d+(?:\.\d+)?)\s*[,\s]\s*(-?\d+(?:\.\d+)?)'+)+_MARKER_POLY_POINT_RE = re.compile(+ r'(-?\d+(?:\.\d+)?)\s*[,\s]\s*(-?\d+(?:\.\d+)?)'+)+++def _marker_size_buckets(w_attr: float, h_attr: float) -> tuple[str, str]:+ """Map SVG markerWidth / markerHeight to DrawingML (w, len) buckets.++ DrawingML arrow-end sizing is categorical: sm / med / lg.+ Width (perpendicular to the line) maps from markerHeight;+ length (along the line) maps from markerWidth.+ """++ def bucket(v: float) -> str:+ if v < 6:+ return 'sm'+ if v > 12:+ return 'lg'+ return 'med'++ return bucket(h_attr), bucket(w_attr)+++def _classify_marker(marker_elem: ET.Element) -> tuple[str, str, str] | None:+ """Classify an SVG <marker> into a DrawingML line-end preset.++ Returns (type, w, len) where:+ type in {'triangle', 'stealth', 'diamond', 'oval', 'arrow'}+ w, len in {'sm', 'med', 'lg'}+ or None if the marker cannot be classified.++ Current coverage (80/20): triangles (3-vertex closed paths or polygons),+ diamonds (4-vertex symmetric), and circles / ellipses. Anything else+ returns None so the caller can warn and skip.+ """+ mw = _f(marker_elem.get('markerWidth'), 3.0)+ mh = _f(marker_elem.get('markerHeight'), 3.0)+ w_bucket, len_bucket = _marker_size_buckets(mw, mh)++ for child in marker_elem:+ tag = child.tag.replace(f'{{{SVG_NS}}}', '')++ if tag in ('circle', 'ellipse'):+ return ('oval', w_bucket, len_bucket)++ if tag == 'path':+ d = child.get('d', '')+ if not d:+ continue+ points = _MARKER_POINT_RE.findall(d)+ n = len(points)+ closed = bool(re.search(r'[Zz]\s*$', d.strip()))+ if n == 3 and closed:+ return ('triangle', w_bucket, len_bucket)+ if n == 4 and closed:+ return ('diamond', w_bucket, len_bucket)+ continue++ if tag in ('polygon', 'polyline'):+ pts_attr = child.get('points', '')+ pts = _MARKER_POLY_POINT_RE.findall(pts_attr)+ n = len(pts)+ if n == 3:+ return ('triangle', w_bucket, len_bucket)+ if n == 4:+ return ('diamond', w_bucket, len_bucket)+ continue++ return None+++def _emit_line_end(+ elem: ET.Element,+ ctx: ConvertContext,+ which: str,+) -> str:+ """Build <a:headEnd> or <a:tailEnd> XML for an element's marker reference.++ Args:+ which: 'head' (SVG marker-start) or 'tail' (SVG marker-end).++ Returns empty string if no marker, cannot resolve, or cannot classify.+ """+ attr = 'marker-start' if which == 'head' else 'marker-end'+ ref = _get_attr(elem, attr, ctx)+ if not ref or ref == 'none':+ return ''++ marker_id = resolve_url_id(ref)+ if not marker_id or marker_id not in ctx.defs:+ return ''++ marker_elem = ctx.defs[marker_id]+ tag = marker_elem.tag.replace(f'{{{SVG_NS}}}', '')+ if tag != 'marker':+ # ID collision with non-marker defs entry; ignore.+ return ''++ cls = _classify_marker(marker_elem)+ if cls is None:+ print(+ f' Warning: marker "{marker_id}" shape cannot be classified; '+ f'skipping (supported: triangle, diamond, oval)'+ )+ return ''++ typ, w_bucket, len_bucket = cls+ dml_tag = 'headEnd' if which == 'head' else 'tailEnd'+ return f'<a:{dml_tag} type="{typ}" w="{w_bucket}" len="{len_bucket}"/>'++def build_stroke_xml(elem: ET.Element,ctx: ConvertContext,@@ -182,11 +301,18 @@ def build_stroke_xml(elif linejoin == 'miter':join_xml = '<a:miter lim="800000"/>'+ # Line-end markers (SVG marker-start / marker-end → <a:headEnd>/<a:tailEnd>)+ # DrawingML schema order is: fill → prstDash → join → headEnd → tailEnd,+ # so these must be appended after join_xml.+ head_end = _emit_line_end(elem, ctx, 'head')+ tail_end = _emit_line_end(elem, ctx, 'tail')+ line_ends = head_end + tail_end+# Gradient strokegrad_id = resolve_url_id(stroke)if grad_id and grad_id in ctx.defs:grad_fill = build_gradient_fill(ctx.defs[grad_id], opacity)- return f'<a:ln w="{width_emu}"{cap_attr}>{grad_fill}{dash_xml}{join_xml}</a:ln>'+ return f'<a:ln w="{width_emu}"{cap_attr}>{grad_fill}{dash_xml}{join_xml}{line_ends}</a:ln>'# Solid color strokecolor = parse_hex_color(stroke)@@ -198,7 +324,7 @@ def build_stroke_xml(alpha_xml = f'<a:alpha val="{int(opacity * 100000)}"/>'return f'''<a:ln w="{width_emu}"{cap_attr}>-<a:solidFill><a:srgbClr val="{color}">{alpha_xml}</a:srgbClr></a:solidFill>{dash_xml}{join_xml}+<a:solidFill><a:srgbClr val="{color}">{alpha_xml}</a:srgbClr></a:solidFill>{dash_xml}{join_xml}{line_ends}</a:ln>'''diff --git a/skills/ppt-master/templates/charts/dumbbell_chart.svg b/skills/ppt-master/templates/charts/dumbbell_chart.svgindex a31c3441..efc3ff51 100644--- a/skills/ppt-master/templates/charts/dumbbell_chart.svg+++ b/skills/ppt-master/templates/charts/dumbbell_chart.svg@@ -78,7 +78,7 @@<!-- Data rows: x = 200 + (value/100) * 900 --><!-- Row 1: US - Overall:78 Innovation:68 Diffusion:75 Adaptation:80 -->- <g class="data-row" transform="translate(0, 30)">+ <g transform="translate(0, 30)"><text x="190" y="5" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif"font-size="14" fill="#333333" text-anchor="end"><tspan>US</tspan></text><line x1="812" y1="0" x2="920" y2="0" stroke="#CCCCCC" stroke-width="1.5"/>@@ -89,7 +89,7 @@</g><!-- Row 2: Singapore - Overall:72 Innovation:55 Diffusion:68 Adaptation:75 -->- <g class="data-row" transform="translate(0, 78)">+ <g transform="translate(0, 78)"><text x="190" y="5" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif"font-size="14" fill="#333333" text-anchor="end"><tspan>Singapore</tspan></text><line x1="695" y1="0" x2="875" y2="0" stroke="#CCCCCC" stroke-width="1.5"/>@@ -100,7 +100,7 @@</g><!-- Row 3: UK - Overall:70 Innovation:52 Diffusion:65 Adaptation:78 -->- <g class="data-row" transform="translate(0, 126)">+ <g transform="translate(0, 126)"><text x="190" y="5" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif"font-size="14" fill="#333333" text-anchor="end"><tspan>UK</tspan></text><line x1="668" y1="0" x2="902" y2="0" stroke="#CCCCCC" stroke-width="1.5"/>@@ -111,7 +111,7 @@</g><!-- Row 4: Switzerland - Overall:68 Innovation:50 Diffusion:62 Adaptation:76 -->- <g class="data-row" transform="translate(0, 174)">+ <g transform="translate(0, 174)"><text x="190" y="5" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif"font-size="14" fill="#333333" text-anchor="end"><tspan>Switzerland</tspan></text><line x1="650" y1="0" x2="884" y2="0" stroke="#CCCCCC" stroke-width="1.5"/>@@ -122,7 +122,7 @@</g><!-- Row 5: Sweden - Overall:65 Innovation:45 Diffusion:58 Adaptation:78 -->- <g class="data-row" transform="translate(0, 222)">+ <g transform="translate(0, 222)"><text x="190" y="5" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif"font-size="14" fill="#333333" text-anchor="end"><tspan>Sweden</tspan></text><line x1="605" y1="0" x2="902" y2="0" stroke="#CCCCCC" stroke-width="1.5"/>@@ -133,7 +133,7 @@</g><!-- Row 6: South Korea - Overall:62 Innovation:48 Diffusion:55 Adaptation:65 -->- <g class="data-row" transform="translate(0, 270)">+ <g transform="translate(0, 270)"><text x="190" y="5" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif"font-size="14" fill="#333333" text-anchor="end"><tspan>South Korea</tspan></text><line x1="632" y1="0" x2="785" y2="0" stroke="#CCCCCC" stroke-width="1.5"/>@@ -144,7 +144,7 @@</g><!-- Row 7: Germany - Overall:58 Innovation:42 Diffusion:52 Adaptation:68 -->- <g class="data-row" transform="translate(0, 318)">+ <g transform="translate(0, 318)"><text x="190" y="5" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif"font-size="14" fill="#333333" text-anchor="end"><tspan>Germany</tspan></text><line x1="578" y1="0" x2="812" y2="0" stroke="#CCCCCC" stroke-width="1.5"/>@@ -155,7 +155,7 @@</g><!-- Row 8: China - Overall:52 Innovation:38 Diffusion:45 Adaptation:55 -->- <g class="data-row" transform="translate(0, 366)">+ <g transform="translate(0, 366)"><text x="190" y="5" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif"font-size="14" fill="#333333" text-anchor="end"><tspan>China</tspan></text><line x1="542" y1="0" x2="695" y2="0" stroke="#CCCCCC" stroke-width="1.5"/>@@ -166,7 +166,7 @@</g><!-- Row 9: Brazil - Overall:35 Innovation:18 Diffusion:28 Adaptation:38 -->- <g class="data-row" transform="translate(0, 414)">+ <g transform="translate(0, 414)"><text x="190" y="5" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif"font-size="14" fill="#333333" text-anchor="end"><tspan>Brazil</tspan></text><line x1="362" y1="0" x2="542" y2="0" stroke="#CCCCCC" stroke-width="1.5"/>@@ -177,7 +177,7 @@</g><!-- Row 10: Argentina - Overall:28 Innovation:12 Diffusion:22 Adaptation:32 -->- <g class="data-row" transform="translate(0, 462)">+ <g transform="translate(0, 462)"><text x="190" y="5" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif"font-size="14" fill="#333333" text-anchor="end"><tspan>Argentina</tspan></text><line x1="308" y1="0" x2="488" y2="0" stroke="#CCCCCC" stroke-width="1.5"/>diff --git a/skills/ppt-master/templates/charts/porter_five_forces.svg b/skills/ppt-master/templates/charts/porter_five_forces.svgindex 5a858c71..ca6b8797 100644--- a/skills/ppt-master/templates/charts/porter_five_forces.svg+++ b/skills/ppt-master/templates/charts/porter_five_forces.svg@@ -88,14 +88,14 @@font-size="16" font-weight="bold" fill="#FFFFFF" text-anchor="middle"><tspan>Threat of New Entrants</tspan></text>- <rect x="-120" y="-5" width="180" height="10" rx="5" fill="rgba(255,255,255,0.3)"/>+ <rect x="-120" y="-5" width="180" height="10" rx="5" fill="#FFFFFF" fill-opacity="0.3"/><rect x="-120" y="-5" width="90" height="10" rx="5" fill="#FFFFFF"/><text x="70" y="3" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"font-size="12" font-weight="bold" fill="#FFFFFF"><tspan>Medium</tspan></text><text x="0" y="22" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif"- font-size="11" fill="rgba(255,255,255,0.9)" text-anchor="middle">+ font-size="11" fill="#FFFFFF" fill-opacity="0.9" text-anchor="middle"><tspan>Capital barriers, Tech accumulation needed</tspan></text></g>@@ -108,14 +108,14 @@font-size="16" font-weight="bold" fill="#FFFFFF" text-anchor="middle"><tspan>Bargaining Power of Buyers</tspan></text>- <rect x="-120" y="-5" width="180" height="10" rx="5" fill="rgba(255,255,255,0.3)"/>+ <rect x="-120" y="-5" width="180" height="10" rx="5" fill="#FFFFFF" fill-opacity="0.3"/><rect x="-120" y="-5" width="135" height="10" rx="5" fill="#FFFFFF"/><text x="70" y="3" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"font-size="12" font-weight="bold" fill="#FFFFFF"><tspan>High</tspan></text><text x="0" y="22" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif"- font-size="11" fill="rgba(255,255,255,0.9)" text-anchor="middle">+ font-size="11" fill="#FFFFFF" fill-opacity="0.9" text-anchor="middle"><tspan>Many choices, Low switching costs</tspan></text></g>@@ -128,14 +128,14 @@font-size="16" font-weight="bold" fill="#FFFFFF" text-anchor="middle"><tspan>Threat of Substitutes</tspan></text>- <rect x="-120" y="-5" width="180" height="10" rx="5" fill="rgba(255,255,255,0.3)"/>+ <rect x="-120" y="-5" width="180" height="10" rx="5" fill="#FFFFFF" fill-opacity="0.3"/><rect x="-120" y="-5" width="54" height="10" rx="5" fill="#FFFFFF"/><text x="70" y="3" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"font-size="12" font-weight="bold" fill="#FFFFFF"><tspan>Low</tspan></text><text x="0" y="22" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif"- font-size="11" fill="rgba(255,255,255,0.9)" text-anchor="middle">+ font-size="11" fill="#FFFFFF" fill-opacity="0.9" text-anchor="middle"><tspan>Few effective alternatives</tspan></text></g>@@ -148,14 +148,14 @@font-size="16" font-weight="bold" fill="#FFFFFF" text-anchor="middle"><tspan>Bargaining Power of Suppliers</tspan></text>- <rect x="-120" y="-5" width="180" height="10" rx="5" fill="rgba(255,255,255,0.3)"/>+ <rect x="-120" y="-5" width="180" height="10" rx="5" fill="#FFFFFF" fill-opacity="0.3"/><rect x="-120" y="-5" width="108" height="10" rx="5" fill="#FFFFFF"/><text x="70" y="3" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"font-size="12" font-weight="bold" fill="#FFFFFF"><tspan>Medium-High</tspan></text><text x="0" y="22" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif"- font-size="11" fill="rgba(255,255,255,0.9)" text-anchor="middle">+ font-size="11" fill="#FFFFFF" fill-opacity="0.9" text-anchor="middle"><tspan>Cloud vendors concentrated</tspan></text></g>@@ -168,14 +168,14 @@font-size="16" font-weight="bold" fill="#FFFFFF" text-anchor="middle"><tspan>Competitive Rivalry</tspan></text>- <rect x="-120" y="-5" width="180" height="10" rx="5" fill="rgba(255,255,255,0.3)"/>+ <rect x="-120" y="-5" width="180" height="10" rx="5" fill="#FFFFFF" fill-opacity="0.3"/><rect x="-120" y="-5" width="162" height="10" rx="5" fill="#FFFFFF"/><text x="70" y="3" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif"font-size="12" font-weight="bold" fill="#FFFFFF"><tspan>Very High</tspan></text><text x="0" y="22" font-family="-apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif"- font-size="11" fill="rgba(255,255,255,0.9)" text-anchor="middle">+ font-size="11" fill="#FFFFFF" fill-opacity="0.9" text-anchor="middle"><tspan>Many competitors, Price wars common</tspan></text></g>