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(svg_to_pptx): flatten positional <tspan> for native pptx
hugohe3055d8dbddf4c
diff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml_converter.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml_converter.pyindex f0c65c5b..8e43a466 100644--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml_converter.py+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml_converter.py@@ -272,6 +272,16 @@ def convert_svg_to_slide_shapes(if verbose and expanded:print(f' Expanded {expanded} <use data-icon="..."/> placeholder(s)')+ # Flatten positional <tspan> (those with x/y/non-zero dy) into independent+ # <text> elements. DrawingML runs cannot reposition mid-paragraph, so a+ # dy-stacked block of tspans would otherwise collapse onto one baseline,+ # and an x-anchored tspan would render in the wrong column. finalize_svg+ # does the same flattening on disk; doing it here keeps native pptx output+ # correct when reading raw svg_output/.+ from .tspan_flattener import flatten_positional_tspans+ if flatten_positional_tspans(tree) and verbose:+ print(' Flattened positional <tspan> into independent <text>')+defs = collect_defs(root)ctx = ConvertContext(defs=defs, slide_num=slide_num, svg_dir=Path(svg_path).parent)diff --git a/skills/ppt-master/scripts/svg_to_pptx/tspan_flattener.py b/skills/ppt-master/scripts/svg_to_pptx/tspan_flattener.pynew file mode 100644index 00000000..88de495b--- /dev/null+++ b/skills/ppt-master/scripts/svg_to_pptx/tspan_flattener.py@@ -0,0 +1,43 @@+"""In-memory flattening of positional ``<tspan>`` elements.++DrawingML's text-run model has no way to express "jump to a new x/y inside+the same paragraph". Every ``<tspan>`` carrying ``x``, ``y`` or non-zero+``dy`` is therefore a layout instruction this converter cannot honour+inline — without flattening, a 4-line dy-stacked block collapses onto a+single baseline and an x-anchored tspan jumps to the wrong column.++The on-disk ``finalize_svg`` pipeline solves this by promoting each+positional tspan to an independent ``<text>`` element. This module+performs the same transformation in memory so ``svg_to_pptx`` can consume+``svg_output/`` directly without that disk step.++Public API:+ flatten_positional_tspans(tree) -> bool+ Walk the SVG element tree, replace every positional ``<tspan>``+ with an independent ``<text>``, and return whether anything+ changed.++Heavy lifting is delegated to ``svg_finalize.flatten_tspan`` so the two+pipelines stay behaviourally aligned.+"""++from __future__ import annotations++import sys+from pathlib import Path+from xml.etree import ElementTree as ET+++def flatten_positional_tspans(tree: ET.ElementTree) -> bool:+ """Flatten positional ``<tspan>`` elements into independent ``<text>``.++ Delegates to ``svg_finalize.flatten_tspan.flatten_text_with_tspans`` so+ the in-memory transform exactly matches the on-disk one.++ Returns True if any tspan was rewritten.+ """+ scripts_dir = Path(__file__).resolve().parent.parent+ if str(scripts_dir) not in sys.path:+ sys.path.insert(0, str(scripts_dir))+ from svg_finalize.flatten_tspan import flatten_text_with_tspans # type: ignore+ return flatten_text_with_tspans(tree)