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(native): keep the original table payload after marker validation

hugohe339129e76bc18
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__.py
index 8e7b515b..824acabe 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
@@ -74,6 +74,7 @@ from .marker_attributes import (
native_replacement_status,
)
from .marker_status import native_marker_status_errors
+from semantic_table import expand_semantic_table_payload
from .table import (
_build_native_table,
_native_table_warnings,
@@ -454,10 +455,9 @@ def _validate_native_object_marker_payload(
off_x, off_y, ext_cx, ext_cy, _ = _validate_bounds_inputs(elem, payload, bounds_ctx)
validated_data: list[list[Any]] | FormulaSpec | None = None
if kind == "table":
- expanded_payload, table_rows, col_count, _merge_layout = (
+ _expanded_payload, table_rows, col_count, _merge_layout = (
_validate_table_payload(payload)
)
- payload = expanded_payload
validated_data = table_rows
if ext_cx < col_count or ext_cy < len(table_rows):
raise RuntimeError(
@@ -518,7 +518,13 @@ def _projection_warnings_for_validated_marker(
):
return []
if kind == "table" and isinstance(validated_data, list):
- return _native_table_warnings(elem, payload, validated_data)
+ # Expand a copy for the parity checks; the caller keeps the original
+ # payload so the table writer can expand it again itself.
+ return _native_table_warnings(
+ elem,
+ expand_semantic_table_payload(payload),
+ validated_data,
+ )
if kind == "chart" and payload.get("source_package") is None:
return _native_chart_chrome_warnings(elem, payload)
return []
diff --git a/skills/ppt-master/scripts/tests/test_native_chart_table_parity.py b/skills/ppt-master/scripts/tests/test_native_chart_table_parity.py
index 18161ee8..7bb25c23 100644
--- a/skills/ppt-master/scripts/tests/test_native_chart_table_parity.py
+++ b/skills/ppt-master/scripts/tests/test_native_chart_table_parity.py
@@ -291,5 +291,24 @@ class NativeProjectionCheckerTests(unittest.TestCase):
self.assertIn(text, findings_by_page[filename])
+class NativeTablePayloadRoundTripTest(unittest.TestCase):
+ def test_marker_validation_keeps_original_table_payload(self):
+ """The converter re-expands the payload; validation must not hand back an expanded copy."""
+ import xml.etree.ElementTree as ET
+ from svg_to_pptx.native_objects import _validate_native_object_marker_payload
+ from svg_to_pptx.native_objects.table import _build_native_table # noqa: F401
+ from semantic_table import expand_semantic_table_payload
+ fixture = FIXTURES_DIR / "27_business_models.svg"
+ root = ET.parse(fixture).getroot()
+ marker = next(
+ el for el in root.iter()
+ if el.get("data-pptx-replace-with") == "table"
+ )
+ kind, payload, rows = _validate_native_object_marker_payload(marker)
+ self.assertEqual(kind, "table")
+ self.assertEqual(payload.get("schema"), "ppt-master.semantic-table.v2")
+ expand_semantic_table_payload(payload) # must still expand cleanly
+
+
if __name__ == "__main__":
unittest.main()