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(source_to_md): emit image_manifest.json across all converter paths
hugohe31744274deefc
diff --git a/skills/ppt-master/scripts/source_to_md/doc_to_md.py b/skills/ppt-master/scripts/source_to_md/doc_to_md.pyindex a36b14af..211ec839 100644--- a/skills/ppt-master/scripts/source_to_md/doc_to_md.py+++ b/skills/ppt-master/scripts/source_to_md/doc_to_md.py@@ -55,6 +55,10 @@ PANDOC_FORMATS = {# Formats pandoc should extract embedded media fromPANDOC_MEDIA_FORMATS = {".odt"}OFFICE_VECTOR_EXTENSIONS = {".emf", ".wmf"}+IMAGE_ASSET_SUFFIXES = {+ ".png", ".jpg", ".jpeg", ".gif", ".webp", ".bmp", ".tiff", ".tif",+ ".emf", ".wmf", ".svg",+}DOCX_NS = {"w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main",@@ -166,6 +170,59 @@ def _is_office_vector(ext: str) -> bool:return ext.lower() in OFFICE_VECTOR_EXTENSIONS+def _write_generic_image_manifest(+ media_dir: Path,+ rel_media_dir: str,+ markdown: str,+ source_kind: str,+) -> None:+ """Write lightweight image metadata for non-DOCX converter paths."""+ if not media_dir.exists():+ return++ ref_pattern = re.compile(rf"{re.escape(rel_media_dir)}/([^)\s]+)")+ refs = [Path(match.group(1)).name for match in ref_pattern.finditer(markdown)]+ occurrence_map: dict[str, list[dict[str, object]]] = {}+ for index, filename in enumerate(refs, 1):+ occurrence_map.setdefault(filename, []).append({+ "occurrence_index": index,+ "source_ref": f"{rel_media_dir}/{filename}",+ })++ manifest: list[dict[str, object]] = []+ for file_path in sorted(path for path in media_dir.iterdir() if path.is_file()):+ ext = _normalize_ext(file_path.suffix)+ if ext not in IMAGE_ASSET_SUFFIXES:+ continue+ width, height = _image_size(file_path)+ ratio = width / height if width and height else None+ asset_kind = "office_vector" if _is_office_vector(ext) else "bitmap"+ occurrences = occurrence_map.get(file_path.name, [])+ entry: dict[str, object] = {+ "index": len(manifest) + 1,+ "filename": file_path.name,+ "original_filename": file_path.name,+ "asset_kind": asset_kind,+ "svg_renderable": asset_kind != "office_vector",+ "pptx_native_supported": True,+ "source_kind": source_kind,+ "source_ext": ext,+ "pixel_width": width,+ "pixel_height": height,+ "pixel_ratio": round(ratio, 6) if ratio else None,+ "display_ratio": round(ratio, 6) if ratio else None,+ "occurrences": occurrences,+ "usage_count": len(occurrences) if occurrences else 1,+ }+ manifest.append(entry)++ if manifest:+ (media_dir / "image_manifest.json").write_text(+ json.dumps(manifest, ensure_ascii=False, indent=2) + "\n",+ encoding="utf-8",+ )++def _local_name(elem: ET.Element) -> str:"""Return an XML element local name without its namespace."""return elem.tag.rsplit("}", 1)[-1]@@ -829,6 +886,7 @@ def _convert_html(input_file: Path, out_file: Path) -> str:# Collapse 3+ blank lines to 2 for tidier outputmarkdown = re.sub(r"\n{3,}", "\n\n", markdown).strip() + "\n"out_file.write_text(markdown, encoding="utf-8")+ _write_generic_image_manifest(media_dir, rel_media_dir, markdown, "html_image")if not any(media_dir.iterdir()):media_dir.rmdir()@@ -1024,6 +1082,7 @@ def _convert_epub(input_file: Path, out_file: Path) -> str:markdown = markdownify(combined_html, heading_style="ATX", bullets="-")markdown = re.sub(r"\n{3,}", "\n\n", markdown).strip() + "\n"out_file.write_text(markdown, encoding="utf-8")+ _write_generic_image_manifest(media_dir, rel_media_dir, markdown, "epub_image")if not any(media_dir.iterdir()):media_dir.rmdir()@@ -1089,6 +1148,7 @@ def _convert_ipynb(input_file: Path, out_file: Path) -> str:markdown = out_file.read_text(encoding="utf-8") if out_file.exists() else bodymedia_dir = out_file.parent / rel_media_dir+ _write_generic_image_manifest(media_dir, rel_media_dir, markdown, "ipynb_image")_report_result(out_file, media_dir if media_dir.exists() else None)return markdown@@ -1156,6 +1216,7 @@ def _convert_with_pandoc(input_file: Path, out_file: Path, suffix: str) -> str:markdown = _html_img_to_md(markdown)out_file.write_text(markdown, encoding="utf-8")+ _write_generic_image_manifest(media_dir, rel_media_dir, markdown, "pandoc_image")_report_result(out_file, media_dir if media_dir.exists() else None)return markdowndiff --git a/skills/ppt-master/scripts/source_to_md/pdf_to_md.py b/skills/ppt-master/scripts/source_to_md/pdf_to_md.pyindex c24377c4..f3c6ef22 100644--- a/skills/ppt-master/scripts/source_to_md/pdf_to_md.py+++ b/skills/ppt-master/scripts/source_to_md/pdf_to_md.py@@ -7,6 +7,7 @@ Supports heading levels, bold, italic, and list detection.import argparseimport hashlib+import jsonimport osimport reimport sys@@ -712,6 +713,7 @@ def extract_pdf_to_markdown(img_dir = output_path.parent / rel_img_dirimg_count = 0+ image_manifest: list[dict[str, object]] = []for page_num, page in enumerate(doc, 1):if page_num > 1:@@ -951,6 +953,27 @@ def extract_pdf_to_markdown(if prev_was_list:markdown_content += "\n"markdown_content += f"\n\n"+ width = int(block.get("width", 0) or 0)+ height = int(block.get("height", 0) or 0)+ ratio = width / height if width > 0 and height > 0 else None+ image_manifest.append({+ "index": len(image_manifest) + 1,+ "filename": image_name,+ "original_filename": image_name,+ "asset_kind": "bitmap",+ "svg_renderable": True,+ "pptx_native_supported": True,+ "source_kind": "pdf_image",+ "source_ext": f".{ext}",+ "page_index": page_num,+ "occurrence_index": img_count + 1,+ "pixel_width": width or None,+ "pixel_height": height or None,+ "pixel_ratio": round(ratio, 6) if ratio else None,+ "display_ratio": round(ratio, 6) if ratio else None,+ "source_sha256": hashlib.sha256(image_data).hexdigest(),+ "bbox": list(block.get("bbox", [])),+ })img_count += 1prev_was_list = Falseprint(f" [OK] Extracted image: {image_name}")@@ -980,6 +1003,29 @@ def extract_pdf_to_markdown(if prev_was_list:markdown_content += "\n"markdown_content += f"\n\n"+ ratio = pix.width / pix.height if pix.width > 0 and pix.height > 0 else None+ image_manifest.append({+ "index": len(image_manifest) + 1,+ "filename": image_name,+ "original_filename": image_name,+ "asset_kind": "bitmap",+ "svg_renderable": True,+ "pptx_native_supported": True,+ "source_kind": "pdf_vector_figure",+ "source_ext": ".png",+ "page_index": page_num,+ "occurrence_index": img_count + 1,+ "pixel_width": pix.width,+ "pixel_height": pix.height,+ "pixel_ratio": round(ratio, 6) if ratio else None,+ "display_ratio": round(ratio, 6) if ratio else None,+ "bbox": [+ figure_rect.x0,+ figure_rect.y0,+ figure_rect.x1,+ figure_rect.y1,+ ],+ })img_count += 1prev_was_list = Falseprint(f" [OK] Rendered vector figure: {image_name}")@@ -1000,6 +1046,11 @@ def extract_pdf_to_markdown(os.makedirs(os.path.dirname(output_path) or '.', exist_ok=True)with open(output_path, 'w', encoding='utf-8') as f:f.write(markdown_content)+ if img_dir and image_manifest:+ (img_dir / "image_manifest.json").write_text(+ json.dumps(image_manifest, ensure_ascii=False, indent=2) + "\n",+ encoding="utf-8",+ )print(f"[OK] Saved Markdown to: {output_path}")return markdown_contentdiff --git a/skills/ppt-master/scripts/source_to_md/web_to_md.py b/skills/ppt-master/scripts/source_to_md/web_to_md.pyindex dba3a7f0..5cba9b25 100644--- a/skills/ppt-master/scripts/source_to_md/web_to_md.py+++ b/skills/ppt-master/scripts/source_to_md/web_to_md.py@@ -29,6 +29,7 @@ TLS fingerprint handling:import argparseimport datetimeimport io+import jsonimport osimport reimport sys@@ -219,6 +220,7 @@ def download_and_rewrite_images(os.makedirs(image_dir, exist_ok=True)downloaded = {}+ manifest_by_filename: dict[str, dict[str, object]] = {}saved = 0for idx, img in enumerate(images):@@ -243,6 +245,8 @@ def download_and_rewrite_images(img["src"] = srcabs_url = urljoin(page_url, src)+ content_type = ""+ converted_from = ""if abs_url in downloaded:saved_name = downloaded[abs_url]else:@@ -269,6 +273,7 @@ def download_and_rewrite_images(pil_image = Image.open(img_data)# Update filename to .png+ converted_from = filenamefilename = f"{stem}.png"local_path = os.path.join(image_dir, filename)@@ -313,6 +318,19 @@ def download_and_rewrite_images(f.write(resp.content)downloaded[abs_url] = filenamesaved_name = filename+ manifest_by_filename[saved_name] = {+ "index": len(manifest_by_filename) + 1,+ "filename": saved_name,+ "original_filename": converted_from or saved_name,+ "asset_kind": "bitmap",+ "svg_renderable": True,+ "pptx_native_supported": True,+ "source_kind": "web_image",+ "source_url": abs_url,+ "source_page_url": page_url,+ "content_type": content_type.split(";")[0] if content_type else "",+ "occurrences": [],+ }saved += 1except Exception as e:print(f" [WARN] Skip image {abs_url}: {e}")@@ -321,6 +339,27 @@ def download_and_rewrite_images(rel_path = os.path.join(rel_prefix, saved_name) if rel_prefix else saved_nameimg["src"] = rel_path+ manifest_item = manifest_by_filename.get(saved_name)+ if manifest_item is not None:+ occurrences = manifest_item.setdefault("occurrences", [])+ if isinstance(occurrences, list):+ occurrences.append({+ "occurrence_index": idx + 1,+ "source_url": abs_url,+ "alt_text": img.get("alt", ""),+ })+ manifest_item["usage_count"] = len(occurrences)++ if manifest_by_filename:+ manifest_path = os.path.join(image_dir, "image_manifest.json")+ with open(manifest_path, "w", encoding="utf-8") as f:+ json.dump(+ list(manifest_by_filename.values()),+ f,+ ensure_ascii=False,+ indent=2,+ )+ f.write("\n")return saved