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): add explicit multiline text flow modes
hugohe3f687b0314b7b
diff --git a/skills/ppt-master/scripts/svg_finalize/flatten_tspan.py b/skills/ppt-master/scripts/svg_finalize/flatten_tspan.pyindex 3cb9fcf3..b5e5d917 100644--- a/skills/ppt-master/scripts/svg_finalize/flatten_tspan.py+++ b/skills/ppt-master/scripts/svg_finalize/flatten_tspan.py@@ -125,27 +125,20 @@ def compute_line_positions(Returns (new_x, new_y)."""del text_el- # Prefer explicit x/y on tspant_x_attr = get_attr(tspan_el, "x")t_y_attr = get_attr(tspan_el, "y")t_dx_attr = get_attr(tspan_el, "dx")t_dy_attr = get_attr(tspan_el, "dy")- if t_x_attr is not None:- nx = parse_first_number(t_x_attr)- elif t_dx_attr is not None:+ nx = parse_first_number(t_x_attr) if t_x_attr is not None else cur_x+ if t_dx_attr is not None:dx = parse_first_number(t_dx_attr) or 0.0- nx = (cur_x or 0.0) + dx- else:- nx = cur_x+ nx = (nx or 0.0) + dx- if t_y_attr is not None:- ny = parse_first_number(t_y_attr)- elif t_dy_attr is not None:+ ny = parse_first_number(t_y_attr) if t_y_attr is not None else cur_y+ if t_dy_attr is not None:dy = parse_first_number(t_dy_attr) or 0.0- ny = (cur_y or 0.0) + dy- else:- ny = cur_y+ ny = (ny or 0.0) + dyreturn nx, ny@@ -193,6 +186,9 @@ PARAGRAPH_SPACE_BEFORE_ATTR = "data-paragraph-space-before"# (SVG used dy to simulate text wrapping; the downstream converter should# merge its runs into the previous <a:p> rather than start a new one).PARAGRAPH_SOFT_BREAK_ATTR = "data-paragraph-soft-break"+# Marks an authored visual line boundary that remains a hard DrawingML break+# in the default single-frame preserve mode.+PARAGRAPH_LINE_BREAK_ATTR = "data-paragraph-line-break"# Tolerance for detecting "base line-height" vs "paragraph gap": dy values# within ±DY_TOLERANCE_PX of each other are considered the same line-height.@@ -211,17 +207,41 @@ def _starts_with_list_marker(line_group: list[ET.Element]) -> bool:return bool(LIST_MARKER_RE.match(text))-def _tspan_has_positional_descendant(tspan: ET.Element) -> bool:- """Return True if any nested tspan inside this one carries x/y/dy."""- for child in list(tspan):- if child.tag != f"{{{SVG_NS}}}tspan":- continue- for k in ("x", "y", "dy"):- if child.get(k) is not None:- return True- if _tspan_has_positional_descendant(child):- return True- return False+def _positional_tspan_attribute(tspan: ET.Element) -> str | None:+ """Return the unsupported nested position attribute, if any."""+ for name in ("x", "y"):+ if tspan.get(name) is not None:+ return name+ raw_dy = tspan.get("dy")+ dy = parse_first_number(raw_dy) if raw_dy is not None else None+ if dy is not None and abs(dy) > 1e-6:+ return "dy"+ return None+++def nested_positional_tspan_errors(root: ET.Element) -> list[str]:+ """Describe nested tspans whose baseline jumps cannot be exported."""+ errors: list[str] = []+ for text_el in root.iter(f"{{{SVG_NS}}}text"):+ text_label = (+ f"<text id={text_el.get('id')!r}>"+ if text_el.get("id")+ else "<text>"+ )+ for direct_child in list(text_el):+ if direct_child.tag != f"{{{SVG_NS}}}tspan":+ continue+ for descendant in direct_child.iter(f"{{{SVG_NS}}}tspan"):+ if descendant is direct_child:+ continue+ attribute = _positional_tspan_attribute(descendant)+ if attribute is None:+ continue+ errors.append(+ f"{text_label} contains a nested <tspan> with {attribute}; "+ "move x/y/non-zero dy to a direct child of <text>"+ )+ return errorsdef _build_paragraph_child_view(@@ -281,19 +301,20 @@ def _classify_paragraph_block(text_el: ET.Element,is_svg_tag,is_new_line_tspan,-) -> tuple[float, list[float], list[bool], list[list[ET.Element]], ET.Element | None] | None:+ preserve_line_breaks: bool,+) -> tuple[float, list[float], list[str], list[list[ET.Element]], ET.Element | None] | None:"""Detect a mergeable paragraph block.Returns ``(base_line_height_px, extra_space_before_px_per_line,- is_soft_break_per_line, line_groups, synthetic_first_line)`` if the children+ break_kind_per_line, line_groups, synthetic_first_line)`` if the childrenform a mergeable paragraph. Each list has one entry per direct-child tspan(line), including a synthetic first line when the source used leading text:- extra_space_before_px_per_line[i]: extra px above base line-height,used as <a:spcBef> on the downstream <a:p>. First entry is 0.- - is_soft_break_per_line[i]: True if this line should merge into the- previous <a:p> (SVG dy was simulating word-wrap); False if it starts- a fresh <a:p>. First entry is always False (paragraph head).+ - break_kind_per_line[i]: ``paragraph`` starts a fresh <a:p>, ``soft``+ joins the previous line for reflow, and ``line`` preserves the visual+ boundary as a hard DrawingML break. First entry is ``paragraph``.Conditions (all must hold):- No direct text under <text>, except simple leading text that can be@@ -308,7 +329,8 @@ def _classify_paragraph_block(any larger dy must be ≤ MAX_DY_MULTIPLIER × base. Anything largeris treated as a section break and rejected.- Every line-break tspan that sets x repeats the parent <text>'s x.- - No nested tspan inside any line carries x/y/dy.+ - A line-break tspan cannot add a non-zero dx offset.+ - No nested tspan inside any line carries x/y/non-zero dy.- Adjacent lines with different effective font sizes start new paragraphs."""base_x = parse_first_number(get_attr(text_el, "x"))@@ -327,8 +349,6 @@ def _classify_paragraph_block(else:if not line_groups:return None- if _tspan_has_positional_descendant(tspan):- return Noneline_groups[-1].append(tspan)if len(line_groups) < 2:@@ -348,6 +368,10 @@ def _classify_paragraph_block(t_x = parse_first_number(t_x_raw)if base_x is None or t_x is None or abs(t_x - base_x) > 1e-6:return None+ t_dx_raw = get_attr(tspan, "dx")+ t_dx = parse_first_number(t_dx_raw) if t_dx_raw is not None else None+ if t_dx is not None and abs(t_dx) > 1e-6:+ return Nonet_dy_raw = get_attr(tspan, "dy")t_dy = parse_first_number(t_dy_raw) if t_dy_raw is not None else None@@ -361,9 +385,6 @@ def _classify_paragraph_block(return Nonedy_values.append(t_dy)- if _tspan_has_positional_descendant(tspan):- return None-# Second pass: pick the base line-height as the minimum positive dy and# express each line's dy as base + extra space-before.positive_dys = [d for d in dy_values[1:] if d > 0]@@ -375,7 +396,7 @@ def _classify_paragraph_block(return Noneextras: list[float] = [0.0] # first line never has space-before- soft_breaks: list[bool] = [False] # first line starts a paragraph+ break_kinds = ["paragraph"]line_font_sizes = [_effective_line_font_size_px(text_el, group)for group in line_groups@@ -392,7 +413,7 @@ def _classify_paragraph_block(# dy strictly greater than base = hard paragraph break. List markers# and font-size changes also start a fresh paragraph so semantically# distinct visual lines do not merge into one PowerPoint line.- is_soft = (+ reflow_candidate = (abs(extra) <= DY_TOLERANCE_PXand not _starts_with_list_marker(line_groups[idx])and abs(line_font_sizes[idx] - line_font_sizes[idx - 1]) <= 1e-6@@ -401,30 +422,36 @@ def _classify_paragraph_block(PARAGRAPH_SOFT_BREAK_ATTR)if explicit_soft_break == "0":- is_soft = False+ break_kind = "paragraph"elif explicit_soft_break == "1":- is_soft = True- extras.append(0.0 if is_soft else extra)- soft_breaks.append(is_soft)+ break_kind = "soft"+ elif reflow_candidate:+ break_kind = "line" if preserve_line_breaks else "soft"+ else:+ break_kind = "paragraph"+ extras.append(0.0 if break_kind != "paragraph" else extra)+ break_kinds.append(break_kind)- return base, extras, soft_breaks, line_groups, synthetic_first+ return base, extras, break_kinds, line_groups, synthetic_firstdef _emit_mergeable_paragraph(text_el: ET.Element,base_dy: float,extras: list[float],- soft_breaks: list[bool],+ break_kinds: list[str],line_groups: list[list[ET.Element]],synthetic_first: ET.Element | None = None,) -> None:"""Rewrite text_el in place so it stays a single <text> with paragraph rows.The base line-height goes on the parent <text> via PARAGRAPH_MARK_ATTR.- Each direct-child tspan is normalized: x/y/dy stripped; inline-run+ Each direct-child tspan is normalized: x/y/dx/dy stripped; inline-runstyling and nested tspans are preserved. Per-tspan attrs:- PARAGRAPH_SOFT_BREAK_ATTR="1" on tspans that should be appended tothe previous <a:p> downstream (SVG used dy to simulate wrap)+ - PARAGRAPH_LINE_BREAK_ATTR="1" on tspans that retain an authored line+ boundary inside the previous <a:p>- PARAGRAPH_SPACE_BEFORE_ATTR on tspans that open a new paragraphwith an extra gap (omitted when 0)"""@@ -448,7 +475,7 @@ def _emit_mergeable_paragraph(continuecontainer = ET.Element(f"{{{SVG_NS}}}tspan")- for k in ("x", "y", "dy"):+ for k in ("x", "y", "dx", "dy"):line.attrib.pop(k, None)for run in group:container.append(run)@@ -460,19 +487,27 @@ def _emit_mergeable_paragraph(text_el.append(line)extras_iter = iter(extras)- soft_iter = iter(soft_breaks)+ break_iter = iter(break_kinds)for tspan in normalized_lines:- for k in ("x", "y", "dy"):+ for k in ("x", "y", "dx", "dy"):if k in tspan.attrib:del tspan.attrib[k]+ for k in (+ PARAGRAPH_SOFT_BREAK_ATTR,+ PARAGRAPH_LINE_BREAK_ATTR,+ PARAGRAPH_SPACE_BEFORE_ATTR,+ ):+ tspan.attrib.pop(k, None)try:extra = next(extras_iter)- soft = next(soft_iter)+ break_kind = next(break_iter)except StopIteration:extra = 0.0- soft = False- if soft:+ break_kind = "paragraph"+ if break_kind == "soft":tspan.set(PARAGRAPH_SOFT_BREAK_ATTR, "1")+ elif break_kind == "line":+ tspan.set(PARAGRAPH_LINE_BREAK_ATTR, "1")elif extra > 1e-6:tspan.set(PARAGRAPH_SPACE_BEFORE_ATTR, format_number(extra))@@ -480,17 +515,26 @@ def _emit_mergeable_paragraph(def flatten_text_with_tspans(tree: ET.ElementTree,merge_paragraphs: bool = False,+ preserve_line_breaks: bool = False,) -> bool:"""Flatten multi-line tspan text into independent text nodes when needed.When ``merge_paragraphs`` is True, mergeable paragraph blocks (same x,- dy clustered around one base line-height) are kept as a single <text>- so downstream conversion emits one editable PowerPoint text frame- with multiple <a:p>. Default False preserves the original behavior:- every line-break tspan becomes its own <text>, matching the SVG's- pixel-fidelity contract.+ dy clustered around one base line-height) are kept as a single <text>.+ ``preserve_line_breaks`` marks ordinary visual rows as hard line breaks+ instead of reflowable continuations. Default split behavior still promotes+ every positioned row to its own <text>."""root = tree.getroot()+ positional_errors = nested_positional_tspan_errors(root)+ if positional_errors:+ preview = "; ".join(positional_errors[:3])+ suffix = (+ ""+ if len(positional_errors) <= 3+ else f"; +{len(positional_errors) - 3} more"+ )+ raise ValueError(f"Unsupported nested positional <tspan>: {preview}{suffix}")parent_map = {c: p for p in root.iter() for c in p}changed = False@@ -539,22 +583,23 @@ def flatten_text_with_tspans(if not needs_flatten:continue- # Paragraph fast-path (opt-in via merge_paragraphs=True): if the- # children form a mergeable paragraph (same x, dy clustered around- # one base line-height with optional paragraph gaps, no nested- # positional tspans), keep as one <text> and let the downstream- # converter emit multiple <a:p> runs. When disabled, every tspan- # gets its own independent <text> so the SVG's exact line layout- # is preserved in PowerPoint.+ # Single-frame fast path: conservative same-x/dy blocks stay in one+ # <text>. The downstream converter either preserves visual breaks or+ # reflows them. Split mode promotes each positioned line to <text>.if merge_paragraphs:- paragraph = _classify_paragraph_block(text_el, is_svg_tag, is_new_line_tspan)+ paragraph = _classify_paragraph_block(+ text_el,+ is_svg_tag,+ is_new_line_tspan,+ preserve_line_breaks,+ )if paragraph is not None:- base_dy, extras, soft_breaks, line_groups, synthetic_first = paragraph+ base_dy, extras, break_kinds, line_groups, synthetic_first = paragraph_emit_mergeable_paragraph(text_el,base_dy,extras,- soft_breaks,+ break_kinds,line_groups,synthetic_first=synthetic_first,)@@ -638,14 +683,22 @@ def _has_tspan_children(elem: ET.Element) -> bool:def _copy_inline_tspan(src: ET.Element, strip_line_attrs: bool) -> ET.Element:"""Deep-copy a tspan as an inline run, preserving nested tspan structure, head text, and tail text.- When strip_line_attrs is True, x/y/dy on the copied tspan are dropped because the- enclosing <text> now positions the line. dx is preserved (safe inline kerning).+ When strip_line_attrs is True, x/y/dy are dropped because the enclosing+ <text> owns the resolved line position. Drop dx only from a positioned+ line starter, where compute_line_positions already consumed it; preserve+ dx on later inline runs.Nested tspans are copied recursively without stripping (they are already inline-only)."""new = ET.Element(f"{{{SVG_NS}}}tspan")+ consumed_dx = (+ strip_line_attrs+ and _positional_tspan_attribute(src) is not None+ )for k, v in src.attrib.items():if strip_line_attrs and k in ("x", "y", "dy"):continue+ if k == "dx" and consumed_dx:+ continuenew.set(k, v)new.text = src.textfor child in list(src):diff --git a/skills/ppt-master/scripts/svg_quality_checker.py b/skills/ppt-master/scripts/svg_quality_checker.pyindex 4cf5d7f6..da78eca4 100644--- a/skills/ppt-master/scripts/svg_quality_checker.py+++ b/skills/ppt-master/scripts/svg_quality_checker.py@@ -348,9 +348,11 @@ except ImportError:try:from svg_to_pptx.tspan_flattener import (flatten_positional_tspans as _flatten_positional_tspans,+ nested_positional_tspan_errors as _nested_positional_tspan_errors,)except ImportError:_flatten_positional_tspans = None+ _nested_positional_tspan_errors = Nonetry:from svg_to_pptx.pptx_package.template_structure import (@@ -2526,6 +2528,17 @@ class SVGQualityChecker:self._check_root_module_text_bounds(root, result)self._check_fragmented_paragraph_text(root, result)self._check_unmergeable_leading_text(root, result)+ self._check_nested_positional_tspans(root, result)++ def _check_nested_positional_tspans(+ self,+ root: ET.Element,+ result: Dict,+ ) -> None:+ """Reject nested baseline jumps that DrawingML runs cannot represent."""+ if _nested_positional_tspan_errors is None:+ return+ result['errors'].extend(_nested_positional_tspan_errors(root))@classmethoddef _single_line_text_runs(@@ -3507,7 +3520,7 @@ class SVGQualityChecker:)def _check_unmergeable_leading_text(self, root: ET.Element, result: Dict) -> None:- """Warn when leading text cannot be normalized for paragraph merging."""+ """Warn when leading text cannot be normalized into one PPT text frame."""risky = []for text_el in root.iter(f'{{{SVG_NS}}}text'):if not (text_el.text or "").strip():@@ -3525,7 +3538,7 @@ class SVGQualityChecker:suffix = '' if len(risky) <= 3 else f"; +{len(risky) - 3} more"result['warnings'].append("Detected multi-line <text> with leading direct text that cannot "- f"be normalized for PPT paragraph merging ({sample}{suffix})"+ f"be normalized into one PPT text frame ({sample}{suffix})")def _check_fragmented_paragraph_text(@@ -4798,10 +4811,16 @@ class SVGQualityChecker:returnflattened_root = copy.deepcopy(root)- _flatten_positional_tspans(- ET.ElementTree(flattened_root),- merge_paragraphs=True,- )+ try:+ _flatten_positional_tspans(+ ET.ElementTree(flattened_root),+ merge_paragraphs=True,+ preserve_line_breaks=True,+ )+ except ValueError:+ # The shared text check reports the unsupported nested-position+ # contract; avoid turning a quality result into a checker crash.+ returnslots_by_id = {(slot.get('id') or '').strip(): slotfor slot in flattened_root.iter(f'{{{SVG_NS}}}g')@@ -4821,7 +4840,7 @@ class SVGQualityChecker:f"{svg_path.name}: placeholder slot {slot_id} becomes "f"{len(native_children)} native children after positional ""<tspan> flattening; a carrier-bound slot must export as one "- "text or picture carrier. Use one mergeable dy-stacked text "+ "text or picture carrier. Use one single-frame dy-stacked text ""frame, or move independently positioned lines outside the slot")diff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml/context.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml/context.pyindex c0a91790..063f8b38 100644--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml/context.py+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml/context.py@@ -14,6 +14,35 @@ if TYPE_CHECKING:AffineMatrix = tuple[float, float, float, float, float, float]IDENTITY_MATRIX: AffineMatrix = (1.0, 0.0, 0.0, 1.0, 0.0, 0.0)+TEXT_FLOW_PRESERVE = 'preserve'+TEXT_FLOW_REFLOW = 'reflow'+TEXT_FLOW_SPLIT = 'split'+TEXT_FLOW_MODES = frozenset({+ TEXT_FLOW_PRESERVE,+ TEXT_FLOW_REFLOW,+ TEXT_FLOW_SPLIT,+})+++def resolve_text_flow(+ text_flow: str | None = None,+ merge_paragraphs: bool | None = None,+) -> str:+ """Resolve the public text-layout options to one internal mode."""+ if text_flow is not None and merge_paragraphs is not None:+ raise ValueError(+ 'text_flow and legacy merge_paragraphs cannot be used together'+ )+ if merge_paragraphs is not None:+ return TEXT_FLOW_REFLOW if merge_paragraphs else TEXT_FLOW_SPLIT+ resolved = TEXT_FLOW_PRESERVE if text_flow is None else text_flow+ if resolved not in TEXT_FLOW_MODES:+ choices = ', '.join(sorted(TEXT_FLOW_MODES))+ raise ValueError(+ f'unsupported text_flow {resolved!r}; expected one of: {choices}'+ )+ return resolved+@dataclassclass ShapeResult:@@ -73,9 +102,9 @@ class ConvertContext:# Explicit sidecar group ids may override the legacy chrome-name heuristic.# Explicit structural layer/role/placeholder markers remain non-animatable.animation_group_overrides: frozenset[str] = frozenset()- # Default-on flag: merge mergeable paragraph blocks into one editable- # text frame with multiple <a:p>. Disable it for strict line fidelity.- merge_paragraphs: bool = True+ # Text-layout policy for positional tspans: preserve authored line breaks+ # in one frame, reflow them, or split them into independent frames.+ text_flow: str = TEXT_FLOW_PRESERVE# Explicit opt-in: replace marked chart/table fallback groups with editable# PowerPoint graphicFrames. Default stays off to preserve SVG output.native_objects_enabled: bool = False@@ -234,7 +263,7 @@ class ConvertContext:# anim_targets is intentionally a fresh list on the child;# only the root-level context's list is read by the builder.animation_group_overrides=self.animation_group_overrides,- merge_paragraphs=self.merge_paragraphs,+ text_flow=self.text_flow,native_objects_enabled=self.native_objects_enabled,image_optimize=self.image_optimize,image_max_dimension=self.image_max_dimension,diff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml/converter.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml/converter.pyindex 03189794..1a8a5b1d 100644--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml/converter.py+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml/converter.py@@ -26,7 +26,13 @@ from pptx_to_svg.preset_authoring import ()from resource_paths import icon_search_dirs_for_svg-from .context import ConvertContext, ShapeResult+from .context import (+ TEXT_FLOW_PRESERVE,+ TEXT_FLOW_SPLIT,+ ConvertContext,+ ShapeResult,+ resolve_text_flow,+)from .paths import (project_freeform_geometry_errors,project_gradient_geometry_errors,@@ -1358,7 +1364,7 @@ def convert_svg_to_slide_shapes(svg_path: str | Path,slide_num: int = 1,verbose: bool = False,- merge_paragraphs: bool = True,+ merge_paragraphs: bool | None = None,image_optimize: bool = True,image_max_dimension: int | None = 2560,image_sizing: str = 'cap',@@ -1370,6 +1376,7 @@ def convert_svg_to_slide_shapes(theme_color_spec: ThemeColorSpec | None = None,trace_out: list[dict[str, Any]] | None = None,promote_background: bool = True,+ text_flow: str | None = None,) -> tuple[str,dict[str, bytes],@@ -1384,10 +1391,11 @@ def convert_svg_to_slide_shapes(svg_path: Path to the SVG file.slide_num: Slide number (for naming).verbose: Print progress info.- merge_paragraphs: When True, mergeable paragraph blocks (same x,- dy clustered around one base line-height) become a single- editable text frame with multiple <a:p>. Disable it to preserve- the SVG's exact line layout (one textbox per line).+ merge_paragraphs: Legacy compatibility option. True selects reflow;+ False selects split. Do not combine with ``text_flow``.+ text_flow: Positional-tspan policy. ``preserve`` keeps authored visual+ line breaks in one frame, ``reflow`` lets PowerPoint wrap the text,+ and ``split`` emits one text frame per visual line.image_optimize: Downsample oversized raster images for PPTX export.image_max_dimension: Maximum optimized image dimension in pixels.image_sizing: ``cap`` to only cap source dimensions, ``display`` to@@ -1423,6 +1431,7 @@ def convert_svg_to_slide_shapes(- content_type_overrides: Dict of {pptx internal path: content type}for package_files that require [Content_Types].xml overrides."""+ text_flow = resolve_text_flow(text_flow, merge_paragraphs)svg_path = Path(svg_path)tree = ET.parse(str(svg_path))root = tree.getroot()@@ -1606,17 +1615,24 @@ def convert_svg_to_slide_shapes(# 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/.- # merge_paragraphs additionally folds mergeable paragraph blocks into a- # single annotated <text> for downstream multi-<a:p> conversion.+ # Preserve/reflow modes additionally fold conservative paragraph blocks+ # into one annotated <text>. Preserve keeps visual lines as DrawingML hard+ # breaks; reflow joins wrapping lines; split keeps one frame per line.from ..tspan_flattener import flatten_positional_tspans- flattened = flatten_positional_tspans(tree, merge_paragraphs=merge_paragraphs)+ flattened = flatten_positional_tspans(+ tree,+ merge_paragraphs=text_flow != TEXT_FLOW_SPLIT,+ preserve_line_breaks=text_flow == TEXT_FLOW_PRESERVE,+ )if flattened:trace_steps.append({'action': 'flatten-positional-tspans',- 'merge_paragraphs': merge_paragraphs,+ 'text_flow': text_flow,+ # Compatibility field for older trace readers.+ 'merge_paragraphs': text_flow != TEXT_FLOW_SPLIT,})if verbose:- print(' Flattened positional <tspan> into independent <text>')+ print(f' Lowered positional <tspan> using {text_flow} text flow')_require_project_text_properties(root, svg_path)try:@@ -1648,7 +1664,7 @@ def convert_svg_to_slide_shapes(viewport_width=viewport_width,viewport_height=viewport_height,svg_dir=Path(svg_path).parent,- merge_paragraphs=merge_paragraphs,+ text_flow=text_flow,image_optimize=image_optimize,image_max_dimension=image_max_dimension,image_sizing=image_sizing,diff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml/elements.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml/elements.pyindex 52c60cf6..fc3c8a8a 100644--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml/elements.py+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml/elements.py@@ -30,7 +30,12 @@ from resource_paths import (svg_image_payload_error,)-from .context import ConvertContext, ShapeResult+from .context import (+ TEXT_FLOW_PRESERVE,+ TEXT_FLOW_SPLIT,+ ConvertContext,+ ShapeResult,+)from .theme_colors import color_node_xmlfrom .theme_fonts import theme_font_tokensfrom .text_properties import (@@ -2120,6 +2125,10 @@ def _strip_leading_chars_from_runs(stripped: list[dict[str, Any]] = []remaining = char_countfor run in runs:+ if run.get('_line_break'):+ if remaining == 0:+ stripped.append(run)+ continuetext = str(run.get('text', ''))if remaining >= len(text):remaining -= len(text)@@ -2561,6 +2570,10 @@ def _coalesce_text_runs(merged: list[dict[str, Any]] = []previous_properties: str | None = Nonefor run in runs:+ if run.get('_line_break'):+ merged.append({'_line_break': True})+ previous_properties = None+ continuetext = str(run.get('text', ''))if not text:continue@@ -2601,6 +2614,8 @@ def _build_run_xml(effect_xml: str = '',) -> str:"""Build a single <a:r> XML from a run dict. Supports gradient fills on text."""+ if run.get('_line_break'):+ return '<a:br/>'text = str(run['text'])properties_xml = _build_run_properties_xml(run,@@ -2698,16 +2713,14 @@ def convert_text(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | None:'stroke_opacity': stroke_opacity,}- # Paragraph mode: flatten_tspan marks <text> with data-paragraph-line-height- # when its direct-child tspans form a mergeable paragraph (same x, dy- # clustered around one base line-height). Each direct tspan becomes one- # <a:p> so the paragraph survives as a single editable text frame.- # Per-line data-paragraph-space-before encodes paragraph gaps (extra dy- # above the base line-height) for the corresponding <a:p>.- # Paragraph mode is controlled by ctx.merge_paragraphs. When off, ignore- # any data-paragraph-* markers and fall through to the original- # one-text-per-tspan path so the SVG's pixel layout is preserved.- line_height_attr = elem.get('data-paragraph-line-height') if ctx.merge_paragraphs else None+ # Single-frame modes annotate conservative dy-stacked text with one base+ # line height. Semantic paragraphs become <a:p>; authored visual rows+ # either become <a:br/> (preserve) or join for wrapping (reflow).+ line_height_attr = (+ elem.get('data-paragraph-line-height')+ if ctx.text_flow != TEXT_FLOW_SPLIT+ else None+ )line_height_px = _f(line_height_attr) if line_height_attr is not None else Noneparagraph_runs: list[list[dict[str, Any]]] | None = Noneparagraph_space_before: list[float] = []@@ -2735,7 +2748,11 @@ def convert_text(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | None:_estimate_bullet_line_width(line_runs, fonts, ctx))soft_break = child.get('data-paragraph-soft-break') == '1'- if soft_break and paragraph_runs:+ line_break = child.get('data-paragraph-line-break') == '1'+ if line_break and paragraph_runs:+ paragraph_runs[-1].append({'_line_break': True})+ paragraph_runs[-1].extend(line_runs)+ elif soft_break and paragraph_runs:# Append to the previous paragraph. A Latin line-wrap needs a# space to keep two words apart (SVG used a dy break, not# punctuation); CJK wraps mid-sentence with no inter-character@@ -2781,7 +2798,7 @@ def convert_text(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | None:runs, single_bullet = _extract_text_bullet(runs)runs = _coalesce_text_runs(runs, fonts, ctx)- full_text = ''.join(r['text'] for r in runs) if runs else ''+ full_text = ''.join(str(r.get('text', '')) for r in runs) if runs else ''if not full_text.strip():is_placeholder_carrier = ((elem.get('data-pptx-carrier') or '').strip().lower()@@ -2800,14 +2817,9 @@ def convert_text(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | None:# Estimate text dimensionsif paragraph_runs is not None:- # Use the WIDEST visual line (per-tspan as the deck author drew it),- # not the joined-up paragraph: soft-broken paragraphs concatenate- # many lines into one <a:p>, and measuring the joined string would- # blow the textbox past the canvas.+ # Use the widest authored visual line, not a reflow-joined paragraph.text_width = max(visual_line_widths) if visual_line_widths else 0.0- # Total height assumes the visual line count from the SVG source;- # if PowerPoint wraps to more or fewer lines after the user resizes,- # the user resizes the height accordingly.+ # Keep the authored visual-line count as the source height contract.text_height = (line_height_px * (len(visual_line_widths) - 1)+ sum(paragraph_space_before)@@ -2986,9 +2998,17 @@ def convert_text(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | None:spc_bef_val = round(extra_px * FONT_PX_TO_HUNDREDTHS_PT)spc_bef_xml = f'<a:spcBef><a:spcPts val="{spc_bef_val}"/></a:spcBef>'runs_inner = '\n'.join(_build_run_xml(r, fonts, ctx, text_effect_xml) for r in line)+ first_text_run = next(+ (run for run in line if not run.get('_line_break')),+ None,+ )p_pr_xml = _paragraph_pr_xml(algn=algn,- font_size=float(line[0].get('font_size', font_size)) if line else font_size,+ font_size=(+ float(first_text_run.get('font_size', font_size))+ if first_text_run is not None+ else font_size+ ),body_xml=f'{ln_spc_xml}{spc_bef_xml}',bullet=bullet,ctx=ctx,@@ -3031,23 +3051,27 @@ def convert_text(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | None:if exact_text_insets is None:raise ValueError('data-pptx-frame text insets were not resolved')left_inset, top_inset, right_inset = exact_text_insets+ exact_frame_wrap = (+ 'none' if ctx.text_flow == TEXT_FLOW_PRESERVE else 'square'+ )body_pr_xml = (- '<a:bodyPr wrap="square" '+ f'<a:bodyPr wrap="{exact_frame_wrap}" 'f'lIns="{px_to_emu(left_inset)}" 'f'tIns="{px_to_emu(top_inset)}" 'f'rIns="{px_to_emu(right_inset)}" bIns="0" ''anchor="t" anchorCtr="0">\n<a:noAutofit/>\n</a:bodyPr>')- # Paragraph mode: wrap="square" so text reflows when the user resizes,- # but NO spAutoFit — otherwise PowerPoint expands the frame to fit a- # long joined-up <a:p> on one line, blowing past the canvas. The cx we- # write below is the longest source SVG line without single-line renderer- # headroom; PowerPoint wraps long paragraphs inside this design width.- # Single-line text keeps wrap="none" + spAutoFit for tight fidelity.+ # Preserve mode disables automatic wrapping and keeps authored <a:br/>+ # boundaries. Reflow mode uses the same source width as a wrapping+ # constraint. Neither mode lets PowerPoint resize the frame automatically.elif paragraph_runs is not None:+ paragraph_wrap = (+ 'none' if ctx.text_flow == TEXT_FLOW_PRESERVE else 'square'+ )body_pr_xml = (- '<a:bodyPr wrap="square" lIns="0" tIns="0" rIns="0" bIns="0" '- 'anchor="t" anchorCtr="0"/>'+ f'<a:bodyPr wrap="{paragraph_wrap}" '+ 'lIns="0" tIns="0" rIns="0" bIns="0" '+ 'anchor="t" anchorCtr="0">\n<a:noAutofit/>\n</a:bodyPr>')else:body_pr_xml = (diff --git a/skills/ppt-master/scripts/svg_to_pptx/pptx_package/builder.py b/skills/ppt-master/scripts/svg_to_pptx/pptx_package/builder.pyindex 410202ca..b118e8d8 100644--- a/skills/ppt-master/scripts/svg_to_pptx/pptx_package/builder.py+++ b/skills/ppt-master/scripts/svg_to_pptx/pptx_package/builder.py@@ -60,6 +60,7 @@ from ..animation_config import (resolve_morph_pairs,resolve_slide_animation_config,)+from ..drawingml.context import resolve_text_flowfrom ..drawingml.converter import convert_svg_to_slide_shapesfrom ..drawingml.theme_colors import (ThemeColorSpec,@@ -1666,7 +1667,7 @@ def _template_shape_for_item(return Noneif not shape_ids:text_hint = (- "; multiline text placeholders require the default paragraph merge "+ "; multiline text placeholders require a single-frame text mode ""and cannot use --no-merge"if item.placeholder and item.placeholder_carrier_tag == "text"else ""@@ -4600,7 +4601,7 @@ def create_pptx_with_native_svg(narration_padding: float = 0.5,cache_dir: Path | None = None,workers: int | None = None,- merge_paragraphs: bool = True,+ merge_paragraphs: bool | None = None,image_optimize: bool = True,image_max_dimension: int | None = 2560,image_sizing: str = 'cap',@@ -4622,6 +4623,7 @@ def create_pptx_with_native_svg(expected_viewbox: str | None = None,animation_resource_root: Path | None = None,transition_effect_options: dict[str, object] | None = None,+ text_flow: str | None = None,) -> bool:"""Create a PPTX file with native DrawingML shapes.@@ -4662,6 +4664,10 @@ def create_pptx_with_native_svg(narration_audio: Optional dict mapping SVG stem to narration audio file.use_narration_timings: Whether to set slide auto-advance from audio duration.narration_padding: Extra seconds added after each narration before advancing.+ merge_paragraphs: Legacy compatibility option. True selects reflow;+ False selects split. Do not combine with ``text_flow``.+ text_flow: Positional-tspan policy: preserve authored line breaks in+ one frame, reflow text, or split visual lines into separate frames.image_optimize: Whether native export optimizes raster images when needed.image_max_dimension: Preferred optimized image dimension cap in pixels.image_sizing: ``cap`` preserves unchanged source bytes and limits@@ -4700,6 +4706,7 @@ def create_pptx_with_native_svg(Returns:Whether all slides were successfully created."""+ text_flow = resolve_text_flow(text_flow, merge_paragraphs)public_svg_files = list(svg_files)definition_svg_files = list(layout_definition_files or [])public_slide_names = [path.stem for path in public_svg_files]@@ -5158,7 +5165,7 @@ def create_pptx_with_native_svg() = (convert_svg_to_slide_shapes(svg_path, slide_num=slide_num, verbose=verbose,- merge_paragraphs=merge_paragraphs,+ text_flow=text_flow,image_optimize=image_optimize,image_max_dimension=image_max_dimension,image_sizing=image_sizing,diff --git a/skills/ppt-master/scripts/svg_to_pptx/pptx_package/cli.py b/skills/ppt-master/scripts/svg_to_pptx/pptx_package/cli.pyindex 661f3d9e..3a71b8ca 100644--- a/skills/ppt-master/scripts/svg_to_pptx/pptx_package/cli.py+++ b/skills/ppt-master/scripts/svg_to_pptx/pptx_package/cli.py@@ -54,6 +54,11 @@ from ..native_objects import ()from ..native_objects.marker_status import native_marker_release_block_reasonfrom ..drawingml.theme_colors import ThemeColorError, load_theme_color_spec+from ..drawingml.context import (+ TEXT_FLOW_PRESERVE,+ TEXT_FLOW_REFLOW,+ TEXT_FLOW_SPLIT,+)from ..drawingml.theme_fonts import (ThemeFontError,load_master_text_style_spec,@@ -870,14 +875,35 @@ Recorded narration:),)- merge_group = parser.add_mutually_exclusive_group()- merge_group.add_argument('--merge-paragraphs', action='store_true', dest='merge_paragraphs',- help='Compatibility no-op: mergeable paragraph blocks are merged '- 'by default.')- merge_group.add_argument('--no-merge', action='store_false', dest='merge_paragraphs',- help='Disable paragraph merging. Every dy-stacked line becomes '- 'its own text frame for strict SVG line-layout fidelity.')- parser.set_defaults(merge_paragraphs=True)+ text_flow_group = parser.add_mutually_exclusive_group()+ text_flow_group.add_argument(+ '--reflow-text',+ action='store_const',+ const=TEXT_FLOW_REFLOW,+ dest='text_flow',+ help=(+ 'Let PowerPoint automatically reflow conservative dy-stacked text '+ 'inside one editable text frame.'+ ),+ )+ text_flow_group.add_argument(+ '--merge-paragraphs',+ action='store_const',+ const=TEXT_FLOW_REFLOW,+ dest='text_flow',+ help='Compatibility alias for --reflow-text.',+ )+ text_flow_group.add_argument(+ '--no-merge',+ action='store_const',+ const=TEXT_FLOW_SPLIT,+ dest='text_flow',+ help=(+ 'Emit every positioned visual line as its own text frame for '+ 'strict per-line SVG positioning.'+ ),+ )+ parser.set_defaults(text_flow=TEXT_FLOW_PRESERVE)parser.add_argument('--conversion-trace',nargs='?',@@ -1816,7 +1842,7 @@ Recorded narration:narration_audio=narration_audio,use_narration_timings=use_narration_timings,narration_padding=args.narration_padding,- merge_paragraphs=args.merge_paragraphs,+ text_flow=args.text_flow,image_optimize=not args.no_image_optimize,image_max_dimension=args.image_max_dimension,image_sizing=args.image_sizing,diff --git a/skills/ppt-master/scripts/svg_to_pptx/tspan_flattener.py b/skills/ppt-master/scripts/svg_to_pptx/tspan_flattener.pyindex 45b6d1f5..ce4b93b7 100644--- a/skills/ppt-master/scripts/svg_to_pptx/tspan_flattener.py+++ b/skills/ppt-master/scripts/svg_to_pptx/tspan_flattener.py@@ -28,21 +28,37 @@ from pathlib import Pathfrom xml.etree import ElementTree as ET+def _flatten_module():+ """Load the shared on-disk flattener after exposing the scripts root."""+ 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 import flatten_tspan # type: ignore+ return flatten_tspan++def flatten_positional_tspans(tree: ET.ElementTree,merge_paragraphs: bool = False,+ preserve_line_breaks: bool = False,) -> bool:"""Flatten positional ``<tspan>`` elements into independent ``<text>``.Delegates to ``svg_finalize.flatten_tspan.flatten_text_with_tspans`` sothe in-memory transform exactly matches the on-disk one. When``merge_paragraphs`` is True, mergeable paragraph blocks are preserved- as a single <text> for downstream multi-<a:p> conversion.+ as a single <text>. ``preserve_line_breaks`` marks visual rows for hard+ DrawingML line breaks instead of reflow.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, merge_paragraphs=merge_paragraphs)+ return _flatten_module().flatten_text_with_tspans(+ tree,+ merge_paragraphs=merge_paragraphs,+ preserve_line_breaks=preserve_line_breaks,+ )+++def nested_positional_tspan_errors(root: ET.Element) -> list[str]:+ """Return shared diagnostics for unsupported nested baseline jumps."""+ return _flatten_module().nested_positional_tspan_errors(root)