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-layouts): report all placement violations at once and scaffold page order

hugohe351b1cd160ab9
diff --git a/skills/ppt-master/references/executor-base.md b/skills/ppt-master/references/executor-base.md
index ac04e52b..dcf70188 100644
--- a/skills/ppt-master/references/executor-base.md
+++ b/skills/ppt-master/references/executor-base.md
@@ -214,6 +214,22 @@ Do **not** invent a layout entry, and do **not** assume a template just because
- `pptx_structure.mode: baseline` or missing with the whole `pptx_layouts` section absent → legacy compatibility only. Omit explicit PPTX layer/layout/placeholder metadata, keep the root page role and necessary structural hints, and let baseline export use conservative promotion plus page-role-backed Layout families. Filenames and ids are fallbacks only when the corresponding marker is absent.
- A layout key may repeat across non-adjacent pages. Reuse is based on identical static/placeholder contracts, not page proximity or content wording.
+**Page scaffold — author every mapped page in this document order.** One shape resolves the direct-child rule, the paint order, and the grouping exception at first write:
+
+```xml
+<svg viewBox="…" data-pptx-layout="<key>" data-pptx-layout-name="<name>">
+ <rect id="master-bg" data-pptx-layer="master" …/> <!-- deck background -->
+ <g id="footer-chrome" data-pptx-layer="master" …>…</g> <!-- every-page chrome -->
+ <g id="zone-framing" data-pptx-layer="layout" …>…</g> <!-- this key's framing -->
+ <text id="page-title" data-pptx-placeholder="title" …>…</text> <!-- direct child, never inside a <g> -->
+ <text id="page-number" data-pptx-placeholder="slide-number" …>…</text>
+ <g id="content-block-1">…</g> <!-- 3–8 content groups -->
+ <g id="content-block-2">…</g>
+</svg>
+```
+
+Master/layout layers and placeholders are always direct children of the root and precede every content group; a placeholder written inside a content `<g>` fails export.
+
**Per-page chart reference — `page_charts` section**:
Before drawing each page, look up its entry in `page_charts` to decide which chart structure applies (the SVG itself was loaded in §1.0):
diff --git a/skills/ppt-master/scripts/svg_to_pptx/pptx_package/template_structure.py b/skills/ppt-master/scripts/svg_to_pptx/pptx_package/template_structure.py
index 7f2e2cde..a8e4b35e 100644
--- a/skills/ppt-master/scripts/svg_to_pptx/pptx_package/template_structure.py
+++ b/skills/ppt-master/scripts/svg_to_pptx/pptx_package/template_structure.py
@@ -1302,10 +1302,69 @@ def native_structure_lock_errors(
return errors
+def _placement_lint_errors(svg_path: Path) -> list[str]:
+ """Enumerate every placement/paint-order violation in one pass.
+
+ ``parse_template_slide`` fails fast on the first error, which discloses
+ violations one whole fix-cycle at a time. The quality checker runs this
+ pre-lint first so a single run reports every offender of the two
+ highest-frequency classes: structure metadata below the root, and
+ template paint-order violations.
+ """
+ try:
+ root = ET.parse(svg_path).getroot()
+ except (OSError, ET.ParseError):
+ return []
+ if _local_tag(root) != "svg":
+ return []
+ errors: list[str] = []
+ direct_children = set(root)
+ for elem in root.iter():
+ if elem is root or elem in direct_children:
+ continue
+ if any(elem.get(attr) is not None for attr in _STRUCTURE_ATTRS):
+ element_id = elem.get("id") or _local_tag(elem) or "<unnamed>"
+ errors.append(
+ f"{svg_path.name}: {element_id} uses template metadata below the SVG "
+ "root; structure metadata is allowed only on direct children"
+ )
+ canvas = _svg_canvas(root)
+ last_order_rank = -1
+ for elem in root:
+ tag = _local_tag(elem)
+ if tag in _NON_VISUAL_TAGS:
+ continue
+ layer = (elem.get("data-pptx-layer") or "").strip().lower() or None
+ if layer not in _LAYERS:
+ layer = None
+ is_background = _is_full_canvas_solid_rect(elem, canvas)
+ effective_layer = layer or ("slide" if is_background else None)
+ if is_background and effective_layer is not None:
+ order_rank = {"master": 0, "layout": 1, "slide": 2}[effective_layer]
+ elif effective_layer == "master":
+ order_rank = 3
+ elif effective_layer == "layout":
+ order_rank = 4
+ else:
+ order_rank = 5
+ if order_rank < last_order_rank:
+ errors.append(
+ f"{svg_path.name}: {elem.get('id') or tag} violates template paint "
+ "order; use Master background, Layout background, Slide background, "
+ "Master shapes, Layout shapes, then Slide content/placeholders"
+ )
+ continue
+ last_order_rank = order_rank
+ return errors
+
+
def validate_template_svg(svg_path: Path) -> list[str]:
"""Return per-file template metadata errors for quality-check integration."""
+ errors = _placement_lint_errors(svg_path)
try:
parse_template_slide(svg_path, 1)
except TemplateStructureError as exc:
- return [str(exc)]
- return []
+ message = str(exc)
+ if message not in errors:
+ errors.append(message)
+ return errors