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-pipeline): enforce compact mirror and native-data authority
hugohe388d3c60c8fe8
diff --git a/skills/ppt-master/scripts/mirror_template_materialize.py b/skills/ppt-master/scripts/mirror_template_materialize.pyindex 547e3b71..efc2710f 100644--- a/skills/ppt-master/scripts/mirror_template_materialize.py+++ b/skills/ppt-master/scripts/mirror_template_materialize.py@@ -4,8 +4,9 @@ PPT Master - Mirror Template MaterializerMaterialize a deterministic structured SVG template workspace from one Type APPTX import workspace. The editable authoring IR is the only authoring input;-lossless SVG files are consulted solely to restore unchanged supported source-objects. Final templates and imported vectors contain no IR-only source refs.+lossless SVG files are consulted solely to validate source identity and recover+small non-visible semantics. Final templates keep the compact authoring tree and+contain no IR-only source refs.Usage:python3 scripts/mirror_template_materialize.py \@@ -213,6 +214,8 @@ class SlotPlan:@dataclassclass RestorationStats:+ # Retained for report compatibility. Mirror materialization no longer+ # rehydrates visible source subtrees, so this counter remains zero.rehydrated_refs: int = 0fallback_refs: int = 0structural_refs: int = 0@@ -1149,16 +1152,16 @@ def _absolutize_local_hrefs(root: ET.Element, base_dir: Path) -> None:)-def _rehydrate_tree(+def _validate_authoring_tree(root: ET.Element,document: AuthoringDocument,*,excluded_refs: set[str],) -> RestorationStats:- source_root = _parse_svg(document.source_path)+ """Inspect source-ref hashes while preserving the compact authoring tree."""stats = RestorationStats()- def restore(element: ET.Element) -> ET.Element:+ def validate(element: ET.Element) -> None:source_ref = element.get(SOURCE_REF_ATTRIBUTE)record = document.source_refs.get(source_ref or "")contains_semantic_object = any(@@ -1169,35 +1172,24 @@ def _rehydrate_tree(raise MirrorMaterializationError(f"{document.name} contains unknown source ref {source_ref!r}")- if source_ref and source_ref in excluded_refs:- stats.structural_refs += 1- elif source_ref and contains_semantic_object:- stats.semantic_refs += 1- elif source_ref and record is not None:+ if source_ref and record is not None:actual_hash = semantic_subtree_sha256(element,ignored_attributes=frozenset({SOURCE_REF_ATTRIBUTE}),)- if actual_hash == record.initial_authoring_subtree_sha256:- restored = copy.deepcopy(_source_element(source_root, record.source_path))- for marker in _fresh_native_fallbacks(restored):- marker.set(_FRESH_NATIVE_FALLBACK_ATTR, "true")- _absolutize_local_hrefs(restored, document.source_path.parent)- stats.rehydrated_refs += 1- return restored- stats.fallback_refs += 1-- children = list(element)- for index, child in enumerate(children):- replacement = restore(child)- if replacement is child:- continue- replacement.tail = child.tail- element.remove(child)- element.insert(index, replacement)- return element+ hash_changed = actual_hash != record.initial_authoring_subtree_sha256++ if source_ref in excluded_refs:+ stats.structural_refs += 1+ elif contains_semantic_object:+ stats.semantic_refs += 1+ elif hash_changed:+ stats.fallback_refs += 1- restore(root)+ for child in element:+ validate(child)++ validate(root)return stats@@ -1345,9 +1337,13 @@ def _prepared_document() -> tuple[ET.Element, RestorationStats]:root = _parse_svg(document.authoring_path)fresh_native_fallbacks = _fresh_native_fallbacks(root)+ stats = _validate_authoring_tree(root, document, excluded_refs=excluded_refs)+ _annotate_unchanged_explicit_text_breaks(+ root,+ document,+ set(document.source_refs),+ )_absolutize_local_hrefs(root, document.authoring_path.parent)- stats = _rehydrate_tree(root, document, excluded_refs=excluded_refs)- _annotate_unchanged_explicit_text_breaks(root, document, excluded_refs)for marker in fresh_native_fallbacks & set(root.iter()):marker.set(_FRESH_NATIVE_FALLBACK_ATTR, "true")return root, stats@@ -2737,8 +2733,8 @@ def _materialize_icon(f"expected {record.expected_sha256}, found {actual_sha256}")root = _parse_svg(record.asset_path)+ stats = _validate_authoring_tree(root, document, excluded_refs=set())_absolutize_local_hrefs(root, record.asset_path.parent)- stats = _rehydrate_tree(root, document, excluded_refs=set())_strip_source_refs(root)return root, statsdiff --git a/skills/ppt-master/scripts/pptx_to_svg/slide_to_svg.py b/skills/ppt-master/scripts/pptx_to_svg/slide_to_svg.pyindex bc3afc2e..92c2ff99 100644--- a/skills/ppt-master/scripts/pptx_to_svg/slide_to_svg.py+++ b/skills/ppt-master/scripts/pptx_to_svg/slide_to_svg.py@@ -2051,6 +2051,7 @@ def _render_graphic_table(result.native_payload["name"] = node.namepayload_metadata = _replacement_payload_metadata(result.native_payload)replacement_attrs.append('data-pptx-replace-with="table"')+ replacement_attrs.append('data-pptx-native-authority="json"')elif result.native_status:replacement_attrs.append('data-pptx-replacement-status="'@@ -2100,6 +2101,7 @@ def _render_graphic_chart()payload_metadata = _replacement_payload_metadata(payload)replacement_attrs.append('data-pptx-replace-with="chart"')+ replacement_attrs.append('data-pptx-native-authority="json"')elif result.native_status:replacement_attrs.append('data-pptx-replacement-status="'diff --git a/skills/ppt-master/scripts/stamp_native_fallbacks.py b/skills/ppt-master/scripts/stamp_native_fallbacks.pynew file mode 100644index 00000000..de07068e--- /dev/null+++ b/skills/ppt-master/scripts/stamp_native_fallbacks.py@@ -0,0 +1,337 @@+#!/usr/bin/env python3+"""+PPT Master - Stamp Native Fallback Baselines++Validate Chart/Table replacement payloads and bind SVG-authoritative markers+to their current visible fallback without reformatting the SVG document.++Usage:+ python3 scripts/stamp_native_fallbacks.py "<svg-or-directory>" [--write]++Examples:+ python3 scripts/stamp_native_fallbacks.py "projects/example/svg_output"+ python3 scripts/stamp_native_fallbacks.py "projects/example/svg_output" --write++Dependencies:+ None (only uses standard library and PPT Master sibling modules)+"""++from __future__ import annotations++import argparse+import os+import re+import stat+import sys+import tempfile+from pathlib import Path+from typing import Optional+from xml.etree import ElementTree as ET+from xml.parsers import expat++from console_encoding import configure_utf8_stdio+from pptx_shapes import NATIVE_FALLBACK_SHA256_ATTR+from svg_to_pptx.native_objects import (+ native_json_is_authoritative,+ native_replacement_kind,+ stamp_native_fallback_baseline,+ validate_native_object_marker,+)+from svg_to_pptx.native_objects.marker_status import native_marker_status_errors+++_FALLBACK_ATTR_BYTES = NATIVE_FALLBACK_SHA256_ATTR.encode("ascii")+_FALLBACK_ATTR_RE = re.compile(+ rb"(?P<prefix>\s" + re.escape(_FALLBACK_ATTR_BYTES) + rb"\s*=\s*)"+ rb"(?P<quote>['\"])(?P<value>.*?)(?P=quote)",+ re.DOTALL,+)+++class NativeFallbackStampError(RuntimeError):+ """Raised when a fallback baseline cannot be validated or patched safely."""+++def _local_name(tag: object) -> str:+ return tag.rsplit("}", 1)[-1] if isinstance(tag, str) else ""+++def _svg_files(input_path: Path) -> list[Path]:+ if input_path.is_file():+ if input_path.suffix.lower() != ".svg":+ raise NativeFallbackStampError(f"Input file is not SVG: {input_path}")+ return [input_path]+ if not input_path.is_dir():+ raise NativeFallbackStampError(f"Input path does not exist: {input_path}")+ files = sorted(+ path+ for path in input_path.glob("*.svg")+ if path.is_file()+ )+ if not files:+ raise NativeFallbackStampError(+ f"Input directory contains no direct SVG files: {input_path}"+ )+ return files+++def _marker_ancestors(+ marker: ET.Element,+ root: ET.Element,+ parent_map: dict[ET.Element, ET.Element],+) -> tuple[ET.Element, ...]:+ ancestors: list[ET.Element] = []+ parent = parent_map.get(marker)+ while parent is not None and parent is not root:+ if _local_name(parent.tag) == "g":+ ancestors.append(parent)+ parent = parent_map.get(parent)+ return tuple(reversed(ancestors))+++def _start_tag_spans(source: bytes) -> list[tuple[int, int, str]]:+ starts: list[tuple[int, str]] = []+ parser = expat.ParserCreate()++ def record_start(name: str, _attrs: dict[str, str]) -> None:+ starts.append((parser.CurrentByteIndex, name.rsplit(":", 1)[-1]))++ parser.StartElementHandler = record_start+ try:+ parser.Parse(source, True)+ except expat.ExpatError as exc:+ raise NativeFallbackStampError(f"Invalid SVG XML: {exc}") from exc++ spans: list[tuple[int, int, str]] = []+ for start, name in starts:+ quote: int | None = None+ cursor = start + 1+ while cursor < len(source):+ token = source[cursor]+ if quote is not None:+ if token == quote:+ quote = None+ elif token in {ord('"'), ord("'")}:+ quote = token+ elif token == ord(">"):+ spans.append((start, cursor + 1, name))+ break+ cursor += 1+ else:+ raise NativeFallbackStampError(+ f"Unterminated start tag at byte offset {start}"+ )+ return spans+++def _patch_start_tag(tag: bytes, digest: str) -> bytes:+ encoded_digest = digest.encode("ascii")+ match = _FALLBACK_ATTR_RE.search(tag)+ if match is not None:+ return tag[:match.start("value")] + encoded_digest + tag[match.end("value"):]+ close = re.search(rb"(?P<space>\s*)(?P<slash>/?)>$", tag)+ if close is None:+ raise NativeFallbackStampError("Unable to locate SVG start-tag terminator")+ insertion = (+ b" "+ + _FALLBACK_ATTR_BYTES+ + b'="'+ + encoded_digest+ + b'"'+ )+ return tag[:close.start()] + insertion + tag[close.start():]+++def _patch_document(+ source: bytes,+ root: ET.Element,+ digests: dict[ET.Element, str],+) -> bytes:+ elements = list(root.iter())+ spans = _start_tag_spans(source)+ if len(elements) != len(spans):+ raise NativeFallbackStampError(+ "Parsed SVG element roster does not match raw start-tag roster"+ )++ patches: list[tuple[int, int, bytes]] = []+ for element, (start, end, raw_name) in zip(elements, spans):+ if _local_name(element.tag) != raw_name:+ raise NativeFallbackStampError(+ "Parsed SVG element order does not match raw start-tag order"+ )+ digest = digests.get(element)+ if digest is None:+ continue+ current_tag = source[start:end]+ replacement = _patch_start_tag(current_tag, digest)+ if replacement != current_tag:+ patches.append((start, end, replacement))++ patched = source+ for start, end, replacement in reversed(patches):+ patched = patched[:start] + replacement + patched[end:]+ return patched+++def _validated_svg_first_digests(+ root: ET.Element,+ path: Path,+) -> tuple[dict[ET.Element, str], int]:+ parent_map = {+ child: parent+ for parent in root.iter()+ for child in parent+ }+ status_errors: list[str] = []+ for element in root.iter():+ if _local_name(element.tag) == "metadata":+ continue+ marker_id = element.get("id") or element.get("data-name") or "<unnamed>"+ status_errors.extend(+ f"{marker_id}: {error}"+ for error in native_marker_status_errors(element)+ )+ if status_errors:+ raise NativeFallbackStampError(+ f"{path.name}: invalid native marker status: "+ + "; ".join(status_errors)+ )++ digests: dict[ET.Element, str] = {}+ json_authoritative = 0+ for marker in root.iter():+ kind = native_replacement_kind(marker)+ if kind not in {"chart", "table"}:+ continue+ marker_id = marker.get("id") or marker.get("data-name") or "<unnamed>"+ try:+ validate_native_object_marker(+ marker,+ ancestors=_marker_ancestors(marker, root, parent_map),+ )+ except RuntimeError as exc:+ raise NativeFallbackStampError(+ f"{path.name}: invalid {kind} marker {marker_id}: {exc}"+ ) from exc+ if native_json_is_authoritative(marker):+ json_authoritative += 1+ continue+ digests[marker] = stamp_native_fallback_baseline(+ marker,+ document_root=root,+ )+ return digests, json_authoritative+++def _atomic_write(path: Path, payload: bytes) -> None:+ mode = stat.S_IMODE(path.stat().st_mode)+ temporary_path: Path | None = None+ try:+ with tempfile.NamedTemporaryFile(+ mode="wb",+ dir=path.parent,+ prefix=f".{path.name}.",+ suffix=".tmp",+ delete=False,+ ) as handle:+ temporary_path = Path(handle.name)+ handle.write(payload)+ handle.flush()+ os.fsync(handle.fileno())+ os.chmod(temporary_path, mode)+ os.replace(temporary_path, path)+ finally:+ if temporary_path is not None and temporary_path.exists():+ temporary_path.unlink()+++def _prepare_file(path: Path) -> tuple[bytes, int, int, bool]:+ source = path.read_bytes()+ try:+ root = ET.fromstring(source)+ except ET.ParseError as exc:+ raise NativeFallbackStampError(f"{path.name}: invalid SVG XML: {exc}") from exc+ digests, json_authoritative = _validated_svg_first_digests(root, path)+ patched = _patch_document(source, root, digests)+ changed = patched != source+ return patched, len(digests), json_authoritative, changed+++def stamp_file(path: Path, *, write: bool) -> tuple[int, int, bool]:+ """Validate and optionally stamp one SVG without reformatting it."""+ patched, svg_authoritative, json_authoritative, changed = _prepare_file(path)+ if write and changed:+ _atomic_write(path, patched)+ return svg_authoritative, json_authoritative, changed+++def build_parser() -> argparse.ArgumentParser:+ parser = argparse.ArgumentParser(+ description=(+ "Validate native Chart/Table payloads and stamp current visible "+ "fallback hashes on SVG-authoritative markers."+ ),+ )+ parser.add_argument(+ "input",+ type=Path,+ help="One SVG file or a directory whose direct *.svg files are checked",+ )+ parser.add_argument(+ "--write",+ action="store_true",+ help=(+ "Atomically update SVG files. Omit for a read-only preview; use only "+ "after visible fallback and embedded JSON were updated together."+ ),+ )+ return parser+++def main(argv: Optional[list[str]] = None) -> int:+ configure_utf8_stdio()+ args = build_parser().parse_args(argv)+ try:+ files = _svg_files(args.input.resolve())+ prepared = [+ (path, *_prepare_file(path))+ for path in files+ ]+ if args.write:+ for path, payload, _svg_first, _json_first, changed in prepared:+ if changed:+ _atomic_write(path, payload)+ total_svg_first = 0+ total_json_first = 0+ changed_files = 0+ for path, _payload, svg_first, json_first, changed in prepared:+ total_svg_first += svg_first+ total_json_first += json_first+ changed_files += int(changed)+ if args.write and changed:+ action = "updated"+ elif changed:+ action = "would-update"+ else:+ action = "unchanged"+ print(+ f"{path}: {action}; SVG-first={svg_first}, JSON-first={json_first}"+ )+ except (NativeFallbackStampError, OSError) as exc:+ print(f"Error: {exc}", file=sys.stderr)+ return 1++ mode = "write" if args.write else "read-only"+ print(+ f"Native fallback baselines: mode={mode}, files={len(files)}, "+ f"changed={changed_files}, SVG-first={total_svg_first}, "+ f"JSON-first={total_json_first}"+ )+ if changed_files and not args.write:+ print("Re-run with --write to apply these validated baseline updates.")+ return 0+++if __name__ == "__main__":+ raise SystemExit(main())diff --git a/skills/ppt-master/scripts/svg_authoring_view.py b/skills/ppt-master/scripts/svg_authoring_view.pyindex c439d82a..dc35a8be 100644--- a/skills/ppt-master/scripts/svg_authoring_view.py+++ b/skills/ppt-master/scripts/svg_authoring_view.py@@ -1131,6 +1131,7 @@ def _source_proxy_element("data-pptx-av-adj1","data-pptx-av-adj2","data-pptx-import-source",+ "data-pptx-native-authority","data-pptx-replacement-status","data-pptx-replace-with","data-pptx-placeholder",diff --git a/skills/ppt-master/scripts/svg_quality/checker.py b/skills/ppt-master/scripts/svg_quality/checker.pyindex f7f45fa9..8798ce66 100644--- a/skills/ppt-master/scripts/svg_quality/checker.py+++ b/skills/ppt-master/scripts/svg_quality/checker.py@@ -230,6 +230,7 @@ try:native_marker_legacy_warnings as _native_marker_legacy_warnings,native_replacement_kind as _native_replacement_kind,native_replacement_status as _native_replacement_status,+ require_fresh_native_fallback as _require_fresh_native_fallback,)except ImportError:_INLINE_FORMULA_ATTR = 'data-pptx-inline-formula'@@ -239,6 +240,7 @@ except ImportError:_native_marker_legacy_warnings = None_native_replacement_kind = None_native_replacement_status = None+ _require_fresh_native_fallback = Nonetry:from svg_to_pptx.native_objects.marker_status import (@@ -4093,6 +4095,7 @@ class SVGQualityChecker:'data-pptx-route-status','data-pptx-replacement-status','data-pptx-native-status',+ 'data-pptx-native-authority','data-pptx-import-source','data-pptx-native-source',)@@ -4199,6 +4202,26 @@ class SVGQualityChecker:for marker in markers:marker_id = marker.get('id') or '<unnamed>'+ replacement_kind = _native_replacement_kind(marker)+ if (+ self.canonical_authoring+ and replacement_kind in {'chart', 'table'}+ ):+ if _require_fresh_native_fallback is None:+ result['errors'].append(+ "Unable to import native fallback freshness validator; "+ f"cannot verify canonical marker {marker_id}"+ )+ else:+ try:+ _require_fresh_native_fallback(+ marker,+ document_root=root,+ )+ except RuntimeError as exc:+ result['errors'].append(+ f"Canonical SVG-first native marker {marker_id}: {exc}"+ )ancestors = []parent = parent_map.get(marker)while parent is not None and parent is not root:diff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml/converter.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml/converter.pyindex 3b784312..a9ac0144 100644--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml/converter.py+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml/converter.py@@ -34,7 +34,6 @@ from resource_paths import icon_dir_for_projectfrom svg_authoring_view import (SEMANTIC_OBJECT_ATTRIBUTE,SEMANTIC_SHAPE_KIND,- SEMANTIC_TABLE_KIND,)from svg_compatibility import normalize_single_child_group_filters@@ -206,13 +205,6 @@ def _native_replacement_enabled(elem: ET.Element, ctx: ConvertContext) -> bool:kind = native_replacement_kind(elem)if kind == 'formula':return True- if (- kind == 'table'- and elem.get(SEMANTIC_OBJECT_ATTRIBUTE) == SEMANTIC_TABLE_KIND- ):- return True- if elem.get('data-pptx-roundtrip-object') == 'source-chart-package':- return kind == 'chart'return ctx.native_objects_enabled and kind in {'chart', 'table'}@@ -974,6 +966,12 @@ def _roundtrip_graphic_frame("""Restore an unchanged relationship-free imported graphicFrame."""if elem.get('data-pptx-roundtrip-object') != 'graphic-frame':return None+ if native_replacement_kind(elem) in {'chart', 'table'}:+ # Eligible data objects follow the public authority/activation route:+ # default export keeps their SVG fallback, while explicit native export+ # rebuilds them from inline JSON. The opaque round-trip payload must not+ # bypass either decision.+ return Noneif elem.get('data-pptx-object') != 'graphic-frame':raise SvgNativeConversionError('round-trip graphic-frame metadata requires '@@ -1860,9 +1858,8 @@ def convert_svg_to_slide_shapes(image_scale: Target image pixels per SVG display pixel.image_quality: JPEG quality used for opaque optimized rasters.native_objects: Convert opt-in ``data-pptx-replace-with`` chart/table- markers to native PowerPoint Chart/Table objects. Formula markers and- semantic authoring tables are intrinsically native. Default off for- other markers.+ markers to native PowerPoint Chart/Table objects. Formula markers+ remain intrinsically native; Chart/Table markers stay off otherwise.animation_group_overrides: Explicit top-level SVG group ids from``animations.json`` that override the legacy chrome-name fallback.Explicit structural layer/role/placeholder markers remain excluded.diff --git a/skills/ppt-master/scripts/svg_to_pptx/native_objects/__init__.py b/skills/ppt-master/scripts/svg_to_pptx/native_objects/__init__.pyindex 229adccc..15138879 100644--- a/skills/ppt-master/scripts/svg_to_pptx/native_objects/__init__.py+++ b/skills/ppt-master/scripts/svg_to_pptx/native_objects/__init__.py@@ -62,10 +62,13 @@ from .marker_common import (native_marker_transform,)from .marker_attributes import (+ JSON_NATIVE_AUTHORITY,+ NATIVE_AUTHORITY_ATTR,NativeMarkerAttributeError,native_fallback_kind,native_import_source,native_metadata_payload_matches,+ native_json_is_authoritative,native_marker_legacy_warnings,native_replacement_kind,native_replacement_status,@@ -86,16 +89,20 @@ __all__ = ["convert_native_object","estimate_inline_formula_vertical_extent","INLINE_FORMULA_ATTR",+ "JSON_NATIVE_AUTHORITY",+ "NATIVE_AUTHORITY_ATTR","NativeMarkerAttributeError","native_fallback_kind","native_import_source","native_metadata_payload_matches",+ "native_json_is_authoritative","native_marker_legacy_warnings","native_object_marker_warnings","native_replacement_kind","native_replacement_status","native_marker_transform","inline_formula_marker_errors",+ "require_fresh_native_fallback","snapshot_native_fallback_freshness","stamp_native_fallback_baseline","validate_native_object_marker",@@ -432,6 +439,16 @@ def _validate_native_object_marker_payload(payload = _load_payload(elem, kind)except NativeMarkerAttributeError as exc:raise RuntimeError(str(exc)) from exc+ if native_json_is_authoritative(elem):+ missing_bounds = [+ key for key in ("x", "y", "width", "height")+ if payload.get(key) is None+ ]+ if missing_bounds:+ raise RuntimeError(+ "JSON-authoritative Chart/Table metadata requires explicit "+ "x/y/width/height; missing " + ", ".join(missing_bounds)+ )bounds_ctx = ctx or _native_marker_validation_context(elem, ancestors)off_x, off_y, ext_cx, ext_cy, _ = _validate_bounds_inputs(elem, payload, bounds_ctx)validated_data: list[list[Any]] | FormulaSpec | None = None@@ -505,6 +522,8 @@ def validate_native_object_marker_with_warnings()if kind in {"chart", "table"} else [])+ if native_json_is_authoritative(elem):+ return warningsif kind == "table" and isinstance(validated_data, list):warnings.extend(_native_table_warnings(elem, validated_data))elif kind == "chart":diff --git a/skills/ppt-master/scripts/svg_to_pptx/native_objects/chart_style.py b/skills/ppt-master/scripts/svg_to_pptx/native_objects/chart_style.pyindex 1bd685fe..3b9ab513 100644--- a/skills/ppt-master/scripts/svg_to_pptx/native_objects/chart_style.py+++ b/skills/ppt-master/scripts/svg_to_pptx/native_objects/chart_style.py@@ -6,7 +6,7 @@ import mathfrom typing import Anyfrom xml.etree import ElementTree as ET-from .marker_attributes import native_import_source+from .marker_attributes import native_import_source, native_json_is_authoritativefrom ..drawingml.context import ConvertContextfrom ..drawingml.utils import (@@ -121,19 +121,32 @@ def _classic_chart_style(inherited_styles: dict[str, str] | None = None,) -> dict[str, str | None]:inherited_styles = inherited_styles or {}- fallback_background = _inferred_chart_background(elem)- text_color = _most_common_color(- _fallback_text_colors(elem, inherited_styles.get("fill"))+ json_authority = native_json_is_authoritative(elem)+ fallback_background = None if json_authority else _inferred_chart_background(elem)+ text_color = (+ None+ if json_authority+ else _most_common_color(+ _fallback_text_colors(elem, inherited_styles.get("fill"))+ )) or "404040"- stroke_colors = _fallback_stroke_colors(elem, inherited_styles.get("stroke"))+ stroke_colors = (+ []+ if json_authority+ else _fallback_stroke_colors(elem, inherited_styles.get("stroke"))+ )darkest_stroke = min(stroke_colors, key=_relative_luminance) if stroke_colors else Nonelightest_stroke = max(stroke_colors, key=_relative_luminance) if stroke_colors else Noneraw_font_face = _chart_style_value(payload, "font_family", "fontFamily", "font_face", "fontFace")- fallback_font_face = _most_common_value(- _fallback_text_attr_values(- elem,- "font-family",- inherited_styles.get("font-family"),+ fallback_font_face = (+ None+ if json_authority+ else _most_common_value(+ _fallback_text_attr_values(+ elem,+ "font-family",+ inherited_styles.get("font-family"),+ )))font_face = str(raw_font_face).strip() if raw_font_face is not None else fallback_font_face@@ -190,6 +203,8 @@ def _chart_text_sizes() -> dict[str, int]:style = payload.get("style") if isinstance(payload.get("style"), dict) else {}inherited_styles = inherited_styles or {}+ if elem is not None and native_json_is_authoritative(elem):+ elem = Nonefallback_font_size = (_most_common_font_size(_fallback_text_attr_values(@@ -485,6 +500,8 @@ def _metadata_text(value: Any) -> str | None:def _native_chart_chrome_errors(elem: ET.Element, payload: dict[str, Any]) -> list[str]:+ if native_json_is_authoritative(elem):+ return []fallback_texts = set(_visible_fallback_texts(elem))missing: list[str] = []@@ -515,7 +532,7 @@ def _native_chart_export_payload(elem: ET.Element,payload: dict[str, Any],) -> tuple[dict[str, Any], list[str]]:- if native_import_source(elem) == "pptx":+ if native_import_source(elem) == "pptx" or native_json_is_authoritative(elem):return payload, []fallback_texts = set(_visible_fallback_texts(elem))output = payloaddiff --git a/skills/ppt-master/scripts/svg_to_pptx/native_objects/fallback_hash.py b/skills/ppt-master/scripts/svg_to_pptx/native_objects/fallback_hash.pyindex e66a935c..0bf3a5fb 100644--- a/skills/ppt-master/scripts/svg_to_pptx/native_objects/fallback_hash.py+++ b/skills/ppt-master/scripts/svg_to_pptx/native_objects/fallback_hash.py@@ -11,7 +11,10 @@ from pptx_shapes import (svg_native_fallback_fingerprint,)-from .marker_attributes import native_import_source, native_replacement_kind+from .marker_attributes import (+ native_json_is_authoritative,+ native_replacement_kind,+)NATIVE_FALLBACK_RUNTIME_ATTR = "data-pptx-runtime-fallback-unchanged"@@ -46,6 +49,10 @@ def snapshot_native_fallback_freshness(root: ET.Element) -> None:and elem.get("data-pptx-roundtrip-object") is None):continue+ if native_json_is_authoritative(elem):+ elem.attrib.pop(NATIVE_FALLBACK_RUNTIME_ATTR, None)+ elem.attrib.pop(_NATIVE_FALLBACK_RUNTIME_TOKEN_ATTR, None)+ continueexpected, invalid = _expected_native_fallback_hash(elem)if invalid:elem.set(NATIVE_FALLBACK_RUNTIME_ATTR, "invalid")@@ -72,7 +79,7 @@ def native_fallback_contract_warnings(document_root: ET.Element | None = None,) -> list[str]:"""Return non-blocking diagnostics for default/checker compatibility."""- if elem.get("data-pptx-semantic-object") == "table":+ if native_json_is_authoritative(elem):return []expected, invalid = _expected_native_fallback_hash(elem)if invalid:@@ -82,12 +89,10 @@ def native_fallback_contract_warnings("--native-charts-and-tables will fail"]if expected is None:- if native_import_source(elem) != "pptx":- return []return [- f"imported marker has no {NATIVE_FALLBACK_SHA256_ATTR} baseline; "- "the marker remains compatible with Chart/Table replacement, but "- "stale fallback edits cannot be detected"+ f"SVG-authoritative marker has no {NATIVE_FALLBACK_SHA256_ATTR} "+ "baseline; the shape-based SVG fallback remains available, but "+ "--native-charts-and-tables will fail"]if _native_fallback_is_fresh(elem,@@ -110,13 +115,19 @@ def require_fresh_native_fallback(document_root: ET.Element | None = None,) -> None:"""Fail Chart/Table replacement when a recorded fallback is stale."""+ if native_json_is_authoritative(elem):+ returnexpected, invalid = _expected_native_fallback_hash(elem)if invalid:raise RuntimeError(f"{NATIVE_FALLBACK_SHA256_ATTR} must be a 64-digit SHA-256")if expected is None:- return+ raise RuntimeError(+ f"SVG-authoritative native-object marker requires "+ f"{NATIVE_FALLBACK_SHA256_ATTR}; --native-charts-and-tables "+ "stopped because the embedded JSON is not bound to the visible SVG"+ )if _native_fallback_is_fresh(elem,expected,diff --git a/skills/ppt-master/scripts/svg_to_pptx/native_objects/marker_attributes.py b/skills/ppt-master/scripts/svg_to_pptx/native_objects/marker_attributes.pyindex 7fe942d6..db7f29a2 100644--- a/skills/ppt-master/scripts/svg_to_pptx/native_objects/marker_attributes.py+++ b/skills/ppt-master/scripts/svg_to_pptx/native_objects/marker_attributes.py@@ -10,6 +10,8 @@ REPLACE_WITH_ATTR = "data-pptx-replace-with"LEGACY_REPLACE_WITH_ATTR = "data-pptx-native"REPLACEMENT_STATUS_ATTR = "data-pptx-replacement-status"LEGACY_REPLACEMENT_STATUS_ATTR = "data-pptx-native-status"+NATIVE_AUTHORITY_ATTR = "data-pptx-native-authority"+JSON_NATIVE_AUTHORITY = "json"IMPORT_SOURCE_ATTR = "data-pptx-import-source"LEGACY_IMPORT_SOURCE_ATTR = "data-pptx-native-source"FALLBACK_KIND_ATTR = "data-pptx-fallback-kind"@@ -66,6 +68,11 @@ def native_replacement_status(elem: ET.Element) -> str:)+def native_json_is_authoritative(elem: ET.Element) -> bool:+ """Return whether embedded JSON is the declared Chart/Table authority."""+ return elem.get(NATIVE_AUTHORITY_ATTR) == JSON_NATIVE_AUTHORITY++def native_import_source(elem: ET.Element) -> str:"""Return replacement payload provenance, or an empty string."""return (diff --git a/skills/ppt-master/scripts/svg_to_pptx/native_objects/marker_status.py b/skills/ppt-master/scripts/svg_to_pptx/native_objects/marker_status.pyindex 4a31a5fd..996e52bc 100644--- a/skills/ppt-master/scripts/svg_to_pptx/native_objects/marker_status.py+++ b/skills/ppt-master/scripts/svg_to_pptx/native_objects/marker_status.py@@ -12,6 +12,8 @@ from .marker_attributes import (LEGACY_REPLACEMENT_STATUS_ATTR,LEGACY_REPLACE_WITH_ATTR,LEGACY_ROUTE_STATUS_ATTR,+ JSON_NATIVE_AUTHORITY,+ NATIVE_AUTHORITY_ATTR,REPLACEMENT_STATUS_ATTR,REPLACE_WITH_ATTR,NativeMarkerAttributeError,@@ -102,6 +104,7 @@ def native_marker_status_errors(elem: ET.Element) -> list[str]:visual_raw = elem.get(FALLBACK_KIND_ATTR)legacy_visual_raw = elem.get(LEGACY_FALLBACK_KIND_ATTR)route_raw = elem.get(LEGACY_ROUTE_STATUS_ATTR)+ authority_raw = elem.get(NATIVE_AUTHORITY_ATTR)try:visual = native_fallback_kind(elem)native = native_replacement_kind(elem)@@ -137,6 +140,15 @@ def native_marker_status_errors(elem: ET.Element) -> list[str]:)if route_raw is not None and route_raw != route:errors.append(f"{LEGACY_ROUTE_STATUS_ATTR} must not contain surrounding whitespace")+ if authority_raw is not None:+ if authority_raw != authority_raw.strip():+ errors.append(+ f"{NATIVE_AUTHORITY_ATTR} must not contain surrounding whitespace"+ )+ elif authority_raw != JSON_NATIVE_AUTHORITY:+ errors.append(+ f"{NATIVE_AUTHORITY_ATTR} must equal {JSON_NATIVE_AUTHORITY!r}"+ )if visual is not None and visual not in VISUAL_STATUSES:errors.append(f"unsupported {FALLBACK_KIND_ATTR} value: {visual!r}")if route is not None and route not in ROUTE_STATUSES:@@ -174,6 +186,11 @@ def native_marker_status_errors(elem: ET.Element) -> list[str]:errors.append(f"data-pptx-replace-with and {REPLACEMENT_STATUS_ATTR} are mutually exclusive")+ if authority_raw is not None and native not in {"chart", "table"}:+ errors.append(+ f"{NATIVE_AUTHORITY_ATTR} is allowed only on "+ f"data-pptx-replace-with chart/table markers"+ )return errorsdiff --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 31549659..6826ea22 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@@ -5644,8 +5644,8 @@ def create_pptx_with_native_svg(image_scale: Target image pixels per SVG display pixel.image_quality: JPEG quality used when opaque rasters are re-encoded.native_objects: Replace opt-in ``data-pptx-replace-with`` chart/table- fallback groups with native PowerPoint Chart/Table objects. Semantic- authoring tables are intrinsically native. Default off for other markers.+ fallback groups with native PowerPoint Chart/Table objects. Formula+ markers remain intrinsically native; Chart/Table markers stay off otherwise.conversion_trace_path: Optional JSON path for native conversion diagnostics.dangerous_nonconforming_export: Apply narrowly defined compatibilitynormalizations before strict SVG conversion. Actual contract,@@ -5927,13 +5927,9 @@ def create_pptx_with_native_svg(if use_native_shapes:print(f" Mode: Native DrawingML shapes (directly editable)")native_object_mode = (- "All registered markers enabled"+ "Chart/Table replacement enabled"if native_objects- else (- "Semantic tables; exact round-trip source charts"- if native_structure_contract is not None- else "Semantic tables only"- )+ else "Chart/Table replacement disabled")print(" Native table/chart objects: "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 e1ee19b6..efe1216b 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@@ -1594,8 +1594,7 @@ Recorded narration:help=('Replace opt-in data-pptx-replace-with chart/table groups with ''PowerPoint native Chart/Table objects. This data-object route may '- 'normalize styling or omit fallback-only visuals. Semantic authoring '- 'tables are always native; default off applies to other markers, which '+ 'normalize styling or omit fallback-only visuals. Default-off markers ''export as editable SVG-derived DrawingML shapes. The default-flow ''output uses <project>_<ts>_native_charts_tables.pptx.'),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.pyindex b2b5c605..9a4be447 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@@ -18,6 +18,7 @@ from __future__ import annotationsimport base64import binascii+import copyimport hashlibimport jsonimport math@@ -44,7 +45,11 @@ from ..geometry_properties import (GeometryStyleError,materialize_inline_geometry_properties,)-from ..native_objects import NativeMarkerAttributeError, native_replacement_kind+from ..native_objects import (+ NativeMarkerAttributeError,+ native_json_is_authoritative,+ native_replacement_kind,+)_NON_VISUAL_TAGS = frozenset({"defs", "title", "desc", "metadata", "style"})@@ -2455,6 +2460,7 @@ def _element_tree_signature(svg_path: Path | None = None,asset_identity: bool = False,ignore_structure_attrs: bool = False,+ ignore_json_native_preview: bool = False,) -> tuple[object, ...]:"""Return a stable structural or literal-visual SVG subtree signature."""text = (elem.text or "") if include_text else ""@@ -2482,6 +2488,14 @@ def _element_tree_signature())))+ children = (+ _mirror_comparison_children(elem)+ if ignore_json_native_preview+ else tuple(elem)+ )+ json_native_marker = (+ ignore_json_native_preview and _is_json_first_native_marker(elem)+ )return (elem.tag,attrs,@@ -2490,16 +2504,59 @@ def _element_tree_signature(_element_tree_signature(child,include_skin=include_skin,- include_text=include_text,+ include_text=(+ include_text+ or (+ json_native_marker+ and _local_tag(child) == "metadata"+ )+ ),svg_path=svg_path,asset_identity=asset_identity,ignore_structure_attrs=ignore_structure_attrs,+ ignore_json_native_preview=ignore_json_native_preview,)- for child in elem+ for child in children),)+def _is_json_first_native_marker(elem: ET.Element) -> bool:+ """Return whether this element directly owns JSON-first Chart/Table data."""+ try:+ replacement_kind = native_replacement_kind(elem)+ except NativeMarkerAttributeError:+ return False+ return (+ native_json_is_authoritative(elem)+ and replacement_kind in {"chart", "table"}+ )+++def _mirror_comparison_children(elem: ET.Element) -> tuple[ET.Element, ...]:+ """Exclude only the derived preview below a JSON-first native marker."""+ if not _is_json_first_native_marker(elem):+ return tuple(elem)+ return tuple(child for child in elem if _local_tag(child) == "metadata")+++def _mirror_resource_projection(elem: ET.Element) -> ET.Element:+ """Copy one comparison subtree without JSON-first derived previews."""+ projected = copy.deepcopy(elem)++ def prune(node: ET.Element) -> None:+ if _is_json_first_native_marker(node):+ for child in list(node):+ if _local_tag(child) != "metadata":+ node.remove(child)+ return+ for child in node:+ prune(child)++ prune(projected)+ return projected++def _svg_reference_ids(elem: ET.Element) -> set[str]:"""Return fragment ids referenced anywhere in one SVG subtree."""references: set[str] = set()@@ -2700,10 +2757,17 @@ def _scope_visual_resources_signature(root: ET.Element,elements: tuple[ET.Element, ...],svg_path: Path,+ *,+ ignore_json_native_preview: bool = False,) -> tuple[object, ...]:"""Capture root inheritance, relevant CSS, and the referenced defs closure."""if not elements:return ()+ comparison_elements = (+ tuple(_mirror_resource_projection(element) for element in elements)+ if ignore_json_native_preview+ else elements+ )root_attrs = tuple(sorted((name,@@ -2720,9 +2784,9 @@ def _scope_visual_resources_signature(and not name.rsplit("}", 1)[-1].startswith("data-"))))- css_rules = _scope_css_signature(root, elements, svg_path)+ css_rules = _scope_css_signature(root, comparison_elements, svg_path)references: set[str] = set()- for element in elements:+ for element in comparison_elements:references.update(_svg_reference_ids(element))for _selector, declarations in css_rules:references.update(@@ -2773,6 +2837,7 @@ def _structure_subtree_signature(include_skin: bool = False,include_text: bool = True,asset_identity: bool = False,+ ignore_json_native_preview: bool = False,) -> tuple[tuple[str, tuple[object, ...]], ...]:"""Read structural or literal-visual signatures for direct SVG children."""try:@@ -2803,6 +2868,7 @@ def _structure_subtree_signature(include_text=include_text,svg_path=svg_path,asset_identity=asset_identity,+ ignore_json_native_preview=ignore_json_native_preview,),))if include_skin:@@ -2813,7 +2879,12 @@ def _structure_subtree_signature()signatures.append(("__visual_resources__",- _scope_visual_resources_signature(root, selected, svg_path),+ _scope_visual_resources_signature(+ root,+ selected,+ svg_path,+ ignore_json_native_preview=ignore_json_native_preview,+ ),))return tuple(signatures)@@ -2849,8 +2920,9 @@ def _mirror_slide_local_signature() -> tuple[tuple[object, ...], tuple[object, ...]]:"""Capture literal mirror visuals that are Slide-local on either page.- Visible text values may change, but their element topology, attributes,- grouping, paint, geometry, and referenced asset bytes remain literal.+ Visible text values and JSON-first native preview children may change, but+ other element topology, attributes, grouping, paint, geometry, and+ referenced asset bytes remain literal.Structure metadata may change when adaptive template authoring assigns anevolved Layout identity to the same stable SVG id."""@@ -2879,12 +2951,14 @@ def _mirror_slide_local_signature(svg_path=spec.svg_path,asset_identity=True,ignore_structure_attrs=True,+ ignore_json_native_preview=True,))resources = _scope_visual_resources_signature(root,tuple(slide_elements),spec.svg_path,+ ignore_json_native_preview=True,)return resources, tuple(slide_visuals)@@ -2970,6 +3044,11 @@ def _mirror_element_difference(actual_tag = _local_tag(actual)if expected_tag != actual_tag:return f"{path}: expected <{expected_tag}>, found <{actual_tag}>"+ if (+ expected_tag == "metadata"+ and (expected.text or "") != (actual.text or "")+ ):+ return f"{path}: metadata payload differs"expected_attrs = _mirror_comparable_attributes(expected,@@ -2991,8 +3070,8 @@ def _mirror_element_difference(f"{expected_value!r}, found {actual_value!r}")- expected_children = list(expected)- actual_children = list(actual)+ expected_children = list(_mirror_comparison_children(expected))+ actual_children = list(_mirror_comparison_children(actual))if len(expected_children) != len(actual_children):expected_tspans = sum(_local_tag(child) == "tspan" for child in expected_children@@ -3076,10 +3155,12 @@ def _mirror_slide_local_difference(expected_root,tuple(expected_children),expected_spec.svg_path,+ ignore_json_native_preview=True,) != _scope_visual_resources_signature(actual_root,tuple(actual_children),actual_spec.svg_path,+ ignore_json_native_preview=True,):return "svg: referenced defs, CSS, root styling, or asset identity differs"return None@@ -3180,12 +3261,14 @@ def template_prototype_errors(prototype.master_elements,include_skin=literal_visual,asset_identity=literal_visual,+ ignore_json_native_preview=literal_visual,)actual_master_structure = _structure_subtree_signature(spec.svg_path,spec.master_elements,include_skin=literal_visual,asset_identity=literal_visual,+ ignore_json_native_preview=literal_visual,)except TemplateStructureError as exc:errors.append(str(exc))@@ -3246,7 +3329,8 @@ def template_prototype_errors(f"{spec.svg_path.name}: mirror Slide-local non-text visuals "f"differ from prototype {reference.svg_path.name}; preserve ""grouping, geometry, paint, effects, and referenced asset "- "identity, changing only visible text content"+ "identity; only visible text content and JSON-first derived "+ "preview children may change"+ (f"; first difference: {difference}" if difference else ""))@@ -3256,12 +3340,14 @@ def template_prototype_errors(prototype.layout_elements,include_skin=literal_visual,asset_identity=literal_visual,+ ignore_json_native_preview=literal_visual,)actual_layout_structure = _structure_subtree_signature(spec.svg_path,spec.layout_elements,include_skin=literal_visual,asset_identity=literal_visual,+ ignore_json_native_preview=literal_visual,)if literal_visual:expected_placeholder_visual = _structure_subtree_signature(@@ -3270,6 +3356,7 @@ def template_prototype_errors(include_skin=True,include_text=False,asset_identity=True,+ ignore_json_native_preview=True,)actual_placeholder_visual = _structure_subtree_signature(spec.svg_path,@@ -3277,6 +3364,7 @@ def template_prototype_errors(include_skin=True,include_text=False,asset_identity=True,+ ignore_json_native_preview=True,)else:expected_placeholder_visual = ()diff --git a/skills/ppt-master/scripts/template_preview_pptx.py b/skills/ppt-master/scripts/template_preview_pptx.pyindex bb34e6d5..e9c3de71 100644--- a/skills/ppt-master/scripts/template_preview_pptx.py+++ b/skills/ppt-master/scripts/template_preview_pptx.py@@ -389,6 +389,14 @@ def build_parser() -> argparse.ArgumentParser:action="store_true",help="Replace an existing review PPTX after an intentional re-export.",)+ parser.add_argument(+ "--native-charts-and-tables",+ action="store_true",+ help=(+ "Replace eligible SVG chart/table fallbacks with PowerPoint-native "+ "objects. Default review export keeps the visible SVG fallbacks."+ ),+ )return parser@@ -470,7 +478,7 @@ def main(argv: list[str] | None = None) -> int:enable_notes=False,animation=None,image_optimize=False,- native_objects=True,+ native_objects=args.native_charts_and_tables,pptx_structure="structured",use_layout_placeholder_frames=use_full_placeholder_frames,master_text_style_spec=text_style,