50 KiB
SVG Pipeline Tools
Maintenance boundary: post-processing modules serve both the on-disk
svg_final/preview and in-memory native PPTX conversion. Check both consumers before changing or removing a step.
These tools cover post-processing, SVG validation, speaker notes, recorded narration, and PPTX export.
The supported delivery contract has one PPTX path: svg_output/ → the project SVG-to-DrawingML converter → native PPTX. The mandatory finalize_svg.py step separately creates self-contained svg_final/ visual previews, which may be opened directly or inserted into PowerPoint as SVG pictures. There is no SVG-image PPTX output, and PowerPoint's manual Convert-to-Shape operation is unsupported.
svg_authoring_view.py
Create a lightweight editable authoring IR bundle from one PPTX-imported SVG or a directory of imported SVGs:
python3 scripts/svg_authoring_view.py <svg-file-or-directory> -o <output-dir> \
--projection-kind layered
The operation is non-destructive and refuses existing output files unless
--force is explicit. It never writes back to the source SVG. The JSON report
on stdout records original/projected byte counts and removals by category. The
output directory contains the editable SVGs, one model-readable
authoring_summary.json, and one tool-only authoring_manifest.json.
The projected copy:
- removes embedded
txbodymetadata; - removes hidden native geometry carriers while retaining and unwrapping their visible preview geometry;
- removes source-object identity/style/hash attributes that are only useful to an exact import round trip;
- keeps visible paths, text, images, stable ids, Master/Layout root markers,
selected native-shape intent, and a document-local
data-pptx-source-refon each imported logical object; - rewrites relative local asset references for the projection's new location;
- compacts imported model-facing frames and safe transform page coordinates to at most two decimals.
The summary stores the current SVG roster plus compact per-file canvas, size,
text, image, vector, placeholder, icon, and source-ref counts. Models read the
summary and editable SVGs; they do not read the machine manifest. The manifest
stores relative source/authoring filenames, source and initial authoring hashes,
and source element paths. It deliberately does not copy the opaque payload.
The authoring bundle is the editable source for template creation; the complete
imported SVG remains immutable native-payload backing. Final
templates/*.svg files are materialized and validated from that pair. The IR
directory itself is not a supported direct input to svg_to_pptx.py.
Regenerate the summary after direct edits that do not pass through one of the in-place normalization tools:
python3 scripts/svg_authoring_view.py <authoring-dir> --refresh-summary
This projection is separate from canonical preset authoring. New project SVGs
and project-owned templates use the compact authored form: one atomic
<g data-pptx-authoring="preset"> owns the preset intent and base paint, with
the registry-generated visible <path> layers as direct children. Quality
check and export rerender the locked registry to validate that group, so the
compact form has no hidden carrier, preview wrapper, or serialized preview
fingerprint. pptx_to_svg.py continues to emit the expanded carrier/preview
evidence required for import and round-trip decisions. The normative boundary
is owned by shared-standards-core.md §1.5, with
authoring guidance in
native-shape-authoring.md.
Shape Boolean maintenance smoke
Run this manual smoke from the repository root after changing
shape_boolean_svg.py, preset geometry, path conversion, or custom-geometry
import/export. It uses only a gitignored projects/_smoke_* workspace and the
inline-smoke convention from code-style.md
§11; do not turn it into a test file or example deck.
python3 - <<'PY'
import re
import subprocess
import sys
import tempfile
import zipfile
from pathlib import Path
from xml.etree import ElementTree as ET
import pathops
project = Path(tempfile.mkdtemp(prefix="_smoke_shape_boolean_", dir="projects"))
scripts = Path("skills/ppt-master/scripts")
svg_output = project / "svg_output"
svg_output.mkdir()
(project / "spec_lock.md").write_text(
"""<!-- ppt-master-schema: spec-lock/v1 -->
# Execution Lock
## canvas
- viewBox: 0 0 1280 720
- format: ppt169
## communication
- audience:
- objective:
- core_message:
## mode
- mode: briefing
## visual_style
- visual_style: Boolean maintenance smoke
## colors
- bg: #FFFFFF
- primary: #2563EB
- accent: #F97316
- text: #0F172A
## typography
- font_family: Arial, sans-serif
- title_family: Arial, sans-serif
- body_family: Arial, sans-serif
- title: 36
- body: 20
## icons
- library: none
- inventory: none
## page_rhythm
- P01: dense
## pptx_structure
- mode: flat
## forbidden
- Unsupported SVG constructs
""",
encoding="utf-8",
)
def run_tool(script, *args):
result = subprocess.run(
[sys.executable, str(scripts / script), *map(str, args)],
capture_output=True, text=True,
)
assert result.returncode == 0, result.stderr or result.stdout
return result.stdout.strip()
preset = run_tool(
"preset_shape_svg.py", "render", "rightArrow",
"--id", "preset-source", "--frame", "500", "120", "240", "120",
"--fill", "#2563EB", "--stroke", "none",
)
source = project / "operands.svg"
source.write_text(
f"""<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1280 720">
<defs><clipPath id="clip"><rect width="80" height="80"/></clipPath></defs>
<g transform="translate(100 80) scale(1.2)">
<rect id="body" x="40" y="40" width="400" height="240" rx="20"
fill="#2563EB" stroke="#0F172A" stroke-width="5"
stroke-dasharray="10 4"/>
<circle id="cutout" cx="240" cy="160" r="70" fill="#F97316"/>
<text id="text-cutout" x="240" y="235" text-anchor="middle"
font-family="sans-serif" font-size="180" font-weight="700">01</text>
<text id="missing-font" x="240" y="235"
font-family="Definitely Missing Font" font-size="80">X</text>
<text id="nested-text" x="240" y="235"
font-family="sans-serif" font-size="80"><tspan>X</tspan></text>
<path id="open" d="M 40 320 L 260 320 L 260 420" fill="#2563EB"/>
<rect id="clipped" x="40" y="320" width="160" height="100"
clip-path="url(#clip)" fill="#2563EB"/>
<path id="imported" d="M 240 320 H 400 V 420 H 240 Z"
data-pptx-geometry-kind="custom" fill="#2563EB"/>
<rect id="dashoffset" x="440" y="320" width="120" height="100"
fill="#2563EB" stroke="#0F172A" stroke-dashoffset="2"/>
<rect id="non-scaling" x="500" y="40" width="150" height="120"
fill="#2563EB" stroke="#0F172A" stroke-width="5"
stroke-dasharray="10 4" vector-effect="non-scaling-stroke"/>
<circle id="non-scaling-cut" cx="625" cy="100" r="45" fill="#F97316"/>
<rect id="far" x="800" y="320" width="100" height="80" fill="#2563EB"/>
</g>
{preset}
<circle id="preset-cut" cx="690" cy="180" r="52" fill="#F97316"/>
</svg>
""",
encoding="utf-8",
)
operations = [
("union", "union", "preset-source", "preset-cut"),
("combine", "combine", "body", "cutout"),
("fragment", "fragment", "body", "cutout"),
("intersect", "intersect", "body", "cutout"),
("subtract", "subtract", "body", "cutout"),
("text-subtract", "subtract", "body", "text-cutout"),
]
expected_custom_shapes = 0
for index, (name, operation, first, second) in enumerate(operations, start=1):
fragment = run_tool(
"shape_boolean_svg.py", "render", source, "--operation", operation,
"--source", first, "--source", second, "--id", f"result-{name}",
)
paths = list(
ET.fromstring(
f'<svg xmlns="http://www.w3.org/2000/svg">{fragment}</svg>'
)
)
assert paths and all(path.tag.endswith("}path") for path in paths)
assert all(
token not in fragment
for token in ("clip-path=", "fill-rule=", "mask=", "transform=")
)
if operation == "fragment":
assert len(paths) > 1
assert [path.get("id") for path in paths] == [
f"result-{name}-{piece}"
for piece in range(1, len(paths) + 1)
]
else:
assert len(paths) == 1
assert paths[0].get("id") == f"result-{name}"
if operation == "combine":
assert all(path.get("stroke-width") == "6" for path in paths)
assert all(path.get("stroke-dasharray") == "12 4.8" for path in paths)
if operation == "subtract":
assert (paths[0].get("d") or "").count("M ") >= 2
expected_custom_shapes += len(paths)
(svg_output / f"{index:02d}_{name}.svg").write_text(
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1280 720" '
'data-pptx-page-role="content">'
'<rect x="0" y="0" width="1280" height="720" fill="#FFFFFF"/>'
f"{fragment}</svg>\n",
encoding="utf-8",
)
non_scaling = ET.fromstring(
run_tool(
"shape_boolean_svg.py", "render", source, "--operation", "union",
"--source", "non-scaling", "--source", "non-scaling-cut",
"--id", "result-non-scaling",
)
)
assert non_scaling.get("stroke-width") == "5"
assert non_scaling.get("stroke-dasharray") == "10 4"
assert non_scaling.get("vector-effect") == "non-scaling-stroke"
rejections = [
("union", "body", "open", "open subpath"),
("union", "body", "clipped", "uses clip-path"),
("union", "body", "imported", "PPTX import/round-trip metadata"),
("union", "body", "dashoffset", "stroke-dashoffset"),
("intersect", "body", "far", "produced no filled area"),
("subtract", "body", "missing-font", "cannot resolve an installed font"),
("subtract", "body", "nested-text", "child content is unsupported"),
]
for operation, first, second, expected_error in rejections:
rejected = subprocess.run(
[
sys.executable,
str(scripts / "shape_boolean_svg.py"),
"render", str(source), "--operation", operation,
"--source", first, "--source", second,
"--id", f"reject-{second}",
],
capture_output=True, text=True,
)
assert rejected.returncode != 0
assert expected_error in rejected.stderr, rejected.stderr
run_tool(
"svg_quality_checker.py", project,
"--quick-generate", "--format", "ppt169",
"--stage", "final", "--json",
)
pptx = project / "boolean-smoke.pptx"
run_tool("svg_to_pptx.py", project, "--quick-generate", "-o", pptx)
with zipfile.ZipFile(pptx) as archive:
slides = [
name
for name in archive.namelist()
if re.fullmatch(r"ppt/slides/slide\d+\.xml", name)
]
custom_shapes = sum(
archive.read(name).count(b"<a:custGeom>")
for name in slides
)
assert len(slides) == len(operations), slides
assert custom_shapes == expected_custom_shapes
readback = project / "readback"
run_tool(
"pptx_to_svg.py", pptx, "-o", readback,
"--inheritance-mode", "flat", "--strict",
)
slides = sorted((readback / "svg").glob("slide_*.svg"))
readback_custom_shapes = sum(
slide.read_text(encoding="utf-8").count('data-pptx-custgeom="')
for slide in slides
)
assert len(slides) == len(operations), slides
assert readback_custom_shapes == expected_custom_shapes
print(
f"Shape Boolean smoke: passed "
f"({expected_custom_shapes} custom shapes; {project})"
)
PY
The seven inline negative cases must return nonzero and match their expected
errors; every other command must pass. Open the printed
boolean-smoke.pptx path in PowerPoint: both shape-cut and text-cut Subtract
results must have real holes, and every Fragment sibling must remain separately
selectable.
compact_svg_coordinates.py
Compact safe model-facing page-space coordinates without rewriting unrelated SVG formatting:
python3 scripts/compact_svg_coordinates.py <svg-file-or-directory>
python3 scripts/compact_svg_coordinates.py <template-directory> \
--inplace --keep-native-frames
The default run is a dry-run JSON report. --inplace atomically replaces only
changed SVG files. The shared create-template final pass uses
--keep-native-frames: it compacts data-pptx-bounds, translation values,
rotation centers, and
matrix e/f, while preserving canonical
authored-preset or inline native frames. svg_authoring_view.py separately
compacts imported model-facing frames because unchanged mirror refs can recover
their exact coordinates from immutable lossless backing.
The compactor never rounds path/points geometry, normalized crop or nested
viewBox ratios, gradient offsets, opacity, scale arguments, rotation angles,
or matrix a/b/c/d coefficients. Type A mirror materialization invokes the
same compactor before native-record externalization; standard and fidelity
use the shared final pass before template validation.
extract_svg_assets.py
Factor large vector subtrees out of lightweight authoring IR documents and
replace them with compact <use data-icon> references:
python3 scripts/extract_svg_assets.py <layered_svg_dir> \
--icons-dir <icons_dir> --icon-namespace imported \
--inplace --id-prefix layered
python3 scripts/extract_svg_assets.py <flat_svg_dir> \
--icons-dir <icons_dir> --icon-namespace imported \
--reuse-inventory <layered_inventory.json> \
--inplace --id-prefix flat
The first pass records a source fingerprint before namespacing each extracted
asset's internal ids. The second pass reuses a fingerprint-matched asset and
writes no duplicate SVG file. Unmatched flat-only subtrees still extract
normally. Use --clean-stale on both import-workspace passes to remove stale
generated files for their respective prefixes. In create-template workspaces,
imported is the fixed namespace: assets live once under icons/imported/, and
the working SVGs reference them as data-icon="imported/<name>". Inventory
entries retain source refs from each extracted subtree, allowing expansion to
reconnect the authoring-manifest mapping. A rerun on an
already rewritten namespaced projection inventories those references and does
not progressively extract their remaining parent or sibling geometry. An
in-place pass over an authoring bundle refreshes authoring_summary.json
automatically.
mirror_template_materialize.py
Compile one Type A PPTX import workspace into a deterministic structured mirror template after the layered authoring IR has been reviewed and edited:
python3 scripts/mirror_template_materialize.py \
<import_workspace> <empty_template_workspace>
The command treats <import_workspace>/authoring-svg/ as the sole editable
source. It reads the tool-only layered authoring manifest internally and
validates it against immutable lossless SVG
hashes, source PPTX hash, complete Master/Layout/Slide graph, inheritance
visibility facts, source-ref closure, and extracted-vector inventory before it
writes anything. It refuses a non-empty destination and stages the whole result
before atomic publication, so a failed preflight cannot leave a partial
template.
Materialization preserves source page order and emits one definition-only
layout_<layout_key>.svg for every source Layout unused by all source Slides.
It mechanically expands fixed Master/Layout group wrappers into direct atoms,
rehydrates only unchanged converter-supported Slide-local/slot refs, keeps the
current SVG fallback for edited refs, preserves explicit text hard breaks, and
removes every IR-only source ref. Imported axis-flipped groups retain their
geometry reflection while descendant SVG text receives a matching
counter-reflection, preserving PowerPoint's upright glyph appearance in browser
previews. Supported opaque p:txBody,
relationship-free p:style, and a:custGeom payloads are deduplicated into
templates/native_payloads.json.gz. Repeated native restoration attributes
are stored there as short data-pptx-native-ref records; page and
imported-vector SVGs retain only those record ids and content-hash payload
references. The native record referenced by an imported text placeholder
carrier owns its authoritative source frame, so the Slide-local frame can
differ from reusable Layout bounds without restoring long exact coordinates
inline. Structural Master/Layout, placeholder, layer, and editable-object
fields remain inline. Source p:sldLayout@showMasterSp and
p:sld@showMasterSp facts become canonical root
data-pptx-show-master-shapes and
data-pptx-show-inherited-shapes booleans.
Checker, template-structure validation, and export hydrate both store layers in memory; legacy inline payload and v1 payload-only stores remain readable.
The published ppt-master.template-execution-manifest.v1 roster points to one
compact ppt-master.template-text-slots.v2-min sidecar per prototype. Each text
slot contains only selector, role, current_text, text_segments, and
tspan_count; a top-level tool hash covers its selectors and immutable
text/tspan topology and attributes. These records are deterministic tool
diagnostics, not page-authoring inputs. Page-context emits only the complete
prototype's path and SHA for that reference, so the model reads the SVG once
per execution context and reuses it until the SHA changes. The model chooses
semantics and edits only existing visible text values, while checker and
structured export validate output attributes, text/tspan topology, and
referenced-resource hashes against
the prototype.
The output routes reusable vectors once to icons/imported/, bitmaps to
images/, and other referenced files to templates/assets/. The JSON report
reports payload occurrence, native-record, unique-byte, and compressed-store
counts and is written to stdout only. The command intentionally does not create
templates/design_spec.md; Template_Designer writes the package-specific rules
and page roster after materialization. This compiler is for Type A mirror materialization,
not standard / fidelity, loose Type B SVGs, ordinary generation, finalize,
or export.
extract_svg_pictures.py
Normalize one deliberately selected complex SVG object into one PowerPoint
picture. The command accepts exact <g id> values only, writes each group as a
tight standalone SVG asset, embeds its local image/CSS dependencies, and
replaces the source group at the same parent index with one <image>. Native
export therefore emits one p:pic backed by SVG media.
python3 scripts/extract_svg_pictures.py \
"<workspace>/authoring-svg/<layered_svg_file>.svg" \
--select "<group_id>" \
--resource-root "<workspace>" \
--images-dir "<workspace>/picture-assets" \
--inplace
Imported PowerPoint groups normally provide data-pptx-frame, which is used
as the picture bounds. For a large standalone SVG without frame metadata, the
tool measures the selected group with Playwright; use repeated
--bounds ID=x,y,width,height values when browser measurement is unavailable
or when effect overflow needs an explicit frame. --padding expands the
chosen bounds. The generated *_picture_asset_inventory.json records the
bounds source, asset hash, copied definition ids, and embedded local resources.
Nested selections are accepted only through metadata-only <g> ancestors.
When an ancestor carries a transform, style, clip, opacity, or other visual
attribute, select that outer group instead; this prevents applying the ancestor
effect once inside the SVG asset and again to the replacement <image>.
Scripts, foreignObject, SVG animation, remote resources, and external SVG
fragment references fail closed; local image/CSS resources must stay inside
the declared --resource-root and are embedded into the asset.
An in-place rewrite inside an authoring bundle refreshes
authoring_summary.json automatically.
This operation belongs only to an explicit create-template normalization
decision in standard or fidelity mode. It does not choose groups, detect
repetition, infer a Master/Layout, or run during ordinary import, free
generation, mirror materialization, finalize, or export. Placeholder, native
single-shape, table/chart, icon-placeholder, and authored-preset groups are
rejected because they already own a different semantic route.
Do not confuse this tool with extract_svg_assets.py:
extract_svg_assets.pyis a model-readability optimization. It replaces heuristic vector runs with<use data-icon>, then re-inlines them before export so the PPTX still contains native shapes.extract_svg_pictures.pyis an explicit representation change. It replaces only named groups with<image>, so each result intentionally remains one editable PowerPoint picture rather than individually editable paths.
Recommended Pipeline
Run these steps one at a time. Wait for each command to exit successfully before starting the next command.
When the effective Speaker Notes outcome in design_spec.md §I is enabled, run:
python3 scripts/total_md_split.py <project_path>
After total_md_split.py exits successfully, run:
python3 scripts/finalize_svg.py <project_path>
After finalize_svg.py exits successfully, run:
python3 scripts/svg_to_pptx.py <project_path>
When Speaker Notes is disabled, skip total_md_split.py and use
python3 scripts/svg_to_pptx.py <project_path> --no-notes for the final
command. This prevents stale files under notes/ from being embedded.
Do not start another post-processing command while the current command is still
running. The canonical gates and success criteria are owned by
generate-pptx.md Step 7.
finalize_svg.py
Unified post-processing entry point. This is the preferred way to run SVG cleanup.
It aggregates:
embed_icons.py- static same-document
<use>expansion fromsvg_to_pptx/use_expander.py align_embed_images.py(crop-images/fix-aspect/embed-imagesaliases route here)flatten_tspan.py
svg_final/ remains a required Step 7.2 artifact even though the native exporter reads svg_output/. It is the self-contained visual reference and may be manually inserted as an SVG picture.
svg_to_pptx.py
Convert project SVGs into PPTX.
python3 scripts/svg_to_pptx.py <project_path>
# Explicit compact image export:
python3 scripts/svg_to_pptx.py <project_path> --image-sizing display --image-scale 2 --image-quality 85
# Force original image bytes:
python3 scripts/svg_to_pptx.py <project_path> --no-image-optimize
python3 scripts/svg_to_pptx.py <project_path> --native-charts-and-tables
python3 scripts/svg_to_pptx.py <project_path> --pptx-structure structured # deck/layout template override
python3 scripts/svg_to_pptx.py <project_path> --pptx-structure flat # free-design/brand-only override
# Template-import visual round-trip diagnostic only:
python3 scripts/svg_to_pptx.py <template_import_output> -s svg-flat
# Post-processed-source comparison diagnostic only (never a release export):
python3 scripts/svg_to_pptx.py <project_path> -s final
python3 scripts/svg_to_pptx.py <project_path> --no-notes
python3 scripts/svg_to_pptx.py <project_path> -t none
python3 scripts/svg_to_pptx.py <project_path> --auto-advance 3
python3 scripts/svg_to_pptx.py <project_path> --animation mixed --animation-duration 0.8
python3 scripts/svg_to_pptx.py <project_path> --reflow-text # opt-in PowerPoint reflow
python3 scripts/svg_to_pptx.py <project_path> --no-merge # one text frame per visual line
python3 scripts/svg_to_pptx.py <project_path> --recorded-narration audio
python3 scripts/svg_to_pptx.py <project_path> --recorded-narration audio --animation-config animations.json
python3 scripts/svg_to_pptx.py <project_path> --recorded-narration audio --no-animations
Native image export defaults to --image-sizing cap: it preserves source bytes
when no resize or EXIF geometry normalization is required, and re-encodes only
images that require one of those transformations. The display command above
is an explicit compact export; --no-image-optimize disables all native image
optimization and forces original bytes.
The normal command reads pptx_structure.mode from spec_lock.md. For legacy
projects whose lock exists but predates that field, export emits one compatibility
warning and uses flat; no SVG regeneration is required. A missing spec_lock.md,
an explicit legacy/unknown mode, or a requested structured export without an
explicit current structured contract remains blocking.
Explicit direct generation may use the
quick-generate profile after the
current agent has converted/read sources, researched identified factual gaps,
and prepared the required images, icons, formulas, and resource manifests as
needed. That profile skips Strategist, Confirm UI, design_spec.md, and
spec_lock.md; it does not skip the resources required by the authored pages.
After the complete SVG roster exists, run its lockless final checker, then
export:
python3 scripts/svg_quality_checker.py <project_path> \
--quick-generate --stage final --json
python3 scripts/svg_to_pptx.py <project_path> --quick-generate
This direct-export flag takes svg_output/ as its authored page source, resolves
valid project-local resources referenced by those pages, infers one consistent
canvas, uses flat converter-default package scaffolding, and does not read or
require spec_lock.md. Notes, motion, narration, native objects, conversion
trace, and other ordinary exporter capabilities remain available; notes,
custom object animation, and narration start off in Quick and may be enabled
when needed. The exporter refuses a missing, blocking, non-final, or stale
Quick final report before PPTX creation. Default-path output retains the normal
postflight report and backup/ snapshot; explicit -o retains the ordinary
no-backup behavior. Existing source, analysis, image/icon/formula, and
resource-manifest artifacts remain untouched.
For generated-project narration, follow the
generate-audio stage. It owns voice
selection, audio generation, and the narrated re-export workflow.
Behavior:
- Default output (either Generate profile, no
-o):exports/<project_name>_<timestamp>.pptx— native editable pptx (canonical output)validation/<project_name>_<timestamp>.report.json— package postflight, quality-gate linkage, unresolved resource audit, and published part countsbackup/<timestamp>/svg_output/— copy of authored SVG source for re-export without re-running the LLM
exports/contains only final PPTX deliverables; machine-readable quality and postflight reports belong invalidation/.- The default Generate flow always runs
finalize_svg.pybefore export. This directory is the self-contained SVG visual preview; it is not packaged as a second PPTX. Quick-generate deliberately skips it. - In both Generate profiles, explicit
-o/--outputchanges the native PPTX destination and skipsbackup/; the postflight report still uses the output stem under the projectvalidation/directory. - Postflight reruns ZIP integrity and published Slide count. Internal relationships,
structured-package validation, transitions, and animations are enforced before the
builder publishes the PPTX and are reported as
enforced-at-build, not as repeated postflight checks. font_portabilitywarns when a complete font stack has no concrete family or when the converter resolves its Latin / East Asian role to a typeface that normally requires a custom installation. A recommended stack such as"Microsoft YaHei", Arial, sans-serifdoes not warn merely because it ends with a generic fallback.- Multiline text export modes:
- Default: one editable frame retains authored breaks and disables PowerPoint wrapping. An ordinary generated frame uses PowerPoint's native resize-shape-to-fit-text behavior, so deleting a retained break expands the frame instead of leaving text outside it; imported exact frames and structured multiline placeholder carriers retain fixed-size behavior.
--reflow-text: eligible same-size lines become flowing prose that PowerPoint may rewrap; a font-size change, list marker, or accepted larger gap remains a paragraph boundary. Legacy--merge-paragraphsaliases this mode.--no-merge: each dy-stacked line becomes an independent frame with its own placement.- Detection is conservative: mixed-layout
<text>falls back to per-line frames. Use--reflow-textonly for resizable body copy and--no-mergeonly for independent line objects or absolute line positions.
- Native release export reads
svg_output/.-s finalis an explicit diagnostic override for comparing conversion behavior against post-processed SVGs; it does not change artifact ownership or create a supported release path. svg_final/may be opened directly or inserted into PowerPoint as an SVG picture. PowerPoint's manual Convert-to-Shape operation is outside the compatibility contract.- On every SVG-authoring route, each file in
svg_output/is the complete visible page-design source. Templates and locks may guide authoring, but finalize/export never use them to overlay visible content missing from the SVG. Notes, animation, narration, transitions, and direct native-PPTX workflows keep their separate inputs and package-level processing. - For PPTX template-import workspaces, use
-s svg-flatwhen you need a visual round-trip check. The layeredsvg/tree is the machine-readable template source and intentionally does not inline inherited master / layout decoration into each slide. - 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-structurereadsspec_lock.md. Free-design, brand-only, andtemplate_reuse_scope: stylereleases declaremode: 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 usemode: structuredonly fortemplate_reuse_scope: mirror|layout, with complete uniquepptx_masters/pptx_layoutsrosters and onepage_pptx_layoutsassignment 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 bypreset_shape_svg.pyis the sole group exception because it compiles to one native shape. - Every visible direct root
<g>requires root-coordinatedata-pptx-bounds; nested bounds are ignored. Frame/native metadata never replaces it; placeholder bounds also define the slot frame. Checker compares root bounds withviewBox, descendant text with its module using DrawingML wrapping headroom, and every estimable visible text carrier directly with the rootviewBoxbefore that headroom. Images, shapes, paths,<use>, effects, and object frames are excluded from module containment. Per side, ≤1pxis 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 withdata-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. Compositeobjectslots 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.
- Template
page_layoutsremains input provenance. Strict preserves the prototype contract; adaptive retains its Master and may use a new Layout identity only when Strategist declared it in the plan and lock. Construction cannot allocate or mutate Layout identity downstream. - Legacy structured/template contracts using
baseline,template,preserve,layout_strategy,data-pptx-layout-kind,distilled/utility, direct atomic placeholders, or incomplete Master identity are rejected with a pointer tocreate-template. Create a new workspace and generate new structured SVG pages; do not upgrade the existing project in place. Explicit flat free-design/brand-only projects intentionally omit Master identity. - Native output uses content-hash media filenames, so identical images are reused and different images cannot overwrite each other by sharing a basename.
[Content_Types].xmlis generated from the actual media extensions written into the PPTX. Unknown media extensions fail unless Python'smimetypescan identify them.- Native export writes to a temporary file first and publishes the requested PPTX only after conversion succeeds. A failed conversion does not replace the main output file.
--conversion-tracewithout a path writesvalidation/<output_stem>.trace.json.--conversion-trace <path>respects the explicit destination; relative paths are resolved from the project root, soexports/<name>.trace.jsonremains available when intentionally requested.- Formal default and
--quick-generaterelease export compute the exact SVG source fingerprint and refuse a missing, unreadable, unsupported, non-final, blocking, stale, or unverifiable final quality report before PPTX creation. A project withoutvalidation/svg_quality_report.jsonexits nonzero with thenot-providedgate status; run the final checker against its currentsvg_output/first. An explicit non-output--sourceremains a diagnostic override and bypasses this release gate; postflight still records any verifiable report linkage. - After publication, native export writes
validation/<output_stem>.report.json. The report distinguishes authored Slides from internal Layout definitions, reruns ZIP integrity and published Slide-count checks, records slide/layout/master/notes part counts, labels relationship/structured/transition/animation validation as enforced at build time, links the final SVG quality report only when its SHA-256 source fingerprint matches the exact export inputs, and surfaces stale/unverified gates, unresolved template tokens, generic-only font stacks, and external image references. A matching final quality report with introduced warnings yieldspassed-with-warningsand aquality_introduced_warnings=<N>receipt instead of a cleanpassedclaim. - By default, a successful command also prints a compact receipt instead of requiring a report read:
[POSTFLIGHT] status=<...> quality_gate=<...> slides=<N> warning_categories=<N>, followed by one compact line per warning category and the[PPTX]/[REPORT]paths. Resource-warning lines carry counts; a non-passing quality gate carries its status. Routine agents use this receipt and do not load either complete validation JSON into model context. Full reports remain cold audit artifacts; failure investigation and explicit audits extract only the required fields.--quietkeeps suppressing successful-run output. - Before publishing structured template output, export reopens the temporary PPTX and validates the Slide → Layout → Master graph and registrations, Layout identity, placeholder identity, reusable bounds, and prompt/level-one sizes. A mismatch aborts publication. Flat release instead validates its single referenced Master/Layout shell and exact date/footer/slide-number hook roster before packaging.
- Authored SVG clip-path restrictions remain. Crop wrappers use an overflow-hidden viewport; preview-safe shape clips target the inner image in viewBox coordinates, while legacy imported wrapper clips remain compatible. Both map to native picture crop/geometry when possible.
- The default Generate flow embeds speaker notes automatically unless
--no-notesis used; Quick Generate defaults them off and enables them with--with-notes - Recorded narration is opt-in:
notes_to_audio.pyusesedge-ttsby default, or a configured cloud TTS provider (elevenlabs,minimax,qwen,cosyvoice), and generates one audio file per slide intoaudio/- Narration text is read strictly from the matching
notes/*.mdfile; the script only skips Markdown heading lines (# ...) and does not summarize, rewrite, or filter delivery notes --recorded-narration audioprepares PowerPoint's "recorded timings and narrations": every slide must have matchingm4a/mp3/wavaudio,ffprobemust read every duration, and--animation-trigger on-clickis rejected--recorded-narration audiokeeps speaker notes, embeds each matching audio file, and writes slide auto-advance timings from page-start lead-in + audio duration + page-tail padding.--narration-start-floorand--narration-paddingare independent optional seconds; their defaults are0.8and0.5, and the post-transition lead-in ismax(0, start floor - transition duration)- While motion remains enabled, narrated export without an explicit
--animation-configselects<project>/narration_animations.jsonwhen either animation sidecar exists; canonical-only cue synchronization therefore blocks until the derived file exists. Narration-independent custom motion explicitly passes--animation-config animations.json, even when a derived sidecar also exists - Without animation sidecars, Generate narration may inherit base-report deck motion via
--inherit-motion-from; direct low-level omission keeps legacyfade/ no object builds. Use--no-animationsto remove object/page motion while retaining narration timings - Non-narrated export keeps the existing optional
<project>/animations.jsondefault - Narration timing merges into the existing slide timing DOM. While motion remains enabled, object-animation rows and the resolved page transition are preserved rather than regenerated; inherited
-a nonesuppresses object rows, and--no-animationsremoves both motion layers --narration-audio-dir audiois the lower-level embedding path: it embeds whatever files match and allows partial audio coverage- Either narration flag names the default-flow export
<project_name>_<timestamp>_narrated.pptx, telling it apart from silent exports in the same directory - This is intended for direct PowerPoint video export with "Use recorded timings and narrations"
- Long-audio import and automatic long-audio splitting are not supported; keep narration assets page-level
- Voice choices can be listed with
python3 scripts/notes_to_audio.py --list-common-voices,python3 scripts/notes_to_audio.py --list-voices --locale zh-CN, or provider-specific--provider <name> --list-voices
- Page transitions are controlled by
-t/--transition; per-element object animations are controlled by-a/--animation - Per-element animation applies to ordinary top-level SVG
<g id="...">groups; each group is a PowerPoint shape-target anchor, not necessarily one Animation Pane row. Use one group per logical Slide-local content unit rather than targeting a group count. Master/Layout atoms and slot groups are structural and excluded; exact id tokens remain a fallback only when explicit structural roles are absent - An explicit
animations.jsongroup entry may override the marker-free legacy chrome-name heuristic. It cannot overridedata-pptx-layeror an explicit static role/placeholder marker - Start mode is set globally by
--animation-trigger, mirroring PowerPoint's Start dropdown:after-previous(default, cascade with--animation-staggerspacing on slide entry),on-click(presenter-paced), orwith-previous(all together on slide entry). A sidecar row may override it withtrigger; the slide value is only the inherited Start mode on-clickis for live presentations only; recorded narration rejects every row that resolves to it, including a row withtrigger_shape, because the tool does not generate object-level click timings- Flat SVG roots without top-level groups fall back to at most 8 visible primitives; beyond that, animation is skipped on the slide
- Per-element animation defaults to
none.autois opt-in (-a auto) and maps generic entrance effects from the group's SVG id: information-dense elements get a stable entrance (chart→wipe, card-/step-/pillar-→fly, title/takeaway→fade); image-like and unmatched ids rotate through bounded entrance pools. mixed(legacy) deterministically rotates through the canonical entrance pool;randomselects from the same entrance pool with a stable seed from the effective deck input.auto,mixed, andrandomnever choose emphasis, motion-path, or exit effects; select an explicit canonicalentrance_*,emphasis_*,path_*, orexit_*key for those authored duties.--conversion-tracerecords each resolved effect when enabled--animation-durationcontrols the inherited per-row schedule length (default0.4); scalable native effects preserve internal timing ratios, while instantaneous presets keep their authored duration.--animation-staggersupplies the default gap between successive non-trigger-shape rows inafter-previousmode (default0.5)- Optional object-level overrides live in
<project>/animations.jsonor a path passed via--animation-config; build and validate them withanimation_config.py scaffold|validate. The scaffold is neutral (defaults.animation.effect: none, untouched groups{}). A populated group uses either the fully compatible legacy single-effect fields or a non-emptyeffects[], never both; everyeffects[]row names an explicit effect - Transition/object sound remains off by default. After SVG and visual motion are complete, discover bundled ids with
sound_sync.py list [--query <term>]and copy only selected ids withsound_sync.py <project> <namespace>/<sound_id> [...].transition.soundreferences a project-relative.wav; object-animationsoundaccepts the existing.m4a/.mp3/.wavpath contract, while bundled selections use the synced project-relative.wav. With no selected cue, do not create<project>/sounds/. Export never resolves ids or readstemplates/sounds/directly - One
effects[]row becomes one Animation Pane record on the group's shape target. Each row may independently set sequenceorder,delay,duration,trigger, andtrigger_shape; ordinary rows use page-wide order, whiletrigger_shaperows keep relative order in separate interactive sequences and implyon-click - Animation configuration is strict: unknown effects/modes/triggers, invalid finite/range/order values, missing slides/groups, and structural-layer targets fail export without fallback or silent omission
- Generated export reads every slide back and verifies animation row order, including repeated rows on one shape target, trigger, shape target, resolved effect tuple and native behavior signature, duration, and offset. Package validation then checks timing placement,
p:cTnids, andp:spTgtreferences before publication - The animation writer does not emit paragraph/text-range builds (
p:bldP), custom freeform motion paths, native Chart/SmartArt build sequences, or media playback commands for grouped SVG content. Direct-PPTX routes preserve source object animation and perform structural package validation only; they do not author effects - The full registry, OOXML rules, and compatibility boundary are documented in
pptx-animations.md
Dependency:
pip install python-pptx
total_md_split.py
Split total.md into per-slide note files.
python3 scripts/total_md_split.py <project_path>
python3 scripts/total_md_split.py <project_path> -o <output_directory>
python3 scripts/total_md_split.py <project_path> -q
Requirements:
- Each section begins with
# - Heading text matches the SVG filename
- Sections are separated by
---
svg_quality_checker.py
Validate SVG technical compliance.
python3 scripts/svg_quality_checker.py examples/project/svg_output/01_cover.svg
python3 scripts/svg_quality_checker.py examples/project/svg_output
python3 scripts/svg_quality_checker.py examples/project
python3 scripts/svg_quality_checker.py examples/project --stage first-page
python3 scripts/svg_quality_checker.py examples/project --stage final --json
python3 scripts/svg_quality_checker.py examples/project --format ppt169
python3 scripts/svg_quality_checker.py --all examples
python3 scripts/svg_quality_checker.py examples/project --export
python3 scripts/svg_quality_checker.py path/to/template/templates --template-mode
Checks include:
viewBox- banned elements
- paint compatibility: unsupported values error; supported non-default spellings such as
rgba()receive non-blocking recommendations for#RRGGBBplus explicit alpha - line-break structure
- explicit Master/Layout/slot structure for reusable templates
- duplicate empty Layout contracts under different keys
Warnings are advisory: they require no modification or acknowledgement and do not affect the command's zero exit status. Only errors block the quality gate.
--stage first-page resolves only the first authored SVG and permits an incomplete
future page roster. --stage final checks the complete project. With --json,
the final stage writes validation/svg_quality_report.json, while the first-page
stage writes validation/svg_quality_first_page_report.json so it cannot overwrite
the release gate (or use --json-output). The report separates
release failures (blocking), changed/new advisories (introduced),
prototype-identical diagnostics (inherited), and source-conversion losses
(source-import). It also fingerprints every checked SVG so postflight cannot
mistake a stale report for the current export gate. On a successful run, use the
checker exit status and terminal summary; do not load the complete JSON unless a
failure investigation or explicit audit requires targeted fields.
Template mode accepts the same compact canonical preset groups as generated
pages: one atomic <g data-pptx-authoring="preset"> with direct visible paths.
It validates those paths dynamically against the locked registry and does not
require an import-style carrier, preview wrapper, fingerprint, or a separate
source-payload opt-in marker. Exact syntax remains owned by the linked
standards rather than this pipeline overview.
svg_position_calculator.py
Analyze and review supported chart coordinates after SVG generation.
Use this after svg_quality_checker.py passes, and only for chart types supported by this script: bar, pie / donut, radar, line / area / scatter, and grid. Area charts do not have a separate calculator mode: use calc line for the upper boundary points, then close the filled region to the plot area's bottom baseline (y_max) in the SVG.
Calculate expected coordinates
python3 scripts/svg_position_calculator.py calc bar --data "A:185,B:142" --area "130,155,1200,480" --bar-width 120
python3 scripts/svg_position_calculator.py calc line --data "0:50,10:80,20:120" --area "120,120,1200,600" --y-range "0,150"
python3 scripts/svg_position_calculator.py calc pie --data "A:35,B:25,C:20" --center "420,400" --radius 200
python3 scripts/svg_position_calculator.py calc grid --rows 2 --cols 3 --area "50,150,1230,670"
For an area chart, use the line output as the top boundary:
M first_x,first_y ... L last_x,last_y L last_x,y_max L first_x,y_max Z
Manually compare the calculator output with the coordinates already present in the generated SVG. If coordinates differ, update the SVG from the calc output, rerun svg_quality_checker.py, then repeat the coordinate review. The tool intentionally does not rewrite SVG files automatically.
Analyze (inspect existing SVG)
python3 scripts/svg_position_calculator.py analyze <svg_file>
Use this after SVG generation to inspect existing SVG geometry when manual comparison needs more context.
Advanced Standalone Tools
flatten_tspan.py
python3 scripts/svg_finalize/flatten_tspan.py examples/<project>/svg_output
python3 scripts/svg_finalize/flatten_tspan.py path/to/input.svg path/to/output.svg
align_embed_images.py
python3 scripts/svg_finalize/align_embed_images.py path/to/slide.svg
python3 scripts/svg_finalize/align_embed_images.py --dry-run path/to/slide.svg
Use for rare single-file diagnostics when image slice / meet alignment and
Base64 embedding must be inspected outside finalize_svg.py. In normal project
runs, use python3 scripts/finalize_svg.py <project_path>; the old
crop-images, fix-aspect, and embed-images names remain accepted only as
finalize_svg.py --only aliases for the merged align-images step.
embed_icons.py
python3 scripts/svg_finalize/embed_icons.py output.svg
python3 scripts/svg_finalize/embed_icons.py svg_output/*.svg
python3 scripts/svg_finalize/embed_icons.py --dry-run svg_output/*.svg
Replaces <use data-icon="chunk-filled/name" .../>, <use data-icon="tabler-filled/name" .../> and <use data-icon="tabler-outline/name" .../> placeholders with actual SVG path elements. Use for manual icon embedding checks outside finalize_svg.py.
SVG Compatibility Contract
The always-on SVG authoring contract lives in
shared-standards-core.md, with
advanced effects, native data objects, and structured PPTX metadata owned by
their conditionally loaded modules. This tool guide does not repeat accepted
syntax, rejected constructs, or conditional limits.
svg_quality_checker.py validates source SVG before finalization.
finalize_svg.py and native export apply the preprocessing required by that
contract, while native conversion fails on unsupported visual elements rather
than silently dropping them.