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(hyperlinks): treat a bare anchor around one top-level group as transparent for animation and grouping

hugohe348238f997465
diff --git a/skills/ppt-master/references/native-hyperlinks.md b/skills/ppt-master/references/native-hyperlinks.md
index 85a5795e..24e71e5e 100644
--- a/skills/ppt-master/references/native-hyperlinks.md
+++ b/skills/ppt-master/references/native-hyperlinks.md
@@ -30,7 +30,7 @@ Authoring contract for PowerPoint-native click hyperlinks on complete objects an
**Hard rule — inline run**: visible text sits in one or more `<tspan>` children inside the anchor; the anchor and its descendants own no `x`, `y`, `dx`, or `dy` — line positioning belongs to the enclosing line `<tspan>` — in a multi-line paragraph the first line is no exception: its anchor also sits inside a line `<tspan>`, never in direct `<text>` content. A linked inline formula is one leaf formula `<tspan>` inside the anchor and keeps its native math contract.
-**Hard rule — whole-object hit area**: wrap at least one visible SVG element; no direct text or bare `<tspan>` in a shape anchor. A multi-object anchor links each exported leaf object; include an explicit background shape when gaps inside a button or card must also be clickable. Ordinary animation may target an outer top-level `<g>`, but a hyperlink-bearing group cannot also be an interactive `trigger_shape` — one click has one owner.
+**Hard rule — whole-object hit area**: wrap at least one visible SVG element; no direct text or bare `<tspan>` in a shape anchor. A multi-object anchor links each exported leaf object; include an explicit background shape when gaps inside a button or card must also be clickable. A bare anchor around one top-level `<g id>` is transparent: that group remains the page's top-level unit and animation anchor. Ordinary animation may target an outer top-level `<g>`, but a hyperlink-bearing group cannot also be an interactive `trigger_shape` — one click has one owner.
**Forbidden**: nested `<a>`; an anchor inside `defs`, metadata, geometry-detail, or a native-replacement subtree (a complete block formula or Chart/Table marker may be wrapped as one whole object, but its preview may not contain another anchor); authored `data-pptx-shape-hyperlink`, which PPTX import writes only when one source shape has both a whole-shape click and descendant run links, and which checker/export accept only on that logical group with at least one real inline `<a>` descendant.
diff --git a/skills/ppt-master/scripts/svg_quality/checker.py b/skills/ppt-master/scripts/svg_quality/checker.py
index d845ae95..9817e796 100644
--- a/skills/ppt-master/scripts/svg_quality/checker.py
+++ b/skills/ppt-master/scripts/svg_quality/checker.py
@@ -78,6 +78,7 @@ except ImportError:
try:
from svg_to_pptx.animation_config import (
+ effective_top_level as _effective_top_level,
load_animation_config as _load_animation_config,
usable_animation_group_id as _usable_animation_group_id,
validate_animation_config as _validate_animation_config,
@@ -85,6 +86,7 @@ try:
validate_transition_config as _validate_transition_config,
)
except ImportError as exc:
+ _effective_top_level = None
_load_animation_config = None
_validate_animation_config = None
_validate_animation_config_errors = None
@@ -5659,6 +5661,8 @@ class SVGQualityChecker:
visual_index = 0
for child in root:
+ if _effective_top_level is not None:
+ child = _effective_top_level(child)
tag = _local_name(child)
if tag in non_visual:
continue
@@ -5761,6 +5765,8 @@ class SVGQualityChecker:
signatures: List[Tuple[object, ...]] = []
visual_index = 0
for child in root:
+ if _effective_top_level is not None:
+ child = _effective_top_level(child)
tag = _local_name(child)
if tag in non_visual:
continue
diff --git a/skills/ppt-master/scripts/svg_to_pptx/animation_config.py b/skills/ppt-master/scripts/svg_to_pptx/animation_config.py
index ca6891e4..9a3221c4 100644
--- a/skills/ppt-master/scripts/svg_to_pptx/animation_config.py
+++ b/skills/ppt-master/scripts/svg_to_pptx/animation_config.py
@@ -34,7 +34,7 @@ from pptx_transitions import (
)
from slide_roster import discover_slide_svgs
-from .drawingml.utils import SVG_NS
+from .drawingml.utils import SVG_NS, XLINK_NS
from .pptx_package.narration import AUDIO_CONTENT_TYPES
from .semantic_markers import is_static_page_frame
@@ -201,6 +201,7 @@ def scan_root_primitives(svg_path: Path) -> dict[str, str]:
root = ET.parse(str(svg_path)).getroot()
primitives: dict[str, str] = {}
for child in root:
+ child = effective_top_level(child)
tag = _tag_name(child)
if tag in _NON_VISUAL_TAGS or tag == 'g':
continue
@@ -215,6 +216,39 @@ def scan_root_primitives(svg_path: Path) -> dict[str, str]:
return primitives
+_ANCHOR_OWN_ATTRIBUTES = frozenset((
+ 'href',
+ f'{{{XLINK_NS}}}href',
+ 'xlink:href',
+))
+
+
+def anchor_wrapped_group(elem: ET.Element) -> ET.Element | None:
+ """Return the single ``<g>`` a bare hyperlink anchor wraps, else ``None``.
+
+ ``<a href><g id>…</g></a>`` is the canonical whole-object link
+ (native-hyperlinks.md §2). The anchor carries only its target, so the
+ group inside is the page's real top-level unit: it stays the animation
+ anchor and the checker's grouping unit, and export attaches the click to
+ its leaves. An anchor with other attributes or several children is an
+ ordinary container.
+ """
+ if _tag_name(elem) != 'a':
+ return None
+ if any(attr not in _ANCHOR_OWN_ATTRIBUTES for attr in elem.attrib):
+ return None
+ visual = [child for child in elem if _tag_name(child) not in _NON_VISUAL_TAGS]
+ if len(visual) != 1 or _tag_name(visual[0]) != 'g':
+ return None
+ return visual[0]
+
+
+def effective_top_level(elem: ET.Element) -> ET.Element:
+ """Return the element a top-level scan should treat ``elem`` as."""
+ wrapped = anchor_wrapped_group(elem)
+ return elem if wrapped is None else wrapped
+
+
def usable_animation_group_id(raw: str | None) -> str | None:
"""Return one nonblank SVG animation anchor verbatim, else ``None``."""
return raw if raw and raw.strip() else None
@@ -237,6 +271,7 @@ def scan_svg_targets(
page_reference_size = _page_reference_size(root)
for child in root:
+ child = effective_top_level(child)
tag = _tag_name(child)
if tag in _NON_VISUAL_TAGS:
continue
diff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml/converter.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml/converter.py
index b0804223..cfe67305 100644
--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml/converter.py
+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml/converter.py
@@ -105,7 +105,12 @@ from .elements import (
project_image_errors,
project_nested_svg_crop_errors,
)
-from ..animation_config import is_chrome_id, usable_animation_group_id
+from ..animation_config import (
+ anchor_wrapped_group,
+ effective_top_level,
+ is_chrome_id,
+ usable_animation_group_id,
+)
from ..canvas_contract import (
CanvasContractError,
parse_project_svg_root,
@@ -1459,7 +1464,11 @@ def convert_g(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | None:
def convert_a(elem: ET.Element, ctx: ConvertContext) -> ShapeResult | None:
"""Convert one standard SVG anchor into a clickable DrawingML object."""
- result = convert_g(elem, ctx)
+ # A bare anchor around one <g> is transparent: the group converts at the
+ # anchor's own depth, so a top-level <a href><g id> stays an animation
+ # anchor, and the click lands on its leaves.
+ wrapped = anchor_wrapped_group(elem)
+ result = convert_g(wrapped if wrapped is not None else elem, ctx)
if result is None:
return None
return apply_shape_hyperlink(result, ctx, svg_hyperlink_href(elem))
@@ -2376,7 +2385,7 @@ def convert_svg_to_slide_shapes(
converted = 0
skipped = 0
has_top_level_group = any(
- child.tag.replace(f'{{{SVG_NS}}}', '') == 'g'
+ effective_top_level(child).tag.replace(f'{{{SVG_NS}}}', '') == 'g'
for child in root
)
background_xml, background_skip_id = (
@@ -2409,11 +2418,12 @@ def convert_svg_to_slide_shapes(
shapes.append(result.xml)
converted += 1
m = re.search(r'<p:cNvPr id="(\d+)"', result.xml)
- elem_id = child.get('id')
- role = child.get('data-pptx-role')
- placeholder = child.get('data-pptx-placeholder')
+ unit = effective_top_level(child)
+ elem_id = unit.get('id')
+ role = unit.get('data-pptx-role')
+ placeholder = unit.get('data-pptx-placeholder')
has_explicit_semantics = role is not None or placeholder is not None
- structurally_static = child.get('data-pptx-layer') is not None
+ structurally_static = unit.get('data-pptx-layer') is not None
legacy_chrome = (
is_static_page_frame(role, placeholder)
if has_explicit_semantics