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(svg-to-pptx): protect imported text run effects
hugohe3959f9a863d2e
diff --git a/docs/powerpoint-svg-mapping.md b/docs/powerpoint-svg-mapping.mdindex 671bcddb..5fbb110a 100644--- a/docs/powerpoint-svg-mapping.md+++ b/docs/powerpoint-svg-mapping.md@@ -160,9 +160,10 @@ preset selection and authoring behavior are documented in| Line arrowheads | Registered start/end markers | Native head/tail end properties | `Approximate` for marker size | See the conditional marker contract || Outer shadow | One supported shadow filter graph | Native outer shadow in `a:effectLst` | `Approximate`; one imported shape/connector source `outerShdw` is reconstructed only when its non-zero offset remains classifiable | Zero-offset source shadows and unsupported graph shapes are not silently reclassified || Glow | One supported glow filter graph | Native glow in `a:effectLst` | `Approximate`; one imported shape/connector source glow keeps the registered radius conversion | Review when the glow carries semantic emphasis |+| Imported text-run effect | Unchanged `metadata[data-pptx-part="txbody"]` on a logical shape | Original native run effect inside `p:txBody` | `Native-stable` only while the raw payload remains usable; edits that would drop a non-empty run `effectLst` / `effectDag` block | Not public authoring syntax; the separate vertical-text output, relationship-bearing text bodies, and table-cell text bodies remain outside this guard || Whole-object transparency | Atomic element `opacity` | Alpha distributed into supported native channels | `Native-normalized` | Prefer channel-specific alpha unless the whole atomic object fades || Group transparency | Compatible `<g opacity>` | Descendant-normalized approximation | `Approximate` with a warning | Generated SVG should prefer descendant alpha |-| Inner shadow, soft edge, reflection, blur, turbulence, blend mode, or arbitrary mask | No registered native mapping | Explicit geometry alternative or raster asset | `Bake-required`; PPTX import keeps the base object and emits blocking diagnostics for unsupported shape/connector effects, picture/group effect DAGs, and non-empty picture/group effect lists | Handled object effects cannot be reclassified or omitted; text-run source effects remain outside this diagnostic path |+| Inner shadow, soft edge, reflection, blur, turbulence, blend mode, or arbitrary mask | No registered native mapping | Explicit geometry alternative or raster asset | `Bake-required`; PPTX import keeps the base object and emits blocking diagnostics for unsupported shape/connector effects, picture/group effect DAGs, and non-empty picture/group effect lists | Handled object effects cannot be reclassified or omitted; text-run safety follows the unchanged-`txBody` row above |## 7. PowerPoint tablesdiff --git a/docs/zh/powerpoint-svg-mapping.md b/docs/zh/powerpoint-svg-mapping.mdindex 49029ec3..e5e29c35 100644--- a/docs/zh/powerpoint-svg-mapping.md+++ b/docs/zh/powerpoint-svg-mapping.md@@ -155,9 +155,10 @@ PowerPoint 意图| 线条箭头 | 已登记起点/终点 marker | 原生 head/tail end 属性 | marker 大小为 `Approximate` | 见条件 marker 合同 || 外阴影 | 一个受支持 shadow filter 图 | `a:effectLst` 中的原生外阴影 | `Approximate`;仅当非零偏移仍可稳定分类时,才重建单一 shape/connector 来源 `outerShdw` | 零偏移来源阴影和不支持的图结构不会被静默改成其他效果 || 发光 | 一个受支持 glow filter 图 | `a:effectLst` 中的原生发光 | `Approximate`;单一 shape/connector 来源发光保持已登记的半径换算 | 发光承载语义强调时需复核 |+| 导入的文字 run 效果 | 逻辑 shape 上未变更的 `metadata[data-pptx-part="txbody"]` | `p:txBody` 内原始原生 run 效果 | 仅在原始 payload 仍可用时为 `Native-stable`;会丢失非空 run `effectLst` / `effectDag` 的编辑将被阻断 | 不是公开创作语法;独立竖排输出路径、含关系引用的文本内容及表格单元格文本尚不在该保护范围内 || 整个对象透明度 | 原子元素 `opacity` | alpha 分发至受支持原生通道 | `Native-normalized` | 除非整个原子对象需要淡出,否则优先通道专属 alpha || 组透明度 | 兼容 `<g opacity>` | 后代归一化近似 | `Approximate`,并产生 warning | 生成 SVG 应优先后代 alpha |-| 内阴影、柔化边缘、倒影、模糊、湍流、混合模式或任意 mask | 无已登记原生映射 | 显式几何替代或栅格资产 | `Bake-required`;PPTX 回导保留基础对象,并对不支持的 shape/connector 效果、图片/组效果 DAG 及非空图片/组效果列表产生阻塞诊断 | 已处理的对象效果不能被改成其他类型或静默省略;文字 run 的来源效果尚不在该诊断路径内 |+| 内阴影、柔化边缘、倒影、模糊、湍流、混合模式或任意 mask | 无已登记原生映射 | 显式几何替代或栅格资产 | `Bake-required`;PPTX 回导保留基础对象,并对不支持的 shape/connector 效果、图片/组效果 DAG 及非空图片/组效果列表产生阻塞诊断 | 已处理的对象效果不能被改成其他类型或静默省略;文字 run 安全边界见上方未变更 `txBody` 行 |## 7. PowerPoint 表格diff --git a/skills/ppt-master/references/shared-standards.md b/skills/ppt-master/references/shared-standards.mdindex 1629e8be..bbee6b84 100644--- a/skills/ppt-master/references/shared-standards.md+++ b/skills/ppt-master/references/shared-standards.md@@ -277,7 +277,7 @@ attributes, and no separate source-payload opt-in marker exists.| `data-pptx-start/end-shape-id/site` | Connector logical `<g>` and carrier | Restore `a:stCxn` / `a:endCxn` after scoped shape-id allocation. A connector may retain one zero frame axis; it must not be expanded from visible stroke or marker bounds. || `data-pptx-shape-style` | Native carrier | Preserve a relationship-free `p:style` independently of text, including shapes with no visible text. || `data-pptx-effect-status="unsupported"` + `data-pptx-effect-reason` | Imported `p:sp` / `p:cxnSp` logical object and native carrier; imported `p:pic` carrier and logical object; imported `p:grpSp` logical group | Record why an encountered source `effectLst` / `effectDag` cannot enter the registered target-specific effect mapping without changing semantics. Checker and export stop with the recorded reason; these attributes are diagnostics, not a preserved effect payload or authoring syntax. |-| `metadata[data-pptx-part="txbody"]` | Logical shape `<g>` | Preserve unchanged `p:txBody`, including an empty text body. Content, whitespace, positioning, or visible typography edits invalidate the payload and use the normal SVG text fallback. |+| `metadata[data-pptx-part="txbody"]` | Logical shape `<g>` | Preserve unchanged `p:txBody`, including an empty text body. Content, whitespace, positioning, visible typography, or incompatible child-topology edits invalidate the payload. A source payload with run-level effects then blocks checker/export instead of losing those effects; an effect-free payload uses the normal SVG text fallback. |**Import/authoring representation split**:@@ -784,6 +784,14 @@ Picture and group targets do not expose the public filter mapping: any sourceeffect DAG or non-empty effect list on `p:pic/p:spPr` or `p:grpSp/p:grpSpPr`keeps the base object but receives effect-status metadata instead of attachingan invalid filter to `<image>` or ordinary `<g>`.+Imported metadata-backed logical shapes preserve run-level effects only inside an+unchanged `metadata[data-pptx-part="txbody"]` payload. If visible text,+typography, or child topology invalidates that payload, checker and exporter+stop when the source `rPr` / `defRPr` / `endParaRPr` contains a non-empty+`effectLst` or `effectDag`; effect-free edited text keeps the normal fallback.+This conditional guard is not a public run-effect authoring surface and does+not cover the separate vertical-text output, relationship-bearing text bodies,+or table-cell text bodies.The quality checker and exporter preflight enforce the same definition,reference, primitive, target, and numeric-value contract; malformed values arenever replaced by effect defaults during native export.@@ -1316,8 +1324,11 @@ Before release export, rasterize the affected object from the source PPTX orrebuild its effect with supported explicit geometry; baking the effect-lessanalysis SVG alone cannot recover the source appearance. This diagnostic pathcovers `p:sp`, `p:cxnSp`, `p:pic`, and `p:grpSp` source effects. Text-run source-effects remain outside it and are not claimed as preserved. Handled object-effects must never become a different effect or disappear without a diagnostic.+effects do not use effect-status metadata; the metadata-backed logical-shape+guard in §6.4 preserves them unchanged or blocks a lossy edit. Other text-body+routes remain outside that guard and are not claimed as preserved. Handled+object effects must never become a different effect or disappear without a+diagnostic.---diff --git a/skills/ppt-master/scripts/svg_quality_checker.py b/skills/ppt-master/scripts/svg_quality_checker.pyindex 50d978bc..9edb0a50 100644--- a/skills/ppt-master/scripts/svg_quality_checker.py+++ b/skills/ppt-master/scripts/svg_quality_checker.py@@ -1248,6 +1248,7 @@ class SVGQualityChecker:# conditional definition interfaces before export.self._check_authoring_property_contract(root, result)self._check_text_property_contract(root, result)+ self._check_preserved_txbody_contract(root, result)self._check_paint_compatibility(root, result)self._check_reference_spelling(root, result)self._check_definition_contract(root, result)@@ -2617,7 +2618,6 @@ class SVGQualityChecker:@staticmethoddef _unchanged_txbody_group_ids(root: ET.Element,- errors: List[str] | None = None,) -> set[int]:"""Return imported shape groups whose original text body will survive."""if _preserved_native_text_body is None:@@ -2630,14 +2630,33 @@ class SVGQualityChecker:trust_runtime_snapshot=False,) is not None:unchanged.add(id(group))- except _SvgNativeConversionError as exc:- if errors is not None:- errors.append(- f'{_element_label(group)} has invalid preserved '- f'txBody metadata: {exc}'- )+ except _SvgNativeConversionError:+ # The dedicated txBody contract check owns the diagnostic.+ continuereturn unchanged+ @staticmethod+ def _check_preserved_txbody_contract(+ root: ET.Element,+ result: Dict,+ ) -> None:+ """Validate imported txBody payloads independently of text geometry."""+ if _preserved_native_text_body is None:+ return+ errors: set[str] = set()+ for group in root.iter(f'{{{SVG_NS}}}g'):+ try:+ _preserved_native_text_body(+ group,+ trust_runtime_snapshot=False,+ )+ except _SvgNativeConversionError as exc:+ errors.add(+ f'{_element_label(group)} cannot preserve source '+ f'txBody: {exc}'+ )+ result['errors'].extend(sorted(errors))+@staticmethoddef _has_ancestor_id(elem: ET.Element,@@ -2815,10 +2834,7 @@ class SVGQualityChecker:for parent in root.iter()for child in list(parent)}- unchanged_groups = self._unchanged_txbody_group_ids(- root,- result['errors'],- )+ unchanged_groups = self._unchanged_txbody_group_ids(root)errors: List[str] = []for text_el in root.iter(f'{{{SVG_NS}}}text'):chain: List[ET.Element] = []diff --git a/skills/ppt-master/scripts/svg_to_pptx/drawingml/converter.py b/skills/ppt-master/scripts/svg_to_pptx/drawingml/converter.pyindex 657fd58a..f3da51cb 100644--- a/skills/ppt-master/scripts/svg_to_pptx/drawingml/converter.py+++ b/skills/ppt-master/scripts/svg_to_pptx/drawingml/converter.py@@ -455,6 +455,14 @@ def _txbody_metadata(elem: ET.Element) -> ET.Element | None:_TXBODY_UNCHANGED_ATTR = 'data-pptx-runtime-txbody-unchanged'_PREVIEW_UNCHANGED_ATTR = 'data-pptx-runtime-preview-unchanged'+_DML_NAMESPACE = 'http://schemas.openxmlformats.org/drawingml/2006/main'+_TEXT_PROPERTY_TAGS = frozenset({+ f'{{{_DML_NAMESPACE}}}defRPr',+ f'{{{_DML_NAMESPACE}}}endParaRPr',+ f'{{{_DML_NAMESPACE}}}rPr',+})+_EFFECT_LIST_TAG = f'{{{_DML_NAMESPACE}}}effectLst'+_EFFECT_DAG_TAG = f'{{{_DML_NAMESPACE}}}effectDag'def _mark_unchanged_txbody_groups(root: ET.Element) -> None:@@ -518,7 +526,7 @@ def _decode_unchanged_txbody(metadata: ET.Element,*,trust_runtime_snapshot: bool = True,-) -> str | None:+) -> tuple[str, bool] | None:expected_hash = metadata.get('data-pptx-text-sha256')if not expected_hash:raise SvgNativeConversionError('txbody metadata requires a text hash')@@ -526,10 +534,10 @@ def _decode_unchanged_txbody(group.get(_TXBODY_UNCHANGED_ATTR)if trust_runtime_snapshot else None)- if snapshot == '0':- return None- if snapshot != '1' and svg_text_fingerprint(group) != expected_hash:- return None+ unchanged = snapshot == '1' or (+ snapshot != '0'+ and svg_text_fingerprint(group) == expected_hash+ )if metadata.get('data-pptx-encoding') != 'base64':raise SvgNativeConversionError('txbody metadata requires base64 encoding')try:@@ -546,7 +554,29 @@ def _decode_unchanged_txbody(raise SvgNativeConversionError('txbody metadata must not contain part-local relationship attributes')- return decoded+ if not unchanged:+ if _txbody_has_run_effects(txbody):+ raise SvgNativeConversionError(+ 'Visible text or typography was edited while the source '+ 'txBody contains run-level effects; export stopped to avoid '+ 'silently discarding those effects'+ )+ return None+ return decoded, _txbody_has_run_effects(txbody)+++def _txbody_has_run_effects(txbody: ET.Element) -> bool:+ """Return whether fallback text rebuilding would discard a run effect."""+ for properties in txbody.iter():+ if properties.tag not in _TEXT_PROPERTY_TAGS:+ continue+ for child in properties:+ if child.tag in {_EFFECT_LIST_TAG, _EFFECT_DAG_TAG} and any(+ isinstance(effect.tag, str)+ for effect in child+ ):+ return True+ return Falsedef _append_shape_text(@@ -584,7 +614,7 @@ def preserved_native_text_body()if not logical_text_shape:return None- native_text = _decode_unchanged_txbody(+ decoded_text = _decode_unchanged_txbody(group,metadata,trust_runtime_snapshot=trust_runtime_snapshot,@@ -604,9 +634,16 @@ def preserved_native_text_body(and child.get('data-pptx-part') not in allowed_partsfor child in group)- if len(carrier_children) != 1 or has_foreign_visual:+ if decoded_text is None:return None- if native_text is None:+ native_text, has_run_effects = decoded_text+ if len(carrier_children) != 1 or has_foreign_visual:+ if has_run_effects:+ raise SvgNativeConversionError(+ 'The source txBody contains run-level effects but cannot be '+ 'restored as one native text shape; export stopped to avoid '+ 'silently discarding those effects'+ )return Nonereturn carrier_children[0], native_textdiff --git a/skills/ppt-master/scripts/test_svg_quality_checker.py b/skills/ppt-master/scripts/test_svg_quality_checker.pyindex 58e8f043..11558525 100644--- a/skills/ppt-master/scripts/test_svg_quality_checker.py+++ b/skills/ppt-master/scripts/test_svg_quality_checker.py@@ -57,6 +57,7 @@ from svg_to_pptx.canvas_contract import ()from svg_to_pptx.drawingml.converter import (SvgNativeConversionError,+ _txbody_has_run_effects,convert_svg_to_slide_shapes,)from svg_to_pptx.pptx_package.builder import create_pptx_with_native_svg@@ -362,13 +363,20 @@ class SVGQualityCheckerCompatibilityTests(unittest.TestCase):]@staticmethod- def _native_txbody_payload() -> str:+ def _native_txbody_payload(*, run_effect: bool = False) -> str:+ effect_xml = (+ '<a:effectLst><a:outerShdw blurRad="38100" dist="38100" '+ 'dir="5400000"><a:srgbClr val="000000"/>'+ '</a:outerShdw></a:effectLst>'+ if run_effect else ''+ )native_txbody = ('<p:txBody ''xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" ''xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">''<a:bodyPr/><a:lstStyle/><a:p><a:r>'- '<a:rPr lang="en-US" sz="1500" spc="-7500"/>'+ '<a:rPr lang="en-US" sz="1500" spc="-7500">'+ f'{effect_xml}</a:rPr>''<a:t>AB</a:t></a:r></a:p></p:txBody>')return base64.b64encode(native_txbody.encode('utf-8')).decode('ascii')@@ -4207,9 +4215,135 @@ class SVGQualityCheckerCompatibilityTests(unittest.TestCase):metadata.text = 'not-base64'result = {'errors': [], 'warnings': []}- SVGQualityChecker()._check_text_output_geometry(root, result)+ SVGQualityChecker()._check_preserved_txbody_contract(root, result)++ self.assertIn('cannot preserve source txBody', '\n'.join(result['errors']))++ def test_edited_imported_text_cannot_drop_run_effects(self):+ def imported_text_root(*, run_effect: bool) -> ET.Element:+ root = ET.fromstring(+ '''<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 360">+ <g id="imported-shape" data-pptx-object="shape" data-pptx-prst="rect">+ <rect data-pptx-part="geometry" x="20" y="40" width="160" height="80"+ fill="#FFFFFF"/>+ <text x="40" y="100" font-size="20">AB</text>+ </g>+</svg>'''+ )+ group = next(root.iter('{http://www.w3.org/2000/svg}g'))+ metadata = ET.SubElement(+ group,+ '{http://www.w3.org/2000/svg}metadata',+ {+ 'data-pptx-part': 'txbody',+ 'data-pptx-encoding': 'base64',+ 'data-pptx-text-sha256': svg_text_fingerprint(group),+ },+ )+ metadata.text = self._native_txbody_payload(+ run_effect=run_effect,+ )+ return root++ unchanged = imported_text_root(run_effect=True)+ with tempfile.TemporaryDirectory() as tmp_dir:+ unchanged_path = Path(tmp_dir) / 'unchanged-run-effect.svg'+ unchanged_path.write_text(+ ET.tostring(unchanged, encoding='unicode'),+ encoding='utf-8',+ )+ unchanged_xml = convert_svg_to_slide_shapes(unchanged_path)[0]+ self.assertEqual(unchanged_xml.count('<a:outerShdw'), 1)++ structurally_changed = imported_text_root(run_effect=True)+ group = next(+ structurally_changed.iter('{http://www.w3.org/2000/svg}g')+ )+ group.append(ET.fromstring(+ '<circle xmlns="http://www.w3.org/2000/svg" cx="220" cy="80" '+ 'r="12" fill="#2563EB"/>'+ ))+ with tempfile.TemporaryDirectory() as tmp_dir:+ structural_path = Path(tmp_dir) / 'structural-run-effect.svg'+ structural_path.write_text(+ ET.tostring(structurally_changed, encoding='unicode'),+ encoding='utf-8',+ )+ structural_result = SVGQualityChecker().check_file(+ str(structural_path)+ )+ self.assertFalse(structural_result['passed'])+ self.assertIn(+ 'cannot be restored as one native text shape',+ '\n'.join(structural_result['errors']),+ )+ with self.assertRaisesRegex(+ SvgNativeConversionError,+ 'cannot be restored as one native text shape',+ ):+ convert_svg_to_slide_shapes(structural_path)++ edited = imported_text_root(run_effect=True)+ next(edited.iter('{http://www.w3.org/2000/svg}text')).text = 'AC'+ with tempfile.TemporaryDirectory() as tmp_dir:+ edited_path = Path(tmp_dir) / 'edited-run-effect.svg'+ edited_path.write_text(+ ET.tostring(edited, encoding='unicode'),+ encoding='utf-8',+ )+ checker_result = SVGQualityChecker().check_file(str(edited_path))+ self.assertFalse(checker_result['passed'])+ self.assertIn(+ 'source txBody contains run-level effects',+ '\n'.join(checker_result['errors']),+ )+ with self.assertRaisesRegex(+ SvgNativeConversionError,+ 'source txBody contains run-level effects',+ ):+ convert_svg_to_slide_shapes(edited_path)++ editable = imported_text_root(run_effect=False)+ next(editable.iter('{http://www.w3.org/2000/svg}text')).text = 'AC'+ with tempfile.TemporaryDirectory() as tmp_dir:+ editable_path = Path(tmp_dir) / 'edited-plain-text.svg'+ editable_path.write_text(+ ET.tostring(editable, encoding='unicode'),+ encoding='utf-8',+ )+ editable_result = SVGQualityChecker().check_file(str(editable_path))+ self.assertTrue(editable_result['passed'])+ editable_xml = convert_svg_to_slide_shapes(editable_path)[0]+ self.assertNotIn('<a:outerShdw', editable_xml)+ self.assertIn('<a:t>AC</a:t>', editable_xml)++ def test_txbody_run_effect_detection_covers_inherited_properties(self):+ dml = 'http://schemas.openxmlformats.org/drawingml/2006/main'+ pml = 'http://schemas.openxmlformats.org/presentationml/2006/main'++ def txbody(properties: str) -> ET.Element:+ return ET.fromstring(+ f'<p:txBody xmlns:p="{pml}" xmlns:a="{dml}">'+ f'<a:bodyPr/><a:lstStyle/>{properties}</p:txBody>'+ )++ inherited_list = txbody(+ '<a:p><a:pPr><a:defRPr><a:effectLst>'+ '<a:glow rad="38100"><a:srgbClr val="000000"/></a:glow>'+ '</a:effectLst></a:defRPr></a:pPr></a:p>'+ )+ paragraph_end_dag = txbody(+ '<a:p><a:endParaRPr><a:effectDag><a:blur rad="38100"/>'+ '</a:effectDag></a:endParaRPr></a:p>'+ )+ empty_containers = txbody(+ '<a:p><a:r><a:rPr><a:effectLst/><a:effectDag/></a:rPr>'+ '<a:t>AB</a:t></a:r></a:p>'+ )- self.assertIn('invalid preserved txBody metadata', '\n'.join(result['errors']))+ self.assertTrue(_txbody_has_run_effects(inherited_list))+ self.assertTrue(_txbody_has_run_effects(paragraph_end_dag))+ self.assertFalse(_txbody_has_run_effects(empty_containers))def test_checker_does_not_trust_authored_runtime_txbody_snapshot(self):root = ET.fromstring(