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): raw Markdown and plain-text URLs are saved verbatim instead of going through the HTML extractor

hugohe3eba4ac77b7d0
diff --git a/skills/ppt-master/scripts/docs/conversion.md b/skills/ppt-master/scripts/docs/conversion.md
index 8d6aac3d..c1613c9c 100644
--- a/skills/ppt-master/scripts/docs/conversion.md
+++ b/skills/ppt-master/scripts/docs/conversion.md
@@ -60,7 +60,11 @@ Useful options:
- At the unified `source_to_md.py` entry, `--images all|filtered|none`,
`--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/`.
+ remote links instead of downloading into `<stem>_files/`; on Markdown/text
+ passthrough it is a no-op.
+- A URL ending in `.md`, `.markdown`, or `.txt` whose body is not HTML (a raw
+ `CHANGELOG.md` on raw.githubusercontent.com) is saved verbatim under a
+ `Source:` comment header, named after the URL's filename stem.
- 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.
diff --git a/skills/ppt-master/scripts/source_to_md.py b/skills/ppt-master/scripts/source_to_md.py
index 89a04ef8..491594fa 100644
--- a/skills/ppt-master/scripts/source_to_md.py
+++ b/skills/ppt-master/scripts/source_to_md.py
@@ -385,7 +385,10 @@ converter, so existing converter behavior remains the source of truth.
parser.add_argument(
"--no-images",
action="store_true",
- help="Alias for --images none on PDF inputs",
+ help=(
+ "Skip images: PDF image mode none; web pages keep remote image "
+ "links instead of downloading; no-op for Markdown/text"
+ ),
)
parser.add_argument(
"--filter-images",
@@ -422,17 +425,20 @@ def _skips_images(args: argparse.Namespace) -> bool:
def _validate_pdf_image_flags(args: argparse.Namespace, conversion_types: list[str]) -> bool:
if not _has_pdf_image_flags(args):
return True
- web_only_skip = _skips_images(args) and not (
+ skip_only = _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:
+ # Web pages keep remote links; Markdown/text passthrough has no
+ # images to skip, so the flag is accepted as a no-op there.
+ if conversion_type in {"web", "markdown", "text"} and skip_only:
continue
print(
"[ERROR] Image extraction flags are supported only for PDFs; "
- "--no-images (or --images none) also applies to web pages",
+ "--no-images (or --images none) also applies to web pages and "
+ "Markdown/text passthrough",
file=sys.stderr,
)
return False
diff --git a/skills/ppt-master/scripts/source_to_md/web_to_md.py b/skills/ppt-master/scripts/source_to_md/web_to_md.py
index 7ecb814b..9df5636f 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
@@ -828,6 +828,56 @@ def simple_html_to_markdown_traversal(soup: Tag | BeautifulSoup | None) -> str:
return md or ""
+PLAIN_TEXT_SUFFIXES = (".md", ".markdown", ".txt")
+
+
+def is_plain_text_document(url: str, body: str) -> bool:
+ """Return whether a fetched URL is raw Markdown / plain text, not HTML.
+
+ A raw file such as ``.../CHANGELOG.md`` on raw.githubusercontent.com is
+ already Markdown; running it through the HTML extractor loses the file or
+ fails on a missing body. The URL suffix decides, guarded by the absence of
+ an HTML document tag near the top of the body.
+ """
+ path = urlparse(url).path.lower()
+ if not path.endswith(PLAIN_TEXT_SUFFIXES):
+ return False
+ head = body[:4096].lower()
+ return "<html" not in head and "<body" not in head and "<!doctype html" not in head
+
+
+def _save_plain_text_document(
+ url: str, body: str, output_file: str | None,
+) -> tuple[bool, str, str | None, str | None]:
+ stem = os.path.splitext(os.path.basename(urlparse(url).path))[0]
+ output_path = output_file or os.path.join(
+ CONFIG["output_dir"], f"{derive_base_name(stem, url)}.md",
+ )
+ output_dirname = os.path.dirname(output_path) or "."
+ os.makedirs(output_dirname, exist_ok=True)
+ header = (
+ "<!--\n"
+ f" Source: {url}\n"
+ f" Crawled: {datetime.datetime.now().isoformat()}\n"
+ " Format: raw Markdown / plain text saved verbatim\n"
+ "-->\n\n"
+ )
+ with open(output_path, "w", encoding="utf-8") as f:
+ f.write(header + body)
+ profile_path = write_conversion_profile_best_effort(
+ input_path=url,
+ markdown_path=output_path,
+ converter="web_to_md.py",
+ conversion_type="web",
+ asset_dir=None,
+ )
+ print(f" [OK] Raw Markdown / plain text: {len(body)} chars saved verbatim")
+ print(f" [OK] Saved: {output_path}")
+ if profile_path:
+ print(f" [OK] Conversion profile: {profile_path}")
+ return True, url, None, output_path
+
+
def process_url(
url: str,
output_file: str | None = None,
@@ -843,6 +893,8 @@ def process_url(
print(f"\n[Fetching] {url}")
try:
html = fetch_url(url)
+ if is_plain_text_document(url, html):
+ return _save_plain_text_document(url, html, output_file)
soup = BeautifulSoup(html, 'html.parser')
# Extract Metadata
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
index 35b99038..fc42738b 100644
--- a/skills/ppt-master/scripts/tests/test_source_to_md_cli.py
+++ b/skills/ppt-master/scripts/tests/test_source_to_md_cli.py
@@ -16,6 +16,11 @@ if str(SCRIPTS_DIR) not in sys.path:
import source_to_md # noqa: E402
+WEB_BACKEND_DIR = SCRIPTS_DIR / "source_to_md"
+if str(WEB_BACKEND_DIR) not in sys.path:
+ sys.path.insert(0, str(WEB_BACKEND_DIR))
+from web_to_md import is_plain_text_document # noqa: E402
+
def _args(**overrides: object) -> argparse.Namespace:
values = dict(
@@ -76,6 +81,30 @@ class ImageFlagRoutingTests(unittest.TestCase):
)
)
+ def test_no_images_is_a_no_op_for_markdown_and_text(self) -> None:
+ self.assertTrue(
+ source_to_md._validate_pdf_image_flags(
+ _args(no_images=True), ["markdown", "text", "web"],
+ )
+ )
+
+
+class RawTextUrlTests(unittest.TestCase):
+ def test_markdown_url_with_markdown_body_is_plain_text(self) -> None:
+ self.assertTrue(is_plain_text_document(
+ "https://raw.githubusercontent.com/astral-sh/uv/main/CHANGELOG.md",
+ "# Changelog\n\n## 0.12.10\n\nReleased on 2026-09-04.\n",
+ ))
+
+ def test_html_bodies_and_html_urls_still_go_through_the_extractor(self) -> None:
+ self.assertFalse(is_plain_text_document(
+ "https://example.com/notes.md",
+ "<!DOCTYPE html><html><body><p>rendered</p></body></html>",
+ ))
+ self.assertFalse(is_plain_text_document(
+ "https://docs.astral.sh/uv/", "# looks like markdown but is a page",
+ ))
+
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")))