Skip to content

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): preserve line-end size buckets

hugohe3f64427a25b85
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.py
index a0b740bc..2c1b4cec 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
@@ -173,10 +173,10 @@ def resolve_stroke(
# Arrow marker generation
# ---------------------------------------------------------------------------
-# Bucket -> markerWidth/markerHeight ratio (in stroke widths).
-# Tuned to roughly match PowerPoint's rendered arrowhead size; the spec is
-# under-defined but PowerPoint draws noticeably larger heads than 1.5–3.5×.
-SIZE_BUCKET = {"sm": 3.0, "med": 5.0, "lg": 7.0}
+# Bucket -> markerWidth/markerHeight ratio (in stroke widths). These values
+# are the stable representatives of the SVG-to-DrawingML bucket thresholds,
+# so importing and exporting preserves both ``w`` and ``len`` categories.
+SIZE_BUCKET = {"sm": 1.5, "med": 2.5, "lg": 3.5}
def _build_arrow_marker(
diff --git a/skills/ppt-master/scripts/test_svg_quality_checker.py b/skills/ppt-master/scripts/test_svg_quality_checker.py
index dd6b259b..866fe00c 100644
--- a/skills/ppt-master/scripts/test_svg_quality_checker.py
+++ b/skills/ppt-master/scripts/test_svg_quality_checker.py
@@ -46,6 +46,7 @@ from pptx_to_svg.effect_to_svg import (
)
from pptx_to_svg.preset_registry_to_svg import render_preset_geometry
from pptx_to_svg.preset_svg_markup import serialize_preset_layers
+from pptx_to_svg.ln_to_svg import _build_arrow_marker
from pptx_to_svg.converter import ConvertOptions, convert_pptx_to_svg
from pptx_to_svg.ooxml_loader import parse_ooxml_boolean
from pptx_to_svg.txbody_to_svg import convert_txbody, convert_vertical_txbody
@@ -62,6 +63,8 @@ from svg_to_pptx.drawingml.converter import (
SvgNativeConversionError,
convert_svg_to_slide_shapes,
)
+from svg_to_pptx.drawingml.context import ConvertContext
+from svg_to_pptx.drawingml.styles import build_stroke_xml
from svg_to_pptx.pptx_package.builder import create_pptx_with_native_svg
from svg_to_pptx.pptx_package.dimensions import (
CANVAS_FORMATS as PACKAGE_CANVAS_FORMATS,
@@ -2492,6 +2495,47 @@ class SVGQualityCheckerCompatibilityTests(unittest.TestCase):
'invalid project gradient',
)
+ def test_imported_line_end_size_buckets_round_trip(self):
+ drawingml_ns = (
+ 'http://schemas.openxmlformats.org/drawingml/2006/main'
+ )
+ for width_bucket in ('sm', 'med', 'lg'):
+ for length_bucket in ('sm', 'med', 'lg'):
+ with self.subTest(
+ width=width_bucket,
+ length=length_bucket,
+ ):
+ end = ET.Element(
+ f'{{{drawingml_ns}}}tailEnd',
+ {
+ 'type': 'triangle',
+ 'w': width_bucket,
+ 'len': length_bucket,
+ },
+ )
+ marker_id, marker_markup = _build_arrow_marker(
+ end,
+ '#112233',
+ id_prefix='roundtrip-',
+ seq=[0],
+ reversed_=False,
+ )
+ marker = ET.fromstring(marker_markup)
+ line = ET.fromstring(
+ '<line xmlns="http://www.w3.org/2000/svg" '
+ 'stroke="#112233" '
+ f'marker-end="url(#{marker_id})"/>'
+ )
+ stroke_xml = build_stroke_xml(
+ line,
+ ConvertContext(defs={marker_id: marker}),
+ )
+ self.assertIn(
+ '<a:tailEnd type="triangle" '
+ f'w="{width_bucket}" len="{length_bucket}"/>',
+ stroke_xml,
+ )
+
def test_invalid_filter_contract_blocks_checker_and_exporter(self):
self._assert_checker_and_exporter_reject(
'''<svg xmlns="http://www.w3.org/2000/svg"