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(source-to-md): read the Fallback of AlternateContent ppt_to_md cannot use
hugohe3fd17372d1b3d
diff --git a/skills/ppt-master/scripts/docs/conversion.md b/skills/ppt-master/scripts/docs/conversion.mdindex 0f89418e..733e0af0 100644--- a/skills/ppt-master/scripts/docs/conversion.md+++ b/skills/ppt-master/scripts/docs/conversion.md@@ -234,6 +234,7 @@ python3 scripts/source_to_md/ppt_to_md.py template.ppsx -o notes/template.mdBehavior:- extracts slide text in reading order- rewrites Office Math equations (`a14:m` OMML) as `$...$` inline or `$$...$$` display LaTeX, using the same converter as `.docx`+- reads the `mc:Fallback` of other shape-tree `mc:AlternateContent` it cannot interpret (3D models, ink, zoom), so their preview pictures and text are kept; ChartEx stays reported as unsupported- converts PowerPoint tables to Markdown tables; cell-internal line breaks become `<br>` so they cannot break the pipe-table row structure- transcribes category charts as category × series tables and scatter/bubble charts as typed X/Y[/size] point tables- preserves every readable chart dimension or series and emits `[Chart data warning: <reason>]` for missing caches/count mismatches; `[Chart data unavailable: <reason>]` is reserved for charts with no readable points (and unsupported ChartEx), so XY data is never flattened into a misleading category tablediff --git a/skills/ppt-master/scripts/source_to_md/ppt_to_md.py b/skills/ppt-master/scripts/source_to_md/ppt_to_md.pyindex 0d082f03..62d43e97 100644--- a/skills/ppt-master/scripts/source_to_md/ppt_to_md.py+++ b/skills/ppt-master/scripts/source_to_md/ppt_to_md.py@@ -217,6 +217,37 @@ def _expose_math_choice_shapes(slide: object) -> None:parent.insert(index + offset, shape)+def _expose_alternate_fallback_shapes(slide: object) -> None:+ """Read the Fallback of shape-tree ``mc:AlternateContent`` this reader cannot use.++ Office Math Choices are exposed by ``_expose_math_choice_shapes`` and ChartEx+ is reported by ``_unexposed_chartex_markdown``. Any other Choice (3D models,+ ink, zoom) is unreadable here, so its Fallback, which is what PowerPoint+ without that feature shows, keeps pictures and text from vanishing.+ """+ alternate_tag = f"{{{MARKUP_COMPATIBILITY_NS}}}AlternateContent"+ fallback_tag = f"{{{MARKUP_COMPATIBILITY_NS}}}Fallback"+ shape_tags = {+ f"{{{PRESENTATIONML_NS}}}{name}"+ for name in ("sp", "grpSp", "pic", "graphicFrame", "cxnSp")+ }+ for wrapper in list(slide.element.iter(alternate_tag)):+ fallback = wrapper.find(fallback_tag)+ parent = wrapper.getparent()+ if fallback is None or parent is None or any(+ data.get("uri") == CHARTEX_URI+ for data in wrapper.iter(f"{{{DRAWINGML_NS}}}graphicData")+ ):+ continue+ shapes = list(fallback)+ if not shapes or any(shape.tag not in shape_tags for shape in shapes):+ continue+ index = parent.index(wrapper)+ parent.remove(wrapper)+ for offset, shape in enumerate(shapes):+ parent.insert(index + offset, shape)++def iter_leaf_shapes(shapes: object) -> list[LeafShape]:"""Return a flattened, reading-order list of shapes."""items: list[LeafShape] = []@@ -1326,6 +1357,7 @@ def convert_presentation_to_markdown(emitted_diagram_ids: set[str] = set()emitted_chart_relationship_ids: set[str] = set()_expose_math_choice_shapes(slide)+ _expose_alternate_fallback_shapes(slide)for item in iter_leaf_shapes(slide.shapes):shape = item.shapediff --git a/skills/ppt-master/scripts/tests/test_source_to_md_content_loss_pptx.py b/skills/ppt-master/scripts/tests/test_source_to_md_content_loss_pptx.pyindex 48daebad..fca83c06 100644--- a/skills/ppt-master/scripts/tests/test_source_to_md_content_loss_pptx.py+++ b/skills/ppt-master/scripts/tests/test_source_to_md_content_loss_pptx.py@@ -213,3 +213,41 @@ class PptxContentLossTests(unittest.TestCase):md = self._convert(prs)self.assertIn(r'ratio $\frac{a}{b}$ holds', md)self.assertIn('$$x^2$$', md)++ def _wrap_in_alternate_content(self, element, requires: str, choice_child) -> None:+ mc = 'http://schemas.openxmlformats.org/markup-compatibility/2006'+ wrapper = etree.Element(f'{{{mc}}}AlternateContent', nsmap={'mc': mc})+ choice = etree.SubElement(wrapper, f'{{{mc}}}Choice', Requires=requires)+ choice.append(choice_child)+ fallback = etree.SubElement(wrapper, f'{{{mc}}}Fallback')+ element.getparent().replace(element, wrapper)+ fallback.append(element)++ def test_unreadable_alternate_content_keeps_its_fallback_picture(self) -> None:+ from PIL import Image++ prs, shape = self._presentation()+ shape.text = 'caption'+ with tempfile.TemporaryDirectory() as tmp:+ image = Path(tmp) / 'model.png'+ Image.new('RGB', (40, 40), 'red').save(image)+ picture = prs.slides[0].shapes.add_picture(str(image), Inches(1), Inches(3))+ frame = etree.Element('{http://schemas.openxmlformats.org/presentationml/2006/main}graphicFrame')+ self._wrap_in_alternate_content(picture._element, 'am3d', frame)+ md = self._convert(prs)+ self.assertIn('caption', md)+ self.assertRegex(md, r'!\[[^\]]*\]\([^)]+\.png\)')++ def test_chartex_fallback_text_is_not_read_as_slide_text(self) -> None:+ prs, shape = self._presentation()+ shape.text = "This chart isn't available in your version of PowerPoint"+ frame = etree.fromstring(+ '<p:graphicFrame xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" '+ 'xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">'+ '<a:graphic><a:graphicData uri="http://schemas.microsoft.com/office/drawing/2014/chartex"/>'+ '</a:graphic></p:graphicFrame>'+ )+ self._wrap_in_alternate_content(shape._element, 'cx1', frame)+ md = self._convert(prs)+ self.assertNotIn("isn't available", md)+ self.assertIn('ChartEx', md)