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-editor): keep the default SVG namespace in preview and save (#323)
Ganesh M94df51ad4b3d
diff --git a/skills/ppt-master/scripts/svg_editor/server.py b/skills/ppt-master/scripts/svg_editor/server.pyindex a3483373..9bd531fd 100644--- a/skills/ppt-master/scripts/svg_editor/server.py+++ b/skills/ppt-master/scripts/svg_editor/server.py@@ -350,6 +350,21 @@ def _file_digest(path: Path) -> str:return hashlib.sha256(path.read_bytes()).hexdigest()+_SVG_NS = 'http://www.w3.org/2000/svg'+_XLINK_NS = 'http://www.w3.org/1999/xlink'+++def _register_svg_namespaces() -> None:+ """Bind the SVG namespace to the default prefix right before serializing.++ The ElementTree prefix map is process-global and ``pptx_ooxml.ooxml``+ (imported via ``svg_to_pptx``) claims the default prefix for its own+ namespace at import, so without this the slide comes out as ``<ns0:svg>``.+ """+ ET.register_namespace('', _SVG_NS)+ ET.register_namespace('xlink', _XLINK_NS)++def _atomic_replace(path: Path, write) -> None:"""Write through ``write(tmp_path)`` and swap the result into ``path``.@@ -885,6 +900,7 @@ def create_app(tag = tag.split('}', 1)[1]id_to_tag[eid] = tag_normalize_preview_hrefs(root)+ _register_svg_namespaces()content = ET.tostring(root, encoding='unicode', xml_declaration=False)content, warnings = _inline_icons(content,@@ -1201,6 +1217,7 @@ def create_app(annotated_ids = set(anns.keys())strip_unused_temp_ids(root, annotated_ids)+ _register_svg_namespaces()try:_atomic_replace(svg_file, lambda tmp: tree.write(str(tmp), encoding='UTF-8', xml_declaration=True,diff --git a/skills/ppt-master/scripts/tests/test_svg_editor_server.py b/skills/ppt-master/scripts/tests/test_svg_editor_server.pyindex c9fc619e..d35d177f 100644--- a/skills/ppt-master/scripts/tests/test_svg_editor_server.py+++ b/skills/ppt-master/scripts/tests/test_svg_editor_server.py@@ -196,6 +196,34 @@ class StagingDraftTests(unittest.TestCase):self.assertFalse(self.draft.exists())+class SvgNamespaceTests(unittest.TestCase):+ """Preview and save keep `<svg xmlns=...>` (issue #323)."""++ _client = StagingDraftTests._client+ _stage = StagingDraftTests._stage++ def setUp(self) -> None:+ StagingDraftTests.setUp(self)+ from xml.etree import ElementTree as ET+ from pptx_ooxml.ooxml import REL_NS+ # The state a running server is in: pptx_ooxml claims the default prefix at import.+ ET.register_namespace('', REL_NS)+ self.addCleanup(ET.register_namespace, '', 'http://www.w3.org/2000/svg')++ def test_slide_content_keeps_default_svg_namespace(self) -> None:+ content = self._client().get('/api/slide/01.svg').get_json()['content']+ self.assertTrue(content.startswith('<svg xmlns="http://www.w3.org/2000/svg"'), content[:80])+ self.assertNotIn('ns0:', content)++ def test_saved_svg_keeps_default_svg_namespace(self) -> None:+ client = self._client()+ self._stage(client)+ self.assertEqual(client.post('/api/save-all').get_json()['files_modified'], ['01.svg'])+ on_disk = self.svg_path.read_text(encoding='utf-8')+ self.assertIn('<svg xmlns="http://www.w3.org/2000/svg"', on_disk)+ self.assertNotIn('ns0:', on_disk)++class AnnotationHelperTests(unittest.TestCase):def test_user_ids_with_the_temp_prefix_are_kept(self) -> None:from xml.etree import ElementTree as ET