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(pptx): add notes master for speaker notes
hugohe3d4e6000e62b9
diff --git a/skills/ppt-master/scripts/svg_to_pptx/pptx_builder.py b/skills/ppt-master/scripts/svg_to_pptx/pptx_builder.pyindex 95d9e609..dc09857b 100644--- a/skills/ppt-master/scripts/svg_to_pptx/pptx_builder.py+++ b/skills/ppt-master/scripts/svg_to_pptx/pptx_builder.py@@ -35,7 +35,10 @@ from .pptx_media import ()from .pptx_notes import (markdown_to_plain_text,- create_notes_slide_xml, create_notes_slide_rels_xml,+ create_notes_master_rels_xml,+ create_notes_master_xml,+ create_notes_slide_xml,+ create_notes_slide_rels_xml,)from .pptx_narration import (AUDIO_CONTENT_TYPES,@@ -91,6 +94,24 @@ def _append_relationship(return next_rid+def _find_relationship_id(+ rels_path: Path,+ rel_type: str,+ target: str,+) -> str | None:+ """Find an existing relationship id by type and target."""+ if not rels_path.exists():+ return None+ rels_content = rels_path.read_text(encoding='utf-8')+ pattern = (+ r'<Relationship\b[^>]*\bId="([^"]+)"[^>]*'+ rf'\bType="{re.escape(rel_type)}"[^>]*'+ rf'\bTarget="{re.escape(target)}"[^>]*/>'+ )+ match = re.search(pattern, rels_content)+ return match.group(1) if match else None++def _add_default_content_type(content_types: str, extension: str, content_type: str) -> str:"""Add a Default content type if it is not already present."""ext = extension.lstrip(".")@@ -210,6 +231,61 @@ def _relax_output_permissions(output_path: Path) -> list[str]:return warnings+_NOTES_MASTER_REL_TYPE = (+ 'http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster'+)+++def _ensure_notes_master(extract_dir: Path) -> None:+ """Create notesMaster parts and wire them into the presentation package."""+ ppt_dir = extract_dir / 'ppt'+ notes_masters_dir = ppt_dir / 'notesMasters'+ notes_masters_dir.mkdir(exist_ok=True)++ notes_master_path = notes_masters_dir / 'notesMaster1.xml'+ if not notes_master_path.exists():+ notes_master_path.write_text(create_notes_master_xml(), encoding='utf-8')++ notes_master_rels_dir = notes_masters_dir / '_rels'+ notes_master_rels_dir.mkdir(exist_ok=True)+ notes_master_rels_path = notes_master_rels_dir / 'notesMaster1.xml.rels'+ if not notes_master_rels_path.exists():+ notes_master_rels_path.write_text(+ create_notes_master_rels_xml(),+ encoding='utf-8',+ )++ presentation_rels_path = ppt_dir / '_rels' / 'presentation.xml.rels'+ notes_master_rid = _find_relationship_id(+ presentation_rels_path,+ _NOTES_MASTER_REL_TYPE,+ 'notesMasters/notesMaster1.xml',+ )+ if notes_master_rid is None:+ notes_master_rid = _append_relationship(+ presentation_rels_path,+ _NOTES_MASTER_REL_TYPE,+ 'notesMasters/notesMaster1.xml',+ )++ presentation_path = ppt_dir / 'presentation.xml'+ presentation_xml = presentation_path.read_text(encoding='utf-8')+ if '<p:notesMasterIdLst>' in presentation_xml:+ return+ notes_master_lst = (+ f'<p:notesMasterIdLst><p:notesMasterId r:id="{notes_master_rid}"/>'+ '</p:notesMasterIdLst>'+ )+ if '</p:sldMasterIdLst>' not in presentation_xml:+ raise RuntimeError('presentation.xml is missing p:sldMasterIdLst')+ presentation_xml = presentation_xml.replace(+ '</p:sldMasterIdLst>',+ '</p:sldMasterIdLst>' + notes_master_lst,+ 1,+ )+ presentation_path.write_text(presentation_xml, encoding='utf-8')++def _to_float(value: Any, default: float) -> float:if value is None:return default@@ -879,6 +955,8 @@ def create_pptx_with_native_svg(notes_content = notes.get(svg_stem, '') if notes else ''notes_text = markdown_to_plain_text(notes_content) if notes_content else ''if notes_text:+ _ensure_notes_master(extract_dir)+notes_slides_dir = extract_dir / 'ppt' / 'notesSlides'notes_slides_dir.mkdir(exist_ok=True)@@ -1014,8 +1092,17 @@ def create_pptx_with_native_svg(with open(content_types_path, 'w', encoding='utf-8') as f:f.write(content_types)- # Add notesSlides content types+ # Add notes master / slides content typesif enable_notes and notes_slides_created:+ notes_master_override = (+ ' <Override PartName="/ppt/notesMasters/notesMaster1.xml" '+ 'ContentType="application/vnd.openxmlformats-officedocument.presentationml.notesMaster+xml"/>'+ )+ if notes_master_override not in content_types:+ content_types = content_types.replace(+ '</Types>',+ notes_master_override + '\n</Types>',+ )for i in sorted(notes_slides_created):override = (f' <Override PartName="/ppt/notesSlides/notesSlide{i}.xml" 'diff --git a/skills/ppt-master/scripts/svg_to_pptx/pptx_notes.py b/skills/ppt-master/scripts/svg_to_pptx/pptx_notes.pyindex 5ee0611a..3ce1a9f1 100644--- a/skills/ppt-master/scripts/svg_to_pptx/pptx_notes.py+++ b/skills/ppt-master/scripts/svg_to_pptx/pptx_notes.py@@ -153,10 +153,105 @@ def create_notes_slide_rels_xml(slide_num: int) -> str:Returns:Relationship file XML string."""- # No notesMaster relationship: the base PPTX produced by python-pptx does- # not ship a notesMaster part, so referencing one here would create a- # dangling rels Target and PowerPoint reports the file as corrupt.return f'''<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">- <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" Target="../slides/slide{slide_num}.xml"/>+ <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/notesMaster" Target="../notesMasters/notesMaster1.xml"/>+ <Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/slide" Target="../slides/slide{slide_num}.xml"/>+</Relationships>'''+++def create_notes_master_xml() -> str:+ """Create a minimal PowerPoint-compatible notes master XML."""+ return '''<?xml version="1.0" encoding="UTF-8" standalone="yes"?>+<p:notesMaster xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main"+ xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"+ xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main">+ <p:cSld>+ <p:spTree>+ <p:nvGrpSpPr>+ <p:cNvPr id="1" name=""/>+ <p:cNvGrpSpPr/>+ <p:nvPr/>+ </p:nvGrpSpPr>+ <p:grpSpPr>+ <a:xfrm>+ <a:off x="0" y="0"/>+ <a:ext cx="0" cy="0"/>+ <a:chOff x="0" y="0"/>+ <a:chExt cx="0" cy="0"/>+ </a:xfrm>+ </p:grpSpPr>+ <p:sp>+ <p:nvSpPr>+ <p:cNvPr id="2" name="Header Placeholder 1"/>+ <p:cNvSpPr><a:spLocks noGrp="1"/></p:cNvSpPr>+ <p:nvPr><p:ph type="hdr" sz="quarter"/></p:nvPr>+ </p:nvSpPr>+ <p:spPr/>+ <p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr lang="en-US"/></a:p></p:txBody>+ </p:sp>+ <p:sp>+ <p:nvSpPr>+ <p:cNvPr id="3" name="Date Placeholder 2"/>+ <p:cNvSpPr><a:spLocks noGrp="1"/></p:cNvSpPr>+ <p:nvPr><p:ph type="dt" sz="half" idx="1"/></p:nvPr>+ </p:nvSpPr>+ <p:spPr/>+ <p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr lang="en-US"/></a:p></p:txBody>+ </p:sp>+ <p:sp>+ <p:nvSpPr>+ <p:cNvPr id="4" name="Slide Image Placeholder 3"/>+ <p:cNvSpPr><a:spLocks noGrp="1" noRot="1" noChangeAspect="1"/></p:cNvSpPr>+ <p:nvPr><p:ph type="sldImg" idx="2"/></p:nvPr>+ </p:nvSpPr>+ <p:spPr/>+ </p:sp>+ <p:sp>+ <p:nvSpPr>+ <p:cNvPr id="5" name="Notes Placeholder 4"/>+ <p:cNvSpPr><a:spLocks noGrp="1"/></p:cNvSpPr>+ <p:nvPr><p:ph type="body" sz="quarter" idx="3"/></p:nvPr>+ </p:nvSpPr>+ <p:spPr/>+ <p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr lang="en-US"/></a:p></p:txBody>+ </p:sp>+ <p:sp>+ <p:nvSpPr>+ <p:cNvPr id="6" name="Footer Placeholder 5"/>+ <p:cNvSpPr><a:spLocks noGrp="1"/></p:cNvSpPr>+ <p:nvPr><p:ph type="ftr" sz="quarter" idx="4"/></p:nvPr>+ </p:nvSpPr>+ <p:spPr/>+ <p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr lang="en-US"/></a:p></p:txBody>+ </p:sp>+ <p:sp>+ <p:nvSpPr>+ <p:cNvPr id="7" name="Slide Number Placeholder 6"/>+ <p:cNvSpPr><a:spLocks noGrp="1"/></p:cNvSpPr>+ <p:nvPr><p:ph type="sldNum" sz="quarter" idx="5"/></p:nvPr>+ </p:nvSpPr>+ <p:spPr/>+ <p:txBody><a:bodyPr/><a:lstStyle/><a:p><a:endParaRPr lang="en-US"/></a:p></p:txBody>+ </p:sp>+ </p:spTree>+ </p:cSld>+ <p:clrMap bg1="lt1" tx1="dk1" bg2="lt2" tx2="dk2"+ accent1="accent1" accent2="accent2" accent3="accent3"+ accent4="accent4" accent5="accent5" accent6="accent6"+ hlink="hlink" folHlink="folHlink"/>+ <p:hf/>+ <p:notesStyle>+ <a:lvl1pPr marL="0" algn="l">+ <a:defRPr sz="1200" lang="en-US"/>+ </a:lvl1pPr>+ </p:notesStyle>+</p:notesMaster>'''+++def create_notes_master_rels_xml() -> str:+ """Create notes master relationships XML."""+ return '''<?xml version="1.0" encoding="UTF-8" standalone="yes"?>+<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">+ <Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme" Target="../theme/theme1.xml"/></Relationships>'''