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-table): accept formatting on merge-covered cells

hugohe348ee45f9f2d3
diff --git a/skills/ppt-master/scripts/docs/native-data.md b/skills/ppt-master/scripts/docs/native-data.md
index ae697dad..bd1457e2 100644
--- a/skills/ppt-master/scripts/docs/native-data.md
+++ b/skills/ppt-master/scripts/docs/native-data.md
@@ -25,7 +25,7 @@ Cells accept `text`, `fill`, `fill_opacity`, `color`, `align` (header cells expo
`style` accepts `font_family`, `font_size`, `header_font_size`, `band_row`, `padding`, `valign`, `border_color`, `border_width`, `lang`, `table_style_id`, and the table-wide colours `header_fill`, `header_text`, `body_fill`, `body_text`, `band_fill`. SVG-first parity reads a header band drawn as one rect spanning the header rows as `style.header_fill` unless every header cell carries that same `fill` (and the dominant header text colour as `style.header_text` unless every header cell carries it), so a drawn band is projected at table level rather than repeated per cell. Fills are only what the payload resolves: a cell with no `fill` takes `style.header_fill` (header rows) or `style.band_fill` / `style.body_fill` (body rows), and when none of those is set it exports as `noFill` so the slide background shows through — the same as a fallback that draws no cell rect. Text colour never falls to nothing: a cell without `color` takes `defaults.run.color` (plain text is one run, and a `paragraphs` cell whose paragraphs are strings or `text` objects inherits the same way at cell level, so `defaults.run` `bold` / `color` / `font_size` reach both when the cell and `defaults.cell` leave them unset; `paragraphs[].runs` take the run defaults directly), then `style.body_text` / `style.header_text`, then `#1F2937` (`header_text` defaults to `#FFFFFF` only when `header_fill` is set). SVG-first parity reports a body text colour drawn in the fallback that none of those layers would carry, and a first-column colour that neither the cell nor `style.body_text` resolves to.
-**Hard rule — the table payload is complete**: a payload holding only `font_size` and a uniform border is not complete when the fallback draws a header band, row or column fills, first-column emphasis, non-uniform row heights, or sparse rules — every row, summary line, value, and cell style that must survive `--native-charts-and-tables` is in `columns` / `rows`, because fallback text is discarded on that route. Numeric or currency columns use cell objects with `align: "r"` (`text-anchor="end"` does not carry). **Merged cells — canonical rectangular contract only**: positive integer `row_span` / `col_span` on the anchor, every covered cell blank (canonical `{"merge_continuation": true}`), spans inside the grid and non-overlapping; the exporter writes `rowSpan` / `gridSpan` / `hMerge` / `vMerge`. Covered-cell blankness is checked before expanding defaults: accepted authored values are `null`, `""`, and objects containing only optional `text` (absent, `null`, or `""`) and `merge_continuation` (absent or exactly `true`), including `{}`. Authored formatting fields make a covered cell nonblank; inherited defaults do not, so `{"text": ""}` stays blank with `defaults.cell.color`. CamelCase aliases, raw OOXML merge fields, top-level merge lists, nonblank covered cells, invalid spans, and overlaps fail.
+**Hard rule — the table payload is complete**: a payload holding only `font_size` and a uniform border is not complete when the fallback draws a header band, row or column fills, first-column emphasis, non-uniform row heights, or sparse rules — every row, summary line, value, and cell style that must survive `--native-charts-and-tables` is in `columns` / `rows`, because fallback text is discarded on that route. Numeric or currency columns use cell objects with `align: "r"` (`text-anchor="end"` does not carry). **Merged cells — canonical rectangular contract only**: positive integer `row_span` / `col_span` on the anchor, every covered cell blank (canonical `{"merge_continuation": true}`), spans inside the grid and non-overlapping; the exporter writes `rowSpan` / `gridSpan` / `hMerge` / `vMerge`. Covered-cell blankness is checked before expanding defaults: accepted authored values are `null`, `""`, and objects with optional `text` (absent, `null`, or `""`) and `merge_continuation` (absent or exactly `true`), including `{}`. Covered cells also accept the cell formatting fields and `cell_style` defined above; resolved fills, opacity, borders, padding, and cell alignment attributes are written to the covered `a:tcPr`, preserving its `a:tc` merge flags. Formatting and inherited defaults do not make a covered cell nonblank; non-empty `text` and any `paragraphs` field are rejected. CamelCase aliases, raw OOXML merge fields, top-level merge lists, nonblank covered cells, invalid spans, and overlaps fail.
## §2 Chart schemas
diff --git a/skills/ppt-master/scripts/svg_to_pptx/native_objects/table.py b/skills/ppt-master/scripts/svg_to_pptx/native_objects/table.py
index 5b9e8d49..dde9dfc5 100644
--- a/skills/ppt-master/scripts/svg_to_pptx/native_objects/table.py
+++ b/skills/ppt-master/scripts/svg_to_pptx/native_objects/table.py
@@ -442,14 +442,16 @@ def _merge_covered_cell_is_blank(value: Any) -> bool:
return True
if not isinstance(value, dict):
return False
- if set(value) - {"merge_continuation", "text"}:
+ # The semantic-table schema has already validated formatting fields.
+ # Covered cells may retain them, but cannot carry a text body.
+ if "paragraphs" in value:
return False
if (
"merge_continuation" in value
and value["merge_continuation"] is not True
):
return False
- return value.get("text") in {None, ""}
+ return value.get("text") in (None, "")
def _resolve_table_merge_layout(
@@ -1840,64 +1842,57 @@ def _build_native_table(elem: ET.Element, ctx: ConvertContext, payload: dict[str
cell_data = _cell_payload(cell)
merge_region = merge_layout.get((row_idx, col_idx))
merge_attrs = _table_merge_attrs(merge_region, row_idx, col_idx)
+ if preserve_source_style:
+ fill = (
+ _clean_hex(cell_data.get("fill"), "#FFFFFF")
+ if cell_data.get("fill") is not None else None
+ )
+ else:
+ fill = _hex_or_none(cell_data.get("fill"))
+ if fill is None:
+ banded = (
+ band_rows_enabled
+ and band_fill is not None
+ and row_idx % 2 == 0
+ and row_idx
+ )
+ fill = header_fill if is_header else (
+ band_fill if banded else body_fill
+ )
+ border_xml = _table_border_xml(cell_data, style, ctx.theme_color_spec)
+ fill_xml = (
+ "<a:noFill/>"
+ if fill is None and not preserve_source_style
+ else _table_fill_xml(fill, _table_fill_opacity(cell_data), ctx.theme_color_spec)
+ )
+ anchor_attr = ""
+ if not preserve_source_style or "valign" in cell_data or "valign" in style:
+ anchor_attr = f' anchor="{_table_anchor(cell_data, style)}"'
if merge_region is not None and (
row_idx != merge_region.row or col_idx != merge_region.col
):
- continuation_attrs = ""
- continuation_border_xml = ""
- continuation_fill_xml = ""
- if cell_data.get("merge_continuation") is True:
- continuation_attrs = (
- _table_padding_attrs(cell_data, style)
- + _table_cell_extra_attrs(cell_data)
- )
- continuation_border_xml = _table_border_xml(
- cell_data,
- style,
- ctx.theme_color_spec,
- )
- continuation_fill = (
- _clean_hex(cell_data.get("fill"), "#FFFFFF")
- if cell_data.get("fill") is not None
- else None
- )
- continuation_fill_xml = _table_fill_xml(
- continuation_fill,
- _table_fill_opacity(cell_data),
- ctx.theme_color_spec,
- )
+ continuation_attrs = (
+ anchor_attr
+ + _table_padding_attrs(cell_data, style)
+ + _table_cell_extra_attrs(cell_data)
+ )
cells_xml.append(
f'<a:tc{merge_attrs}>'
'<a:txBody><a:bodyPr/><a:lstStyle/><a:p/></a:txBody>'
f'<a:tcPr{continuation_attrs}>'
- f'{continuation_border_xml}{continuation_fill_xml}'
+ f'{border_xml}{fill_xml}'
'</a:tcPr>'
'</a:tc>'
)
continue
if preserve_source_style:
- fill = (
- _clean_hex(cell_data.get("fill"), "#FFFFFF")
- if cell_data.get("fill") is not None else None
- )
color = (
_clean_hex(cell_data.get("color"), "#000000")
if cell_data.get("color") is not None else None
)
align = str(cell_data.get("align") or "l")
else:
- fill = _hex_or_none(cell_data.get("fill"))
- if fill is None:
- banded = (
- band_rows_enabled
- and band_fill is not None
- and row_idx % 2 == 0
- and row_idx
- )
- fill = header_fill if is_header else (
- band_fill if banded else body_fill
- )
color = _clean_hex(
cell_data.get("color"),
header_text if is_header else body_text,
@@ -2012,28 +2007,11 @@ def _build_native_table(elem: ET.Element, ctx: ConvertContext, payload: dict[str
f"<a:p>{paragraph_props}{text_run_xml}</a:p>"
)
paragraphs_xml = "".join(paragraph_parts)
- anchor_keys = {"valign"}
- anchor_attr = ""
- if not preserve_source_style or anchor_keys.intersection(cell_data) or anchor_keys.intersection(style):
- anchor_attr = f' anchor="{_table_anchor(cell_data, style)}"'
tc_pr_attrs = (
f'{anchor_attr}'
f'{_table_padding_attrs(cell_data, style, row_height=row_heights[row_idx], paragraphs_xml=paragraphs_xml)}'
f'{_table_cell_extra_attrs(cell_data)}'
)
- border_xml = _table_border_xml(
- cell_data,
- style,
- ctx.theme_color_spec,
- )
- if fill is None and not preserve_source_style:
- fill_xml = "<a:noFill/>"
- else:
- fill_xml = _table_fill_xml(
- fill,
- _table_fill_opacity(cell_data),
- ctx.theme_color_spec,
- )
cells_xml.append(
f"<a:tc{merge_attrs}>"
"<a:txBody><a:bodyPr/><a:lstStyle/>"
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.py
index c17252d1..be69bb90 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
@@ -91,6 +91,7 @@ from ..native_objects import (
native_replacement_kind,
native_replacement_status,
)
+from ..native_objects.marker_attributes import native_json_is_authoritative
from ..native_objects.marker_status import native_marker_release_block_reason
from ..drawingml.theme_colors import (
ThemeColorError,
@@ -1769,11 +1770,12 @@ def _native_object_fallbacks(svg_files: list[Path]) -> list[tuple[str, str, str]
return fallbacks
-def _native_object_projection_findings(
+def _native_object_preflight_findings(
svg_files: list[Path],
-) -> list[tuple[str, str, str]]:
- """Return SVG-first Chart/Table details that native metadata would discard."""
- findings: list[tuple[str, str, str]] = []
+) -> tuple[list[tuple[str, str, str]], list[tuple[str, str, str]]]:
+ """Separate JSON-first payload failures from SVG-first projection findings."""
+ payload_findings: list[tuple[str, str, str]] = []
+ projection_findings: list[tuple[str, str, str]] = []
for svg_path in svg_files:
try:
root = ET.parse(svg_path).getroot()
@@ -1803,12 +1805,15 @@ def _native_object_projection_findings(
document_root=root,
)
except RuntimeError as exc:
+ if native_json_is_authoritative(elem):
+ payload_findings.append((svg_path.name, marker_id, str(exc)))
+ continue
warnings = [f"projection validation failed: {exc}"]
- findings.extend(
+ projection_findings.extend(
(svg_path.name, marker_id, warning)
for warning in warnings
)
- return findings
+ return payload_findings, projection_findings
def _release_blocked_graphics(
@@ -3229,7 +3234,20 @@ Recorded narration:
)
if args.native_objects:
- projection_findings = _native_object_projection_findings(native_files)
+ payload_findings, projection_findings = _native_object_preflight_findings(native_files)
+ if payload_findings:
+ print(
+ "Error: --native-charts-and-tables stopped because JSON-first "
+ "native payload validation failed:",
+ file=sys.stderr,
+ )
+ for filename, marker_id, finding in payload_findings:
+ print(f" {filename}: {marker_id}: {finding}", file=sys.stderr)
+ print(
+ "Correct the reported JSON payload fields in the object's "
+ "metadata and retry the native export.",
+ file=sys.stderr,
+ )
if projection_findings:
print(
"Error: --native-charts-and-tables stopped because visible "
@@ -3247,6 +3265,7 @@ Recorded narration:
"Native-ready=no.",
file=sys.stderr,
)
+ if payload_findings or projection_findings:
return 1
print(
"Warning: --native-charts-and-tables replaces shape-based SVG fallbacks "
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 bb3a145e..dbf9f7e7 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
@@ -28,7 +28,7 @@ from svg_to_pptx.native_objects.table import ( # noqa: E402
)
from semantic_table import expand_semantic_table_payload # noqa: E402
from svg_to_pptx.pptx_package.cli import ( # noqa: E402
- _native_object_projection_findings,
+ _native_object_preflight_findings,
)
from svg_quality.checker import SVGQualityChecker # noqa: E402
@@ -111,6 +111,7 @@ class NativeTableMergeTests(unittest.TestCase):
{},
{"text": ""},
{"merge_continuation": True},
+ {"fill": "#F1F4F8"},
):
with self.subTest(covered_cell=covered_cell):
_payload, rows, col_count, merge_layout = (
@@ -122,7 +123,6 @@ class NativeTableMergeTests(unittest.TestCase):
for covered_cell in (
{"text": "authored"},
{"paragraphs": [{"text": ""}]},
- {"fill": "#F1F4F8"},
):
with self.subTest(covered_cell=covered_cell):
with self.assertRaisesRegex(RuntimeError, "must be blank"):
@@ -357,7 +357,8 @@ class NativeProjectionCheckerTests(unittest.TestCase):
for filename in self.EXPECTED_FINDINGS
]
- findings = _native_object_projection_findings(fixture_paths)
+ payload_findings, findings = _native_object_preflight_findings(fixture_paths)
+ self.assertFalse(payload_findings)
findings_by_page: dict[str, str] = {}
for filename, _marker_id, warning in findings:
findings_by_page.setdefault(filename, "")
diff --git a/skills/ppt-master/scripts/tests/test_native_table_merges.py b/skills/ppt-master/scripts/tests/test_native_table_merges.py
new file mode 100644
index 00000000..006a8d57
--- /dev/null
+++ b/skills/ppt-master/scripts/tests/test_native_table_merges.py
@@ -0,0 +1,200 @@
+#!/usr/bin/env python3
+"""PPT Master - Native Merged Table Regression Tests
+
+Exercise covered-cell formatting and authority-aware errors through the public
+SVG converter and export CLI using small inline fixtures.
+
+Usage:
+ python3 -m unittest tests.test_native_table_merges
+
+Examples:
+ Run the module from the scripts directory.
+
+Dependencies:
+ Standard library and the local SVG-to-PPTX converter.
+"""
+
+from __future__ import annotations
+
+import io
+import json
+import tempfile
+import unittest
+from contextlib import redirect_stderr, redirect_stdout
+from pathlib import Path
+from xml.etree import ElementTree as ET
+
+from svg_to_pptx.drawingml.converter import convert_svg_to_slide_shapes
+from svg_to_pptx.pptx_package.cli import main
+
+
+NS = {
+ "a": "http://schemas.openxmlformats.org/drawingml/2006/main",
+ "s": "http://www.w3.org/2000/svg",
+}
+
+
+class NativeTableMergeTests(unittest.TestCase):
+ def setUp(self) -> None:
+ temporary = tempfile.TemporaryDirectory()
+ self.addCleanup(temporary.cleanup)
+ self.root = Path(temporary.name)
+ self.source = self.root / "input"
+ self.source.mkdir()
+ self.svg_path = self.source / "slide_01.svg"
+
+ @staticmethod
+ def _payload(covered: object, **extra: object) -> dict:
+ return {
+ "schema": "ppt-master.semantic-table.v2",
+ "x": 20, "y": 20, "width": 400, "height": 160,
+ "header_rows": 0,
+ "rows": [
+ [{"text": "Owner", "row_span": 2, "col_span": 2}, covered],
+ [covered, covered],
+ ],
+ **extra,
+ }
+
+ def _write_svg(
+ self, payload: dict, *, imported: bool = False, json_first: bool = True,
+ ) -> ET.Element:
+ root = ET.Element(f'{{{NS["s"]}}}svg', {
+ "viewBox": "0 0 1280 720", "lang": "en-US",
+ })
+ marker = ET.SubElement(root, f'{{{NS["s"]}}}g', {
+ "id": "shape-60", "data-pptx-replace-with": "table",
+ })
+ if json_first:
+ marker.set("data-pptx-native-authority", "json")
+ if imported:
+ marker.set("data-pptx-import-source", "pptx")
+ ET.SubElement(marker, f'{{{NS["s"]}}}metadata', {
+ "type": "application/json",
+ }).text = json.dumps(payload)
+ self.svg_path.write_bytes(ET.tostring(root))
+ return root
+
+ def _export(self, payload: dict, *, imported: bool = False) -> list[list[ET.Element]]:
+ self._write_svg(payload, imported=imported)
+ xml, *_rest = convert_svg_to_slide_shapes(
+ self.svg_path, resource_root=self.root, native_objects=True,
+ )
+ table = ET.fromstring(xml).find(".//a:tbl", NS)
+ self.assertIsNotNone(table)
+ return [row.findall("a:tc", NS) for row in table.findall("a:tr", NS)]
+
+ def _run_cli(self) -> tuple[int, str]:
+ stderr = io.StringIO()
+ with redirect_stdout(io.StringIO()), redirect_stderr(stderr):
+ result = main([
+ str(self.root), "--source", "input", "--native-charts-and-tables",
+ "-o", str(self.root / "output.pptx"),
+ ])
+ return result, stderr.getvalue()
+
+ def test_covered_formatting_reaches_tcpr_with_or_without_continuation_marker(self) -> None:
+ formatting = {
+ "fill": "#35778F", "fill_opacity": 0.65,
+ "borders": {
+ "left": {"style": "solid", "color": "#FFFFFF", "width": 3},
+ "right": {"style": "none"},
+ "diagonal_down": {"style": "solid", "color": "#112233", "width": 2},
+ },
+ "padding": {"left": 4, "right": 5, "top": 6, "bottom": 7},
+ "valign": "bottom", "anchor_center": True, "horizontal_overflow": "clip",
+ "color": "#112233", "font_size": 16, "bold": True, "align": "r", "lang": "en-US",
+ }
+ for imported in (False, True):
+ for named_style in (False, True):
+ for continuation in (False, True):
+ with self.subTest(imported=imported, named_style=named_style, continuation=continuation):
+ covered = {"text": ""}
+ if continuation:
+ covered["merge_continuation"] = True
+ if named_style:
+ covered["cell_style"] = "covered"
+ else:
+ covered.update(formatting)
+ payload = self._payload(
+ covered,
+ defaults={"cell": {"fill": "#000000", "padding": {"left": 1}}},
+ cell_styles={"covered": formatting} if named_style else {},
+ )
+ rows = self._export(payload, imported=imported)
+ self.assertEqual(rows[0][0].attrib, {"rowSpan": "2", "gridSpan": "2"})
+ for row, col, attrs in (
+ (0, 1, {"rowSpan": "2", "hMerge": "1"}),
+ (1, 0, {"gridSpan": "2", "vMerge": "1"}),
+ (1, 1, {"hMerge": "1", "vMerge": "1"}),
+ ):
+ cell = rows[row][col]
+ self.assertEqual(cell.attrib, attrs)
+ self.assertFalse(cell.findall("a:txBody//a:t", NS))
+ props = cell.find("a:tcPr", NS)
+ self.assertEqual(props.attrib, {
+ "anchor": "b", "anchorCtr": "1", "horzOverflow": "clip",
+ "marL": "38100", "marR": "47625", "marT": "57150", "marB": "66675",
+ })
+ fill = props.find("a:solidFill/a:srgbClr", NS)
+ self.assertEqual(fill.get("val"), "35778F")
+ self.assertEqual(fill.find("a:alpha", NS).get("val"), "65000")
+ self.assertEqual(props.find("a:lnL", NS).get("w"), "28575")
+ self.assertEqual(props.find("a:lnL/a:solidFill/a:srgbClr", NS).get("val"), "FFFFFF")
+ self.assertIsNotNone(props.find("a:lnR/a:noFill", NS))
+ self.assertEqual(props.find("a:lnTlToBr", NS).get("w"), "19050")
+
+ def test_blank_forms_keep_defaults_and_authored_merge_topology(self) -> None:
+ for covered in (None, "", {}, {"text": None}, {"text": ""}, {"merge_continuation": True}):
+ with self.subTest(covered=covered):
+ rows = self._export(self._payload(covered, defaults={"cell": {"fill": "#ABCDEF"}}))
+ self.assertEqual([node.text for node in rows[0][0].findall(".//a:t", NS)], ["Owner"])
+ for cell in (rows[0][1], rows[1][0], rows[1][1]):
+ self.assertEqual(cell.find("a:tcPr/a:solidFill/a:srgbClr", NS).get("val"), "ABCDEF")
+ self.assertFalse(cell.findall(".//a:t", NS))
+
+ def test_covered_text_and_paragraphs_still_fail(self) -> None:
+ for covered in (
+ {"text": "hidden", "fill": "#35778F", "merge_continuation": True},
+ {"text": " "}, {"text": 0}, {"text": []},
+ {"paragraphs": [{"text": "hidden"}]},
+ {"paragraphs": [{"runs": [{"text": "hidden"}]}]},
+ {"paragraphs": [""]}, {"merge_continuation": False},
+ ):
+ with self.subTest(covered=covered):
+ with self.assertRaisesRegex(RuntimeError, "merge-covered cell R1C2 must be blank"):
+ self._export(self._payload(covered))
+
+ def test_covered_formatting_keeps_schema_and_merge_validation(self) -> None:
+ for covered, message in (
+ ({"unknown": "value"}, "unsupported field"),
+ ({"cell_style": "missing"}, "unknown cell_style"),
+ ({"fill_opacity": 2}, "fill_opacity"),
+ ({"borders": {"left": {"style": "solid", "color": "#FFFFFF", "width": 0}}}, "width"),
+ ({"col_span": 1}, "overlaps"),
+ ):
+ with self.subTest(covered=covered):
+ with self.assertRaisesRegex(RuntimeError, message):
+ self._export(self._payload(covered))
+
+ def test_json_first_validation_errors_do_not_recommend_svg_fallback(self) -> None:
+ for imported in (False, True):
+ with self.subTest(imported=imported):
+ self._write_svg(self._payload({"text": "hidden"}), imported=imported)
+ result, stderr = self._run_cli()
+ self.assertEqual(result, 1, stderr)
+ self.assertIn("JSON-first native payload validation failed", stderr)
+ self.assertIn("slide_01.svg: shape-60:", stderr)
+ self.assertIn("merge-covered cell R1C2 must be blank", stderr)
+ self.assertIn("Correct the reported JSON payload", stderr)
+ for incorrect in ("SVG-first", "projection validation", "remove the active", "Native-ready=no"):
+ self.assertNotIn(incorrect, stderr)
+
+ def test_svg_first_validation_keeps_projection_guidance(self) -> None:
+ self._write_svg(self._payload({"text": "hidden"}), json_first=False)
+ result, stderr = self._run_cli()
+ self.assertEqual(result, 1, stderr)
+ self.assertIn("SVG-first fallback", stderr)
+ self.assertIn("projection validation failed", stderr)
+ self.assertIn("Native-ready=no", stderr)
+ self.assertNotIn("JSON-first native payload validation failed", stderr)