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

feat(native_objects): guard chart chrome against invisible fallback text

hugohe334580721ff4a
diff --git a/skills/ppt-master/references/executor-base.md b/skills/ppt-master/references/executor-base.md
index 55a7146c..022903d1 100644
--- a/skills/ppt-master/references/executor-base.md
+++ b/skills/ppt-master/references/executor-base.md
@@ -231,7 +231,7 @@ grep "chart-plot-area" <project_path>/svg_output/<current_page>.svg
- Data labels: when visible point values are part of the fallback chart, write `data_labels` instead of companion text; use `data_labels.points` for selected labels, and use `number_format`, `font_size`, `font_family`, and per-point `colors` / `color` when the fallback labels carry suffixes or color-coded text.
- Line markers: when the fallback line chart draws visible point nodes, set `line_style: "lineMarker"`; leave the default `line` only for line charts without nodes.
- Area-under-line: when a combo plot is drawn as a filled area under a line, keep `type: "line"`, add `area_fill: true`, and copy the area transparency into `series[].fill_opacity`; copy visible line `stroke-width` into `series[].line_width` for line/area series.
-- Native chrome: write axis titles or `show_legend: true` only when the fallback visibly renders them inside the native chart's replacement scope. Write `name` (page-semantic, e.g. `p03-revenue-chart`) and explicit `x`/`y`/`width`/`height` read from the drawn plot area; omission is the fallback — the exporter then infers the frame from the drawn fallback geometry.
+- Native chrome: write `title`, `subtitle`, axis titles, or `show_legend: true` only when the fallback visibly renders the same chrome inside the native chart's replacement scope. `title` is the PowerPoint chart title, not an object name; use `name` for page-semantic object naming (e.g. `p03-revenue-chart`). Write explicit `x`/`y`/`width`/`height` read from the drawn plot area; omission is the fallback — the exporter then infers the frame from the drawn fallback geometry.
- Value-axis labels: when the fallback keeps category labels but intentionally omits numeric value-axis tick labels, set `show_value_axis_labels: false`.
- Freeform chart text: transcribe center labels, source notes, and other in-chart annotations as companion `caption` / `note` / `notes` entries with explicit slide-coordinate bounds; do not rely on fallback `<text>` children to survive native export.
- Native chart typography mirrors the SVG fallback. Copy the fallback's shared chart font into `style.font_family` and visible chart text sizes into the matching metadata fields (`title_font_size`, `subtitle_font_size`, `axis_font_size`, `note_font_size`, etc.) when role sizes differ; if omitted, the exporter infers shared font family and base chart text size from visible fallback text inside the native marker. When a visible chart title, subtitle, or axis title needs its own size/color/font, write that field as an object with `text`, `font_size`, `font_family`, and `color`. Use `axis_title_font_size`, `legend_font_size`, or companion per-entry `font_size` only when the fallback visibly uses a separate size. If a fallback role has no explicit size, use the compact three-tier chart defaults from [shared-standards.md](shared-standards.md).
diff --git a/skills/ppt-master/references/shared-standards.md b/skills/ppt-master/references/shared-standards.md
index 844641c6..4c11c203 100644
--- a/skills/ppt-master/references/shared-standards.md
+++ b/skills/ppt-master/references/shared-standards.md
@@ -813,13 +813,19 @@ default to compact PowerPoint text: `title_font_size: 16` (12pt),
`note_font_size: 12` (9pt).
**Chart chrome metadata**: Text that is visually part of the chart must be in
-metadata, not only in SVG fallback children. `title` becomes the native chart
-title on classic charts; `subtitle` becomes the second rich-text line of that
-classic chart title. `title`, `subtitle`, and axis-title values may be strings
-or objects with `text`, `font_size`, `font_family`, and `color` when the fallback uses local
-role typography. chartEx keeps PowerPoint's empty `<cx:title>` and emits the
-title / subtitle as companion editable text boxes until chartEx rich titles are
-validated. Axis titles are optional and explicit: use `axis_titles` with
+metadata, not only in SVG fallback children; metadata MUST still match visible
+fallback chrome. `title` becomes the native chart title on classic charts; it
+is not an object name, so use `name` for semantic object naming. `subtitle`
+becomes the second rich-text line of that classic chart title. `title`,
+`subtitle`, and axis-title values may be strings or objects with `text`,
+`font_size`, `font_family`, and `color` when the fallback uses local role
+typography. `svg_quality_checker.py` rejects `title`, `subtitle`, or axis-title
+metadata whose text is not visible inside the native marker's fallback. Direct
+`--native-objects` export keeps the chart native but omits that inconsistent
+chrome with a warning. chartEx keeps PowerPoint's empty `<cx:title>` and emits
+the title / subtitle as companion editable text boxes until chartEx rich titles
+are validated. Axis
+titles are optional and explicit: use `axis_titles` with
`category`, `value`, `x`, `y`, or `secondary_value` keys, or the root aliases
`category_axis_title`, `value_axis_title`, `x_axis_title`, `y_axis_title`, and
`secondary_value_axis_title`; do not add semantic axis titles that are not
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 4549bcb1..3b8ae27d 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
@@ -2,6 +2,7 @@
from __future__ import annotations
+import sys
from typing import Any
from xml.etree import ElementTree as ET
@@ -14,6 +15,9 @@ from .chart_style import (
_chart_companion_text_xml,
_chart_text_sizes,
_classic_chart_style,
+ _native_chart_chrome_errors,
+ _native_chart_chrome_warnings,
+ _native_chart_export_payload,
)
from .chart_xml import _chart_rels_xml, _chart_xml
from .chartex import (
@@ -158,6 +162,8 @@ def _build_native_chart(elem: ET.Element, ctx: ConvertContext, payload: dict[str
def _validate_native_object_marker_payload(
elem: ET.Element,
+ *,
+ validate_chrome: bool = True,
) -> tuple[str, dict[str, Any], list[list[Any]] | None]:
kind = (elem.get("data-pptx-native") or "").strip().lower()
if not kind:
@@ -177,6 +183,10 @@ def _validate_native_object_marker_payload(
table_rows, _ = _validate_table_payload(payload)
else:
_chart_data(payload)
+ if validate_chrome:
+ chrome_errors = _native_chart_chrome_errors(elem, payload)
+ if chrome_errors:
+ raise RuntimeError("; ".join(chrome_errors))
return kind, payload, table_rows
@@ -187,10 +197,12 @@ def validate_native_object_marker(elem: ET.Element) -> None:
def validate_native_object_marker_with_warnings(elem: ET.Element) -> list[str]:
"""Validate a data-pptx-native marker and return non-fatal warnings."""
- kind, _, table_rows = _validate_native_object_marker_payload(elem)
- if kind != "table" or table_rows is None:
- return []
- return _native_table_warnings(elem, table_rows)
+ kind, payload, table_rows = _validate_native_object_marker_payload(elem)
+ if kind == "table" and table_rows is not None:
+ return _native_table_warnings(elem, table_rows)
+ if kind == "chart":
+ return _native_chart_chrome_warnings(elem, payload)
+ return []
def native_object_marker_warnings(elem: ET.Element) -> list[str]:
@@ -203,15 +215,15 @@ def convert_native_object(elem: ET.Element, ctx: ConvertContext) -> ShapeResult
kind = (elem.get("data-pptx-native") or "").strip().lower()
if not kind:
return None
- if kind not in _NATIVE_KINDS:
- raise RuntimeError(f"Unsupported data-pptx-native value: {kind}")
- if _local_tag(elem) != "g":
- raise RuntimeError("Native PPTX table/chart markers must be <g> elements")
- transform = elem.get("transform", "")
- if transform and any(token in transform for token in ("rotate", "matrix", "skew")):
- raise RuntimeError("Native PPTX table/chart markers support translate/scale transforms only")
- payload = _load_payload(elem, kind)
+ kind, payload, _ = _validate_native_object_marker_payload(elem, validate_chrome=False)
if kind == "table":
return _build_native_table(elem, ctx, payload)
+ payload, warnings = _native_chart_export_payload(elem, payload)
+ marker_id = elem.get("id") or "<unnamed>"
+ for warning in warnings:
+ print(
+ f" Warning: data-pptx-native marker {marker_id}: {warning}",
+ file=sys.stderr,
+ )
return _build_native_chart(elem, ctx, payload)
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.py
index 7460d214..7204a0dc 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
@@ -25,8 +25,10 @@ from .marker_common import (
_maybe_number,
_most_common_color,
_number,
+ _normalized_fallback_text,
_relative_luminance,
_style_attr,
+ _visible_fallback_texts,
)
@@ -385,6 +387,30 @@ def _axis_title_xml(
)
+_AXIS_TITLE_KEY_GROUPS = {
+ "category": (
+ ("category",),
+ ("category_axis_title", "categoryAxisTitle"),
+ ),
+ "value": (
+ ("value",),
+ ("value_axis_title", "valueAxisTitle"),
+ ),
+ "x": (
+ ("x",),
+ ("x_axis_title", "xAxisTitle"),
+ ),
+ "y": (
+ ("y",),
+ ("y_axis_title", "yAxisTitle"),
+ ),
+ "secondary_value": (
+ ("secondary_value", "secondaryValue"),
+ ("secondary_value_axis_title", "secondaryValueAxisTitle"),
+ ),
+}
+
+
def _axis_titles(payload: dict[str, Any]) -> dict[str, Any]:
style = payload.get("style") if isinstance(payload.get("style"), dict) else {}
raw = payload.get("axis_titles", payload.get("axisTitles"))
@@ -407,23 +433,191 @@ def _axis_titles(payload: dict[str, Any]) -> dict[str, Any]:
return _first_present(*values)
return {
- "category": pick(
- ("category",),
- ("category_axis_title", "categoryAxisTitle"),
- ),
- "value": pick(
- ("value",),
- ("value_axis_title", "valueAxisTitle"),
- ),
- "x": pick(("x",), ("x_axis_title", "xAxisTitle")),
- "y": pick(("y",), ("y_axis_title", "yAxisTitle")),
- "secondary_value": pick(
- ("secondary_value", "secondaryValue"),
- ("secondary_value_axis_title", "secondaryValueAxisTitle"),
- ),
+ field_name: pick(axis_keys, root_keys)
+ for field_name, (axis_keys, root_keys) in _AXIS_TITLE_KEY_GROUPS.items()
}
+def _metadata_text(value: Any) -> str | None:
+ entry = _chart_text_entry(value)
+ if entry is None:
+ return None
+ text, _ = entry
+ return _normalized_fallback_text(text)
+
+
+def _native_chart_chrome_errors(elem: ET.Element, payload: dict[str, Any]) -> list[str]:
+ fallback_texts = set(_visible_fallback_texts(elem))
+ missing: list[str] = []
+
+ for field_name in ("title", "subtitle"):
+ text = _metadata_text(payload.get(field_name))
+ if text and text not in fallback_texts:
+ missing.append(f"{field_name}={text!r}")
+
+ for field_name, value in _axis_titles(payload).items():
+ text = _metadata_text(value)
+ if text and text not in fallback_texts:
+ missing.append(f"axis_titles.{field_name}={text!r}")
+
+ if not missing:
+ return []
+
+ sample = ", ".join(missing[:5])
+ suffix = "" if len(missing) <= 5 else f", and {len(missing) - 5} more"
+ return [
+ "Native PPTX chart metadata contains title/axis text that is not visible "
+ f"inside the fallback marker and would appear only after --native-objects: {sample}{suffix}. "
+ "Use `name` for object naming, or draw the same text in the chart fallback."
+ ]
+
+
+def _native_chart_export_payload(
+ elem: ET.Element,
+ payload: dict[str, Any],
+) -> tuple[dict[str, Any], list[str]]:
+ fallback_texts = set(_visible_fallback_texts(elem))
+ output = payload
+ messages: list[str] = []
+
+ def mutable_payload() -> dict[str, Any]:
+ nonlocal output
+ if output is payload:
+ output = dict(payload)
+ return output
+
+ def mutable_style(target: dict[str, Any]) -> dict[str, Any] | None:
+ style = target.get("style")
+ if not isinstance(style, dict):
+ return None
+ if target.get("style") is payload.get("style"):
+ style = dict(style)
+ target["style"] = style
+ return style
+
+ def drop_map_keys(source: dict[str, Any], map_key: str, keys: tuple[str, ...]) -> None:
+ raw_map = source.get(map_key)
+ if not isinstance(raw_map, dict):
+ return
+ next_map = dict(raw_map)
+ for key in keys:
+ next_map.pop(key, None)
+ if next_map:
+ source[map_key] = next_map
+ else:
+ source.pop(map_key, None)
+
+ for key in ("title", "subtitle"):
+ text = _metadata_text(payload.get(key))
+ if text and text not in fallback_texts:
+ mutable_payload().pop(key, None)
+ messages.append(
+ f"omitted native chart {key} {text!r} because it is not visible in the fallback"
+ )
+
+ for field_name, value in _axis_titles(payload).items():
+ text = _metadata_text(value)
+ if not text or text in fallback_texts:
+ continue
+ axis_keys, root_keys = _AXIS_TITLE_KEY_GROUPS[field_name]
+ target = mutable_payload()
+ for key in root_keys:
+ target.pop(key, None)
+ for map_key in ("axis_titles", "axisTitles"):
+ drop_map_keys(target, map_key, axis_keys + root_keys)
+ style = mutable_style(target)
+ if style is not None:
+ for key in root_keys:
+ style.pop(key, None)
+ for map_key in ("axis_titles", "axisTitles"):
+ drop_map_keys(style, map_key, axis_keys + root_keys)
+ messages.append(
+ f"omitted native chart axis_titles.{field_name} {text!r} "
+ "because it is not visible in the fallback"
+ )
+
+ style = payload.get("style") if isinstance(payload.get("style"), dict) else {}
+ show_legend = payload.get("show_legend", style.get("show_legend", False))
+ if show_legend:
+ legend_texts = _legend_candidate_texts(payload)
+ if legend_texts and not any(text in fallback_texts for text in legend_texts):
+ mutable_payload()["show_legend"] = False
+ messages.append(
+ "omitted native chart legend because show_legend=true has no "
+ "visible fallback legend text"
+ )
+
+ return output, messages
+
+
+def _legend_candidate_texts(payload: dict[str, Any]) -> list[str]:
+ series_values: list[str] = []
+ category_values: list[str] = []
+ categories = payload.get("categories")
+ if isinstance(categories, list):
+ category_values.extend(str(item) for item in categories if str(item).strip())
+ series = payload.get("series")
+ if isinstance(series, list):
+ for item in series:
+ if isinstance(item, dict) and item.get("name") is not None:
+ series_values.append(str(item.get("name")))
+ plots = payload.get("plots")
+ if isinstance(plots, list):
+ for plot in plots:
+ if not isinstance(plot, dict):
+ continue
+ plot_series = plot.get("series")
+ if not isinstance(plot_series, list):
+ continue
+ for item in plot_series:
+ if isinstance(item, dict) and item.get("name") is not None:
+ series_values.append(str(item.get("name")))
+ chart_type = _compact_key(payload.get("type") or payload.get("chart_type") or "")
+ category_legend_types = {"pie", "doughnut", "donut", "ofpie", "pieofpie", "barofpie"}
+ values = category_values if chart_type in category_legend_types else series_values
+ normalized: list[str] = []
+ for value in values:
+ text = _normalized_fallback_text(value)
+ if text:
+ normalized.append(text)
+ return normalized
+
+
+def _native_chart_chrome_warnings(elem: ET.Element, payload: dict[str, Any]) -> list[str]:
+ fallback_texts = set(_visible_fallback_texts(elem))
+ warnings: list[str] = []
+ style = payload.get("style") if isinstance(payload.get("style"), dict) else {}
+ show_legend = payload.get("show_legend", style.get("show_legend", False))
+ if show_legend:
+ legend_texts = _legend_candidate_texts(payload)
+ if legend_texts and not any(text in fallback_texts for text in legend_texts):
+ warnings.append(
+ "Native PPTX chart has show_legend=true, but no series/category "
+ "legend text is visible inside the fallback marker. Add the "
+ "fallback legend or remove show_legend."
+ )
+
+ companion_entries = _chart_companion_entries(
+ payload,
+ include_title=False,
+ include_subtitle_as_caption=False,
+ )
+ missing_companion: list[str] = []
+ for item in companion_entries:
+ text = _normalized_fallback_text(item.get("text"))
+ if text and text not in fallback_texts:
+ missing_companion.append(text)
+ if missing_companion:
+ sample = ", ".join(repr(text) for text in missing_companion[:5])
+ suffix = "" if len(missing_companion) <= 5 else f", and {len(missing_companion) - 5} more"
+ warnings.append(
+ "Native PPTX chart companion text is not visible inside the fallback "
+ f"marker and may appear only after --native-objects: {sample}{suffix}. "
+ "Keep companion metadata aligned with visible chart annotations."
+ )
+ return warnings
+
+
def _text_box_xml(
ctx: ConvertContext,
*,
diff --git a/skills/ppt-master/scripts/svg_to_pptx/native_objects/marker_common.py b/skills/ppt-master/scripts/svg_to_pptx/native_objects/marker_common.py
index 2eae315a..fa943c91 100644
--- a/skills/ppt-master/scripts/svg_to_pptx/native_objects/marker_common.py
+++ b/skills/ppt-master/scripts/svg_to_pptx/native_objects/marker_common.py
@@ -133,6 +133,36 @@ def _paint_visible(elem: ET.Element, paint: str) -> bool:
return True
+def _normalized_fallback_text(value: Any) -> str:
+ return re.sub(r"\s+", " ", str(value or "")).strip()
+
+
+def _visible_fallback_texts(elem: ET.Element, *, include_metadata: bool = False) -> list[str]:
+ texts: list[str] = []
+
+ def visit(node: ET.Element, hidden: bool) -> None:
+ tag = _local_tag(node)
+ if tag in {"defs", "clipPath", "mask", "filter", "style"}:
+ return
+ if tag == "metadata" and not include_metadata:
+ return
+ node_hidden = (
+ hidden
+ or _style_attr(node, "display") == "none"
+ or _style_attr(node, "visibility") == "hidden"
+ )
+ if tag == "text" and not node_hidden:
+ text = _normalized_fallback_text("".join(node.itertext()))
+ if text:
+ texts.append(text)
+ return
+ for child in node:
+ visit(child, node_hidden)
+
+ visit(elem, False)
+ return texts
+
+
def _number(value: Any, field_name: str) -> float:
try:
return float(value)
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 d71c11aa..6640a0ff 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
@@ -2,7 +2,6 @@
from __future__ import annotations
-import re
from typing import Any
from xml.etree import ElementTree as ET
@@ -18,8 +17,9 @@ from .marker_common import (
_compact_key,
_first_present,
_font_size_hpt,
- _local_tag,
+ _normalized_fallback_text,
_number,
+ _visible_fallback_texts,
)
@@ -150,35 +150,17 @@ def _validate_table_payload(payload: dict[str, Any]) -> tuple[list[list[Any]], i
return table_rows, col_count
-def _normalized_table_text(value: Any) -> str:
- return re.sub(r"\s+", " ", str(value or "")).strip()
-
-
def _native_table_metadata_texts(table_rows: list[list[Any]]) -> dict[str, int]:
counts: dict[str, int] = {}
for row in table_rows:
for cell in row:
cell_data = _cell_payload(cell)
- text = _normalized_table_text(cell_data.get("text"))
+ text = _normalized_fallback_text(cell_data.get("text"))
if text:
counts[text] = counts.get(text, 0) + 1
return counts
-def _visible_fallback_texts(elem: ET.Element) -> list[str]:
- texts: list[str] = []
- for child in elem.iter():
- tag = _local_tag(child)
- if tag != "text":
- continue
- if child.get("display") == "none" or child.get("visibility") == "hidden":
- continue
- text = _normalized_table_text("".join(child.itertext()))
- if text:
- texts.append(text)
- return texts
-
-
def _native_table_warnings(elem: ET.Element, table_rows: list[list[Any]]) -> list[str]:
fallback_texts = _visible_fallback_texts(elem)
if not fallback_texts: