Skip to content

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(scripts): source_to_md names an extension-less -o as <name>.md and honours --no-images for web pages

hugohe3494304d9e3f9
diff --git a/skills/ppt-master/scripts/docs/conversion.md b/skills/ppt-master/scripts/docs/conversion.md
index c6f41466..8d6aac3d 100644
--- a/skills/ppt-master/scripts/docs/conversion.md
+++ b/skills/ppt-master/scripts/docs/conversion.md
@@ -58,14 +58,15 @@ Useful options:
output path is known. With multiple inputs, each successful conversion prints
its own JSON line after that source finishes.
- At the unified `source_to_md.py` entry, `--images all|filtered|none`,
- `--no-images`, and `--filter-images` map to the PDF image mode. The web
- backend exposes its own direct `--no-images` option described below.
+ `--no-images`, and `--filter-images` map to the PDF image mode.
+ `--no-images` (or `--images none`) also applies to web pages: images stay
+ remote links instead of downloading into `<stem>_files/`.
- Unknown backend-specific flags are passed through to each selected converter.
- `-o/--output` selects one Markdown file for one input, or an output directory
for multiple inputs / directory inputs.
A path that names an existing directory, or ends in `/`, is always treated as
a directory, even for a single input: the file keeps its default `<stem>.md`
- name inside it.
+ name inside it. An extension-less `-o` for one input gains `.md`.
For multi-source project intake, use `project_manager.py import-sources` with
all source paths / URLs. For local files, the default is to keep generated
diff --git a/skills/ppt-master/scripts/source_to_md.py b/skills/ppt-master/scripts/source_to_md.py
index c6e945ce..89a04ef8 100644
--- a/skills/ppt-master/scripts/source_to_md.py
+++ b/skills/ppt-master/scripts/source_to_md.py
@@ -100,6 +100,11 @@ def _dispatch_output_arg(
)
)
if output_arg:
+ # One input with an extension-less -o names the Markdown file, not a
+ # directory: `-o sources_cf` writes `sources_cf.md` (a directory is
+ # spelled with a trailing separator or already exists).
+ if not Path(output_arg).suffix:
+ return f"{output_arg}.md"
return output_arg
if batch_mode and conversion_type != "web":
return str(default_markdown_path(input_arg))
@@ -255,6 +260,10 @@ def dispatch_single(
output = Path(output_arg) if output_arg else None
emit_result: Path | None = None
extra_args = list(unknown_args)
+ if _skips_images(args) and "--no-images" not in extra_args:
+ # web_to_md keeps remote image links instead of downloading the
+ # page's images into `<stem>_files/`.
+ extra_args.append("--no-images")
if output is None:
emit_file = tempfile.NamedTemporaryFile(
prefix="ppt-master-web-result-",
@@ -406,11 +415,26 @@ def _conversion_type_for_input(input_arg: str, requested_type: str) -> str:
return requested_type
+def _skips_images(args: argparse.Namespace) -> bool:
+ return bool(args.no_images or args.images == "none")
+
+
def _validate_pdf_image_flags(args: argparse.Namespace, conversion_types: list[str]) -> bool:
if not _has_pdf_image_flags(args):
return True
- if any(conversion_type != "pdf" for conversion_type in conversion_types):
- print("[ERROR] Image extraction flags are currently supported only for PDFs", file=sys.stderr)
+ web_only_skip = _skips_images(args) and not (
+ args.filter_images or args.render_vector_figures
+ )
+ for conversion_type in conversion_types:
+ if conversion_type == "pdf":
+ continue
+ if conversion_type == "web" and web_only_skip:
+ continue
+ print(
+ "[ERROR] Image extraction flags are supported only for PDFs; "
+ "--no-images (or --images none) also applies to web pages",
+ file=sys.stderr,
+ )
return False
return True
diff --git a/skills/ppt-master/scripts/tests/test_source_to_md_cli.py b/skills/ppt-master/scripts/tests/test_source_to_md_cli.py
new file mode 100644
index 00000000..35b99038
--- /dev/null
+++ b/skills/ppt-master/scripts/tests/test_source_to_md_cli.py
@@ -0,0 +1,86 @@
+#!/usr/bin/env python3
+"""Unit tests for source_to_md.py output naming and image-flag routing."""
+
+from __future__ import annotations
+
+import argparse
+import sys
+import tempfile
+import unittest
+from pathlib import Path
+
+
+SCRIPTS_DIR = Path(__file__).resolve().parents[1]
+if str(SCRIPTS_DIR) not in sys.path:
+ sys.path.insert(0, str(SCRIPTS_DIR))
+
+import source_to_md # noqa: E402
+
+
+def _args(**overrides: object) -> argparse.Namespace:
+ values = dict(
+ images=None,
+ no_images=False,
+ filter_images=False,
+ render_vector_figures=False,
+ )
+ values.update(overrides)
+ return argparse.Namespace(**values)
+
+
+class OutputNamingTests(unittest.TestCase):
+ def test_single_input_extensionless_output_gets_md_suffix(self) -> None:
+ self.assertEqual(
+ source_to_md._dispatch_output_arg(
+ "https://example.com/post", "web", "sources_cf", False, set(),
+ ),
+ "sources_cf.md",
+ )
+ self.assertEqual(
+ source_to_md._dispatch_output_arg(
+ "report.docx", "doc", "notes.markdown", False, set(),
+ ),
+ "notes.markdown",
+ )
+
+ def test_existing_directory_still_keeps_default_name_inside_it(self) -> None:
+ with tempfile.TemporaryDirectory() as tmp:
+ result = source_to_md._dispatch_output_arg(
+ "report.docx", "doc", tmp, False, set(),
+ )
+ self.assertEqual(Path(result), Path(tmp) / "report.md")
+
+
+class ImageFlagRoutingTests(unittest.TestCase):
+ def test_no_images_is_accepted_for_web_and_pdf(self) -> None:
+ self.assertTrue(
+ source_to_md._validate_pdf_image_flags(
+ _args(no_images=True), ["web", "pdf"],
+ )
+ )
+ self.assertTrue(
+ source_to_md._validate_pdf_image_flags(
+ _args(images="none"), ["web"],
+ )
+ )
+
+ def test_other_image_flags_stay_pdf_only(self) -> None:
+ self.assertFalse(
+ source_to_md._validate_pdf_image_flags(
+ _args(filter_images=True), ["web"],
+ )
+ )
+ self.assertFalse(
+ source_to_md._validate_pdf_image_flags(
+ _args(no_images=True), ["doc"],
+ )
+ )
+
+ def test_skips_images_reads_both_spellings(self) -> None:
+ self.assertTrue(source_to_md._skips_images(_args(no_images=True)))
+ self.assertTrue(source_to_md._skips_images(_args(images="none")))
+ self.assertFalse(source_to_md._skips_images(_args(images="all")))
+
+
+if __name__ == "__main__":
+ unittest.main()