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 parity reads inherited text-anchor and tspan colour; right-to-left decks get RTL defaults
hugohe35771f4f0fe59
diff --git a/skills/ppt-master/scripts/docs/svg-pipeline.md b/skills/ppt-master/scripts/docs/svg-pipeline.mdindex ef5b56a5..a074e644 100644--- a/skills/ppt-master/scripts/docs/svg-pipeline.md+++ b/skills/ppt-master/scripts/docs/svg-pipeline.md@@ -756,6 +756,8 @@ Convert project SVGs into PPTX. EMF/WMF images referenced from `svg_output/` areEach exported object is named after `data-pptx-shape-name`, else its SVG `id` (or `data-name`), else a positional `Group N` / `TextBox N`; forced-Morph `!!` names still win. The PowerPoint Selection and Animation panes therefore read like the source SVG.+The lock's `primary_language` tags base-template default text (new text boxes, master and layout placeholders); a right-to-left language also makes those defaults right-to-left and right-aligned and points the theme's `Arab` / `Hebr` script font at the locked face.+Native formulas use the two markers owned by[`native-formula.md`](../../references/native-formula.md). A standalone blockstores delimiter-free LaTeX in the JSON metadata ofdiff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml/theme_fonts.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml/theme_fonts.pyindex c9c07cc5..7c69f864 100644--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml/theme_fonts.py+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml/theme_fonts.py@@ -9,6 +9,8 @@ from dataclasses import dataclassfrom pathlib import Pathfrom xml.etree import ElementTree as ET+from language_tags import language_base, language_uses_rtl+from .utils import font_px_to_hpt, parse_font_family@@ -53,6 +55,9 @@ class ThemeFontSpec:minor: ThemeFontFacemajor_family: strminor_family: str+ # Supplemental theme scripts (``Arab`` / ``Hebr``) a right-to-left deck+ # writes in; they take the locked complex-script face.+ rtl_scripts: tuple[str, ...] = ()@dataclass(frozen=True)@@ -196,6 +201,7 @@ def load_theme_font_spec(minor=_font_face(minor_family, language),major_family=major_family,minor_family=minor_family,+ rtl_scripts=_rtl_theme_scripts(language),)@@ -261,7 +267,18 @@ def theme_font_tokens(}-def _patch_font_collection(collection: ET.Element, face: ThemeFontFace) -> None:+def _rtl_theme_scripts(language: str | None) -> tuple[str, ...]:+ """Return the theme supplemental script a right-to-left language uses."""+ if not language or not language_uses_rtl(language):+ return ()+ return ("Hebr",) if language_base(language) in {"he", "yi"} else ("Arab",)+++def _patch_font_collection(+ collection: ET.Element,+ face: ThemeFontFace,+ rtl_scripts: tuple[str, ...] = (),+) -> None:for tag, value in (("latin", face.latin), ("ea", face.ea), ("cs", face.cs)):elem = collection.find(f"{{{DML_NS}}}{tag}")if elem is None:@@ -270,6 +287,8 @@ def _patch_font_collection(collection: ET.Element, face: ThemeFontFace) -> None:for supplemental in collection.findall(f"{{{DML_NS}}}font"):if supplemental.get("script") in _CJK_THEME_SCRIPTS:supplemental.set("typeface", face.ea)+ elif supplemental.get("script") in rtl_scripts:+ supplemental.set("typeface", face.cs)def apply_theme_font_spec(extract_dir: Path, spec: ThemeFontSpec) -> None:@@ -293,8 +312,8 @@ def apply_theme_font_spec(extract_dir: Path, spec: ThemeFontSpec) -> None:if major is None or minor is None:raise ThemeFontError(f"Theme has no major/minor font collection: {theme_path}")font_scheme.set("name", "PPT Master")- _patch_font_collection(major, spec.major)- _patch_font_collection(minor, spec.minor)+ _patch_font_collection(major, spec.major, spec.rtl_scripts)+ _patch_font_collection(minor, spec.minor, spec.rtl_scripts)tree.write(theme_path, encoding="utf-8", xml_declaration=True)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 a9fc5a1b..46141fdd 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@@ -49,6 +49,8 @@ from .inline_formula import ()from .marker_common import (_bounds,+ fallback_text_inheritance,+ inherited_text_attrs,CHART_COLOR_STYLE_CONTENT_TYPE,CHART_CONTENT_TYPE,CHART_REL_TYPE,@@ -634,18 +636,21 @@ def native_object_projection_warnings(elem: ET.Element,*,ancestors: tuple[ET.Element, ...] = (),+ document_root: ET.Element | None = None,) -> list[str]:"""Return SVG-first fallback details that marker metadata does not project."""kind, payload, validated_data = _validate_native_object_marker_payload(elem,ancestors=ancestors,)- return _projection_warnings_for_validated_marker(- elem,- kind,- payload,- validated_data,- )+ chain = (document_root, *ancestors) if document_root is not None else ancestors+ with fallback_text_inheritance(inherited_text_attrs(chain)):+ return _projection_warnings_for_validated_marker(+ elem,+ kind,+ payload,+ validated_data,+ )def validate_native_object_marker_with_warnings(@@ -669,14 +674,17 @@ def validate_native_object_marker_with_warnings(# The final checker reports these as warnings because activation is an# export-time choice; ``--native-charts-and-tables`` refuses the same# findings as errors, so say so where the author reads them.- warnings.extend(- f"{warning} (blocks --native-charts-and-tables export)"- for warning in _projection_warnings_for_validated_marker(+ chain = (document_root, *ancestors) if document_root is not None else ancestors+ with fallback_text_inheritance(inherited_text_attrs(chain)):+ projection = _projection_warnings_for_validated_marker(elem,kind,payload,validated_data,)+ warnings.extend(+ f"{warning} (blocks --native-charts-and-tables export)"+ for warning in projection)return warnings@@ -725,13 +733,16 @@ def convert_native_object(elem: ET.Element, ctx: ConvertContext) -> ShapeResultf" Warning: data-pptx-replace-with marker {marker_id}: {warning}",file=sys.stderr,)- if kind == "table":- return _build_native_table(elem, ctx, payload)- if payload.get("source_package") is None:- payload, warnings = _native_chart_export_payload(elem, payload)- for warning in warnings:- print(- f" Warning: data-pptx-replace-with marker {marker_id}: {warning}",- file=sys.stderr,- )- return _build_native_chart(elem, ctx, payload)+ # Fallback text read below starts from what the marker inherits (for+ # example a root-level text-anchor on a right-to-left page).+ with fallback_text_inheritance(ctx.inherited_styles):+ if kind == "table":+ return _build_native_table(elem, ctx, payload)+ if payload.get("source_package") is None:+ payload, warnings = _native_chart_export_payload(elem, payload)+ for warning in warnings:+ print(+ f" Warning: data-pptx-replace-with 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/marker_common.py b/skills/ppt-master/scripts/svg_to_pptx/native_objects/marker_common.pyindex 22d61b93..0eb72564 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@@ -2,10 +2,12 @@from __future__ import annotations+import contextvarsimport jsonimport mathimport re-from collections.abc import Iterable+from collections.abc import Iterable, Iterator+from contextlib import contextmanagerfrom dataclasses import dataclassfrom typing import Anyfrom xml.etree import ElementTree as ET@@ -613,15 +615,76 @@ def _fallback_shape_records(return records+_INHERITED_TEXT_ATTRS = ("fill", "font-weight", "text-anchor")+# fill / font-weight / text-anchor a marker inherits from outside its own+# subtree (root <svg> and ancestor groups); the record walk starts from them.+_FALLBACK_TEXT_INHERITANCE: contextvars.ContextVar[dict[str, str]] = (+ contextvars.ContextVar("_FALLBACK_TEXT_INHERITANCE", default={})+)+_UNSET: Any = object()+++def inherited_text_attrs(chain: Iterable[ET.Element]) -> dict[str, str]:+ """Resolve inherited text attributes along an outermost-first element chain."""+ values: dict[str, str] = {}+ for element in chain:+ for name in _INHERITED_TEXT_ATTRS:+ value = _style_attr(element, name)+ if value is not None:+ values[name] = value+ return values+++@contextmanager+def fallback_text_inheritance(values: dict[str, str]) -> Iterator[None]:+ """Let fallback text records start from a marker's inherited attributes."""+ token = _FALLBACK_TEXT_INHERITANCE.set(+ {name: value for name, value in values.items() if name in _INHERITED_TEXT_ATTRS}+ )+ try:+ yield+ finally:+ _FALLBACK_TEXT_INHERITANCE.reset(token)+++def _dominant_text_style(+ elem: ET.Element,+ fill: str | None,+ weight: str | None,+) -> tuple[str | None, str | None]:+ """Return the fill and weight carried by most visible characters."""+ counts: dict[tuple[str | None, str | None], int] = {}++ def visit(node: ET.Element, node_fill: str | None, node_weight: str | None) -> None:+ node_fill = _style_attr(node, "fill") or node_fill+ node_weight = _style_attr(node, "font-weight") or node_weight+ key = (node_fill, node_weight)+ counts[key] = counts.get(key, 0) + len("".join((node.text or "").split()))+ for child in node:+ visit(child, node_fill, node_weight)+ tail = len("".join((child.tail or "").split()))+ counts[key] = counts.get(key, 0) + tail++ visit(elem, fill, weight)+ return max(counts, key=counts.get) if any(counts.values()) else (fill, weight)++def _fallback_text_records(elem: ET.Element,matrix: tuple[float, float, float, float, float, float] = IDENTITY_MATRIX,- inherited_fill: str | None = "000000",- inherited_weight: str | None = None,- inherited_anchor: str | None = None,+ inherited_fill: str | None = _UNSET,+ inherited_weight: str | None = _UNSET,+ inherited_anchor: str | None = _UNSET,inherited_labels: tuple[str, ...] = (),) -> list[_FallbackTextRecord]:"""Collect visible fallback text with resolved paint, emphasis, and anchor."""+ outer = _FALLBACK_TEXT_INHERITANCE.get()+ if inherited_fill is _UNSET:+ inherited_fill = outer.get("fill", "000000")+ if inherited_weight is _UNSET:+ inherited_weight = outer.get("font-weight")+ if inherited_anchor is _UNSET:+ inherited_anchor = outer.get("text-anchor")tag = _local_tag(elem)if tag == "metadata" or tag in {"defs", "clipPath", "mask", "filter", "style"}:return []@@ -648,6 +711,10 @@ def _fallback_text_records(text = _normalized_fallback_text("".join(elem.itertext()))if not text:return []+ # A <text> whose visible characters mostly sit in styled <tspan>s+ # reads in their paint and weight (a whole cell set in an emphasis+ # tspan is that colour, not the <text> default).+ fill, weight = _dominant_text_style(elem, fill, weight)x = _project_geometry_number(elem, "x") if elem.get("x") is not None else Noney = _project_geometry_number(elem, "y") if elem.get("y") is not None else Noneif x is not None and y is not None: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 51d20113..48b5f926 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@@ -1739,6 +1739,7 @@ def _native_object_projection_findings(warnings = native_object_projection_warnings(elem,ancestors=tuple(reversed(ancestors)),+ document_root=root,)except RuntimeError as exc:warnings = [f"projection validation failed: {exc}"]diff --git a/skills/ppt-master/scripts/tests/test_dogfood_leaves_fixes.py b/skills/ppt-master/scripts/tests/test_dogfood_leaves_fixes.pyindex b34f10c6..f5d0c8b0 100644--- a/skills/ppt-master/scripts/tests/test_dogfood_leaves_fixes.py+++ b/skills/ppt-master/scripts/tests/test_dogfood_leaves_fixes.py@@ -483,6 +483,44 @@ class ArabicPdfTests(unittest.TestCase):self.assertEqual(pdf_to_md.arabic_text_layer_warnings(clean), [])+class RtlAndTemplateExportTests(unittest.TestCase):+ SVG_NS = "http://www.w3.org/2000/svg"++ def test_fallback_text_starts_from_inherited_anchor(self) -> None:+ from svg_to_pptx.native_objects.marker_common import (+ _fallback_text_records, fallback_text_inheritance, inherited_text_attrs)+ root = ET.fromstring(+ f'<svg xmlns="{self.SVG_NS}" text-anchor="end" fill="#2B1D15">'+ '<g id="m"><text x="10" y="10">كلمة</text></g></svg>')+ marker = root[0]+ with fallback_text_inheritance(inherited_text_attrs([root])):+ [record] = _fallback_text_records(marker)+ self.assertEqual((record.anchor, record.fill), ("end", "2B1D15"))++ def test_text_in_one_emphasis_tspan_reads_in_its_colour(self) -> None:+ from svg_to_pptx.native_objects.marker_common import _fallback_text_records+ marker = ET.fromstring(+ f'<g xmlns="{self.SVG_NS}" fill="#2B1D15">'+ '<text x="1" y="1"><tspan fill="#5E7D4F" font-weight="bold">الهيل</tspan></text>'+ '<text x="1" y="9"><tspan fill="#5E7D4F">الهيل</tspan> والزعفران والقرفة</text></g>')+ whole, mixed = _fallback_text_records(marker)+ self.assertEqual((whole.fill, whole.bold), ("5E7D4F", True))+ self.assertEqual(mixed.fill, "2B1D15")++ def test_rtl_template_levels_flip(self) -> None:+ from svg_to_pptx.pptx_package.builder import _rtl_text_levels+ xml = '<a:lvl1pPr marL="0" algn="l" rtl="0"/><a:lvl1pPr algn="ctr" rtl="0"/>'+ self.assertEqual(+ _rtl_text_levels(xml),+ '<a:lvl1pPr marL="0" algn="r" rtl="1"/><a:lvl1pPr algn="ctr" rtl="1"/>')++ def test_rtl_theme_script_slot(self) -> None:+ from svg_to_pptx.drawingml.theme_fonts import _rtl_theme_scripts+ self.assertEqual(_rtl_theme_scripts("ar-SA"), ("Arab",))+ self.assertEqual(_rtl_theme_scripts("he-IL"), ("Hebr",))+ self.assertEqual(_rtl_theme_scripts("zh-CN"), ())++class SlideSizeTypeTests(unittest.TestCase):def test_standard_ratios_keep_their_token(self) -> None:self.assertEqual(_slide_size_type(12192000, 6858000), "screen16x9")