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-quality): detect text outside the page boundary
hugohe376406edbd774
diff --git a/skills/ppt-master/references/animations.md b/skills/ppt-master/references/animations.mdindex 6504dccc..363a5f2b 100644--- a/skills/ppt-master/references/animations.md+++ b/skills/ppt-master/references/animations.md@@ -333,7 +333,7 @@ other visible state is expected to change; both endpoints must still resolve toone compatible top-level PowerPoint object kind. Automatic Morph without pairsis heuristic and may cross-fade instead of tweening.-**Give text somewhere to come from.** Morph tweens objects present on both pages; text that only exists on the second page can only fade in. The standard fix is to place the *next* page's copy on the current page just outside the canvas (below), and the *previous* page's copy just outside the opposite edge (above). Each block then slides through the frame instead of blinking, and the deck reads as one continuous surface being scrolled. Objects parked outside the canvas are not rendered but must still exist on both pages and be explicitly paired when deterministic identity matters.+**Give text somewhere to come from.** Morph tweens objects present on both pages; text that only exists on the second page can only fade in. The standard fix is to place the *next* page's copy on the current page just outside the canvas (below), and the *previous* page's copy just outside the opposite edge (above). Each block then slides through the frame instead of blinking, and the deck reads as one continuous surface being scrolled. A wholly off-canvas endpoint must be one direct-root `<g id>` with valid `data-pptx-bounds` and `data-pptx-morph-staging="true"`; when Morph remains enabled, pair it explicitly under §2.1. The marker only declares an intentional invisible endpoint; it cannot excuse a partially clipped group or text carrier.**When Morph refuses to match**: PowerPoint pairs compatible object kinds; ashape and a picture will cross-fade instead of tweening. For generated pages,diff --git a/skills/ppt-master/references/executor-base.md b/skills/ppt-master/references/executor-base.mdindex b7ee2b80..15c616dc 100644--- a/skills/ppt-master/references/executor-base.md+++ b/skills/ppt-master/references/executor-base.md@@ -134,7 +134,7 @@ Before drawing each page, look up its entry in `page_rhythm` (key format `P<NN>`## 3. Execution Guidelines- **Proximity**: group related elements with tight spacing; separate unrelated groups-- **Element grouping (Mandatory)**: wrap each logical Slide-local body unit in a descriptive, page-unique top-level `<g id>`. Every visible direct root `<g>` declares root-coordinate `data-pptx-bounds="x y width height"`; frame/native coordinates do not replace it, and placeholder bounds also supply the slot frame. Nested groups need no bounds and any such values are ignored. Checker compares root bounds with the `viewBox` and recursively checks only estimable text against its root module: through `1px` is ignored, through `5%` warns, above `5%` fails per side. Images, shapes, paths, `<use>`, effects, and object frames remain geometrically free. Flat pages use ordinary groups; structured slots already qualify, while titles, direct Master/Layout atoms, and canvas-level static framing may remain root primitives. On flat pages, give a root background image or full-canvas scrim/decoration rectangle a stable `id` plus `data-pptx-role="background"` / `"decoration"`; never wrap it only to silence the advisory.+- **Element grouping (Mandatory)**: wrap each logical Slide-local body unit in a descriptive, page-unique top-level `<g id>`. Every visible direct root `<g>` declares root-coordinate `data-pptx-bounds="x y width height"`; frame/native coordinates do not replace it, and placeholder bounds also supply the slot frame. Nested groups need no bounds and any such values are ignored. Checker compares root bounds with the `viewBox`, recursively checks estimable text against its root module with DrawingML wrapping headroom, and independently checks every estimable visible text carrier against the page without that headroom: through `1px` is ignored; module overflow warns through `5%` and fails above it, while larger page overflow always fails. Unestimable visible text receives an advisory warning. Only a wholly off-canvas direct-root Morph endpoint may set `data-pptx-morph-staging="true"`; keep its text inside its own module bounds, use an explicit pair when Morph remains enabled, and never use the marker for partial overflow. Images, shapes, paths, `<use>`, effects, and object frames remain geometrically free. Flat pages use ordinary groups; structured slots already qualify, while titles, direct Master/Layout atoms, and canvas-level static framing may remain root primitives. On flat pages, give a root background image or full-canvas scrim/decoration rectangle a stable `id` plus `data-pptx-role="background"` / `"decoration"`; never wrap it only to silence the advisory.- **Reference — not a constraint**: top-level groups set semantic and automatic-animation granularity, but they may contain descriptive nested `<g>` edit groups when the page has meaningful internal subunits. Nested groups need no bounds and create no automatic animation step; use or omit them from the page's actual editing semantics, with no default pattern, depth, or quota.- **Default — size `data-pptx-bounds` as the intended module zone, not a glyph box (may skip when no text is estimable)**: make the zone as generous as the canvas and sibling layout allow, without overlapping another module zone. An untransformed line spans `y - 0.85 × font_size` to `y + 0.35 × font_size`; width uses the shared SVG-to-PPTX per-run estimate and safety headroom. If text does not fit, first expand a zone that has unused non-overlapping space; otherwise reflow or adapt. Larger bounds do not repair off-canvas text.- **Spec adherence**: follow color, layout, canvas format, and typography in the specdiff --git a/skills/ppt-master/references/shared-standards-core.md b/skills/ppt-master/references/shared-standards-core.mdindex c7d0df34..2aedbd2a 100644--- a/skills/ppt-master/references/shared-standards-core.md+++ b/skills/ppt-master/references/shared-standards-core.md@@ -587,7 +587,7 @@ These forms are needed only when the stated PPT behavior matters:### 4.3 Element Grouping (Mandatory)-**Hard rule — root groups protect body-text layout**: Every visible direct root `<g>` declares positive root-coordinate `data-pptx-bounds="x y width height"`. Keep it when frame/native coordinates size one PowerPoint object; placeholder bounds also supply the slot frame. On flat pages, make each module zone as generous as the canvas and sibling layout allow without overlapping another module zone. Checker validates this subcanvas against the root `viewBox`, then recursively validates only estimable `<text>` descendants against it using the shared SVG-to-PPTX per-run width estimate and safety headroom. Nested groups and all shapes, images, paths, `<use>` instances, effects, and object frames are not content-boundary inputs. Per side, Checker ignores text/bounds overflow through `1px`, warns through `5%` of the containing boundary dimension, and fails above `5%`. Bounds do not clip or reflow.+**Hard rule — root groups protect body-text layout**: Every visible direct root `<g>` declares positive root-coordinate `data-pptx-bounds="x y width height"`. Keep it when frame/native coordinates size one PowerPoint object; placeholder bounds also supply the slot frame. On flat pages, make each module zone as generous as the canvas and sibling layout allow without overlapping another module zone. Checker validates this subcanvas against the root `viewBox`, then recursively validates only estimable `<text>` descendants against it using the shared SVG-to-PPTX per-run width estimate and DrawingML wrapping headroom. It validates every estimable visible text carrier directly against the root `viewBox` with the same per-run estimate before that headroom. Nested groups and all shapes, images, paths, `<use>` instances, effects, and object frames are not module-boundary inputs. Per side, Checker ignores overflow through `1px`; module-boundary overflow warns through `5%` and fails above `5%`, while any larger root-`viewBox` text overflow fails. Bounds do not clip or reflow; unestimable visible text receives an advisory warning. The only page-boundary exception is a wholly off-canvas direct-root Morph endpoint marked `data-pptx-morph-staging="true"`; its own module bounds still apply, retained Morph uses an explicit pair, and the marker never excuses partial page overflow.Wrap each logical Slide-local body unit in one descriptive top-level `<g id>`; group count follows the page's semantic units, and each group becomes one stable animation target when animation is enabled. Generic deck-wide animation gives that target one step; an explicit animation sidecar may assign it several ordered effects. Nested implementation groups may remain anonymous and need no bounds; any nested bounds are ignored. Flat pages use ordinary groups; structured slots already qualify, while titles, direct atomic Master/Layout elements, and canvas-level static framing—including background images and full-canvas scrim/decoration rectangles—may remain root primitives. On flat pages, give such static framing a stable `id` plus `data-pptx-role="background"` / `"decoration"`; never add a `<g>` solely to silence an ungrouped-element advisory.diff --git a/skills/ppt-master/scripts/docs/svg-pipeline.md b/skills/ppt-master/scripts/docs/svg-pipeline.mdindex 29f57bee..8360a686 100644--- a/skills/ppt-master/scripts/docs/svg-pipeline.md+++ b/skills/ppt-master/scripts/docs/svg-pipeline.md@@ -624,7 +624,7 @@ Behavior:- Native mode is strict about unsupported visual SVG elements: if a visual element cannot be represented or safely preserved, export fails with the SVG file, element tag, and position instead of silently dropping content.- Omitting `--pptx-structure` reads `spec_lock.md`. Free-design, brand-only, and `template_reuse_scope: style` releases declare `mode: flat`, omit Master/Layout mappings and SVG structure metadata, and materialize one clean project-owned Master plus one Blank Layout from the current lock. Deck/layout templates use `mode: structured` only for `template_reuse_scope: mirror|layout`, with complete unique `pptx_masters` / `pptx_layouts` rosters and one `page_pptx_layouts` assignment per page. A template-backed Layout definition may remain unused by pages and still register in the final package.- On structured template routes, every page root repeats Master/Layout keys and picker names. Master/Layout fixed visuals are direct semantic atoms. Ordinary layer `<g>` elements are invalid; one validated compact authored-preset `<g>` emitted by `preset_shape_svg.py` is the sole group exception because it compiles to one native shape.-- Every visible direct root `<g>` requires root-coordinate `data-pptx-bounds`; nested bounds are ignored. Frame/native metadata never replaces it; placeholder bounds also define the slot frame. Checker compares root bounds with `viewBox` and only descendant text with that module. Images, shapes, paths, `<use>`, effects, and object frames are excluded. Per side: ≤`1px` ignored, ≤`5%` warns, >`5%` fails. Bounds never clip/reflow.+- Every visible direct root `<g>` requires root-coordinate `data-pptx-bounds`; nested bounds are ignored. Frame/native metadata never replaces it; placeholder bounds also define the slot frame. Checker compares root bounds with `viewBox`, descendant text with its module using DrawingML wrapping headroom, and every estimable visible text carrier directly with the root `viewBox` before that headroom. Images, shapes, paths, `<use>`, effects, and object frames are excluded from module containment. Per side, ≤`1px` is ignored; module overflow ≤`5%` warns and >`5%` fails, while larger page text overflow always fails. Bounds never clip/reflow; unestimable visible text warns. A wholly off-canvas direct-root Morph endpoint may opt out of page containment with `data-pptx-morph-staging="true"`; it still needs valid module bounds, retained Morph uses an explicit pair, and partial overflow remains blocking.- Missing root bounds fails on final pages/templates and under `--template-mode`; references warn until adapted.- On structured template routes, each normal slot is a direct root `<g id>` with semantic type, positive design-zone bounds, and exactly one compatible carrier. Composite `object` slots use explicit proxy binding; zero-slot Layouts are valid. Flat pages keep all SVG objects Slide-local.- Flat export maps locked typography/colors into a clean project-owned theme/Master, removes stock content placeholders and unused built-in Layouts, retains only the standard date/footer/slide-number capability hooks, and keeps one Blank Layout without promoting Slide content. Structured export additionally creates one reusable Layout per declared key and reopens the package to verify the full Presentation → Master → Layout → Slide graph, fixed-object order, placeholder identities/bounds, carrier bindings, hidden proxies, and zero-slot Layouts.diff --git a/skills/ppt-master/scripts/svg_quality/checker.py b/skills/ppt-master/scripts/svg_quality/checker.pyindex 8d389421..582010f3 100644--- a/skills/ppt-master/scripts/svg_quality/checker.py+++ b/skills/ppt-master/scripts/svg_quality/checker.py@@ -343,6 +343,7 @@ _NON_VISUAL_SVG_TAGS = frozenset({'title',})_BOUNDS_ATTR = 'data-pptx-bounds'+_MORPH_STAGING_ATTR = 'data-pptx-morph-staging'_BOUNDS_OVERFLOW_TOLERANCE = 1.0_BOUNDS_OVERFLOW_ERROR_RATIO = 0.05_PARAGRAPH_LINE_GAP_MIN_RATIO = 0.9@@ -1483,7 +1484,7 @@ class SVGQualityChecker:self._check_module_bounds_contract(root, result)self._check_text_output_geometry(root, result)- self._check_root_module_text_bounds(root, result)+ self._check_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)@@ -1894,6 +1895,8 @@ class SVGQualityChecker:runs: List[Dict],font_size: float,parent_by_id: Dict[int, ET.Element],+ *,+ include_headroom: bool = True,) -> Tuple[float, float, float, float] | None:"""Estimate one line's transformed visible bounds in SVG coordinates."""if any(helper is None for helper in (@@ -1906,7 +1909,10 @@ class SVGQualityChecker:)):return Nonetry:- width = float(_estimate_single_line_text_frame_width(runs))+ width = float(_estimate_single_line_text_frame_width(+ runs,+ include_headroom=include_headroom,+ ))raw_anchor = (_effective_presentation_value(line_el,@@ -1950,6 +1956,8 @@ class SVGQualityChecker:parent_by_id: Dict[int, ET.Element],font_sizes: Dict[int, float],letter_spacings: Dict[int, float],+ *,+ include_headroom: bool = True,) -> Tuple[float, float, float, float] | None:"""Estimate one single- or multi-line text carrier's visual bounds."""lines: List[Tuple[ET.Element, float, float, List[Dict], float]] | None@@ -1991,6 +1999,7 @@ class SVGQualityChecker:line_runs,font_size,parent_by_id,+ include_headroom=include_headroom,)for line_el, x, y, line_runs, font_size in lines]@@ -2155,6 +2164,36 @@ class SVGQualityChecker:axes = 'vertical'return axes, horizontal_ratio, vertical_ratio+ @staticmethod+ def _bounds_are_disjoint(+ first: Tuple[float, float, float, float],+ second: Tuple[float, float, float, float],+ ) -> bool:+ """Return whether two root-coordinate rectangles do not intersect."""+ left, top, right, bottom = first+ other_left, other_top, other_right, other_bottom = second+ return (+ right <= other_left+ or left >= other_right+ or bottom <= other_top+ or top >= other_bottom+ )++ @classmethod+ def _is_off_canvas_morph_group(+ cls,+ group: ET.Element,+ canvas: Tuple[float, float, float, float],+ ) -> bool:+ """Return whether a group declares one wholly off-canvas Morph state."""+ if group.get(_MORPH_STAGING_ATTR) != 'true':+ return False+ resolved = cls._resolved_root_module_bounds(group)+ return (+ resolved is not None+ and cls._bounds_are_disjoint(resolved[1], canvas)+ )+@classmethoddef _record_bounds_overflow(cls,@@ -2198,6 +2237,51 @@ class SVGQualityChecker:f'{repair}')+ @classmethod+ def _record_canvas_text_overflow(+ cls,+ result: Dict,+ *,+ subject: str,+ inner: Tuple[float, float, float, float],+ canvas: Tuple[float, float, float, float],+ ) -> bool:+ """Record one page-boundary error and return whether it overflowed."""+ metrics = cls._bounds_overflow_metrics(inner, canvas)+ if metrics is None:+ return False+ axes, horizontal_ratio, vertical_ratio = metrics+ left, top, right, bottom = inner+ canvas_left, canvas_top, canvas_right, canvas_bottom = canvas+ result['errors'].append(+ f'{subject} exceeds the root viewBox on the {axes} axis: '+ f'content ({left:.1f}, {top:.1f})-({right:.1f}, '+ f'{bottom:.1f}), canvas ({canvas_left:.1f}, '+ f'{canvas_top:.1f})-({canvas_right:.1f}, '+ f'{canvas_bottom:.1f}), overflow horizontal '+ f'{horizontal_ratio:.1%}, vertical {vertical_ratio:.1%}; '+ 'move or reflow the text until its estimated bounds stay on-page'+ )+ return True++ @staticmethod+ def _text_diagnostic_label(text_element: ET.Element) -> str:+ """Return a locatable label for one SVG text carrier."""+ label = _element_label(text_element)+ if (text_element.get('id') or '').strip():+ return label++ details: List[str] = []+ raw_x = (text_element.get('x') or '').strip()+ raw_y = (text_element.get('y') or '').strip()+ if raw_x or raw_y:+ details.append(f'x={raw_x or "?"}, y={raw_y or "?"}')+ snippet = re.sub(r'\s+', ' ', ''.join(text_element.itertext())).strip()+ if snippet:+ preview = snippet[:20] + ('…' if len(snippet) > 20 else '')+ details.append(f'text={preview!r}')+ return f'{label} ({"; ".join(details)})' if details else label+@staticmethoddef _is_hidden_element(element: ET.Element,@@ -2334,6 +2418,72 @@ class SVGQualityChecker:'only on <g> layout modules')+ for element in root.iter():+ raw_staging = element.get(_MORPH_STAGING_ATTR)+ if raw_staging is None:+ continue+ label = _element_label(element)+ if raw_staging != 'true':+ result['errors'].append(+ f'{label} {_MORPH_STAGING_ATTR} must equal "true"; '+ 'set the exact value or remove the marker'+ )+ continue+ if _local_name(element) != 'g':+ result['errors'].append(+ f'{label} {_MORPH_STAGING_ATTR} is valid only on <g>; '+ 'move it to the enclosing ordinary direct-root group'+ )+ continue+ if parent_by_id.get(id(element)) is not root:+ result['errors'].append(+ f'{label} {_MORPH_STAGING_ATTR} requires a direct-root '+ '<g>; move the marked group directly under <svg> or remove '+ 'the marker'+ )+ continue+ if not (element.get('id') or '').strip():+ result['errors'].append(+ f'{label} {_MORPH_STAGING_ATTR} requires a stable non-empty '+ 'id; add an id to the marked direct-root group'+ )+ continue+ incompatible = [+ attribute+ for attribute in (+ 'data-pptx-layer',+ 'data-pptx-placeholder',+ )+ if element.get(attribute) is not None+ ]+ if incompatible:+ result['errors'].append(+ f'{label} {_MORPH_STAGING_ATTR} cannot be combined with '+ f'{", ".join(incompatible)}; use an ordinary Slide-local '+ 'group or remove the marker'+ )+ continue+ resolved = self._resolved_root_module_bounds(element)+ if resolved is None:+ result['errors'].append(+ f'{label} {_MORPH_STAGING_ATTR} requires valid '+ f'{_BOUNDS_ATTR}; add or fix positive root-coordinate '+ 'x y width height bounds'+ )+ continue+ if canvas is None:+ result['errors'].append(+ f'{label} {_MORPH_STAGING_ATTR} cannot verify an off-canvas '+ 'endpoint without a valid root viewBox; fix the root viewBox'+ )+ continue+ if not self._bounds_are_disjoint(resolved[1], canvas):+ result['errors'].append(+ f'{label} {_MORPH_STAGING_ATTR} requires wholly off-canvas '+ f'{_BOUNDS_ATTR}; move the full bounds outside the root '+ 'viewBox or remove the marker from partially visible content'+ )+missing: List[str] = []root_groups = [child@@ -2366,6 +2516,8 @@ class SVGQualityChecker:resolved = self._resolved_root_module_bounds(group)if resolved is None or canvas is None:continue+ if self._is_off_canvas_morph_group(group, canvas):+ continueattribute, bounds = resolvedself._record_bounds_overflow(result,@@ -2391,12 +2543,12 @@ class SVGQualityChecker:'data-pptx-frame or native chart/table coordinates')- def _check_root_module_text_bounds(+ def _check_text_bounds(self,root: ET.Element,result: Dict,) -> None:- """Grade visible text against its direct root module subcanvas."""+ """Validate visible text against page and root-module bounds."""helpers = (_estimate_single_line_text_frame_width,_parse_project_font_weight,@@ -2422,6 +2574,103 @@ class SVGQualityChecker:for child in list(parent)}unchanged_groups = self._unchanged_txbody_group_ids(root)+ viewbox = _parse_viewbox_values(root.get('viewBox') or '')+ canvas = None+ if viewbox is not None:+ x, y, width, height = viewbox+ canvas = (x, y, x + width, y + height)++ estimated_by_id: Dict[+ int,+ Tuple[float, float, float, float],+ ] = {}+ page_overflow_text_ids: set[int] = set()+ unverified: List[str] = []+ for text_element in root.iter(f'{{{SVG_NS}}}text'):+ if self._has_ancestor_id(+ text_element,+ parent_by_id,+ unchanged_groups,+ ):+ continue+ if self._has_non_visual_ancestor(+ text_element,+ root,+ parent_by_id,+ ):+ continue+ if self._is_hidden_element(text_element, parent_by_id):+ continue+ visible_text = ''.join(text_element.itertext())+ if (+ not visible_text.strip()+ or ('{{' in visible_text and '}}' in visible_text)+ ):+ continue+ estimated = self._estimated_text_bounds(+ text_element,+ parent_by_id,+ font_sizes,+ letter_spacings,+ include_headroom=True,+ )+ if estimated is not None:+ estimated_by_id[id(text_element)] = estimated++ if (+ canvas is None+ or self._has_zero_opacity(text_element, parent_by_id)+ ):+ continue++ page_estimated = self._estimated_text_bounds(+ text_element,+ parent_by_id,+ font_sizes,+ letter_spacings,+ include_headroom=False,+ )+ if page_estimated is None:+ unverified.append(self._text_diagnostic_label(text_element))+ continue+ direct_child = text_element+ parent = parent_by_id.get(id(direct_child))+ while parent is not None and parent is not root:+ direct_child = parent+ parent = parent_by_id.get(id(direct_child))+ morph_staging = (+ parent is root+ and _local_name(direct_child) == 'g'+ and self._is_off_canvas_morph_group(+ direct_child,+ canvas,+ )+ and self._bounds_are_disjoint(page_estimated, canvas)+ )+ if (+ not morph_staging+ and self._record_canvas_text_overflow(+ result,+ subject=self._text_diagnostic_label(text_element),+ inner=page_estimated,+ canvas=canvas,+ )+ ):+ page_overflow_text_ids.add(id(text_element))++ if unverified:+ sample = ', '.join(unverified[:3])+ suffix = (+ ''+ if len(unverified) <= 3+ else f', +{len(unverified) - 3} more'+ )+ result['warnings'].append(+ 'Cannot verify root viewBox bounds for visible text with '+ f'unsupported or unresolved geometry: {sample}{suffix}; use '+ 'supported explicit text positioning when page fit matters'+ )+root_groups = [childfor child in list(root)@@ -2435,37 +2684,14 @@ class SVGQualityChecker:continueboundary_attribute, boundary = resolved_modulefor text_element in module.iter(f'{{{SVG_NS}}}text'):- if self._has_ancestor_id(- text_element,- parent_by_id,- unchanged_groups,- ):- continue- if self._has_non_visual_ancestor(- text_element,- module,- parent_by_id,- ):- continue- if self._is_hidden_element(text_element, parent_by_id):+ if id(text_element) in page_overflow_text_ids:continue- visible_text = ''.join(text_element.itertext())- if (- not visible_text.strip()- or ('{{' in visible_text and '}}' in visible_text)- ):- continue- estimated = self._estimated_text_bounds(- text_element,- parent_by_id,- font_sizes,- letter_spacings,- )+ estimated = estimated_by_id.get(id(text_element))if estimated is None:continueself._record_bounds_overflow(result,- subject=_element_label(text_element),+ subject=self._text_diagnostic_label(text_element),inner=estimated,container=(f'{_element_label(module)} {boundary_attribute}'diff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml/elements.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml/elements.pyindex e410e700..887c531e 100644--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml/elements.py+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml/elements.py@@ -2091,10 +2091,15 @@ def _estimate_text_runs_width(def estimate_single_line_text_frame_width(runs: list[dict[str, Any]],+ *,+ include_headroom: bool = True,) -> float:- """Estimate the content width used by one generated DrawingML textbox."""+ """Estimate one DrawingML textbox width with optional safety headroom."""content_runs, bullet = _extract_text_bullet(runs)- width = _estimate_text_runs_width(content_runs)+ width = _estimate_text_runs_width(+ content_runs,+ include_headroom=include_headroom,+ )if bullet:font_size = (float(content_runs[0].get('font_size', 16))