Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

fix: allow marimo to open the markdown file format over http (#5742)

Dylan Madisetti4039d0c1a619
diff --git a/marimo/_cli/file_path.py b/marimo/_cli/file_path.py
index 539140239f..bfb1eafb24 100644
--- a/marimo/_cli/file_path.py
+++ b/marimo/_cli/file_path.py
@@ -307,8 +307,14 @@ class RemoteFileHandler(FileHandler):
LOGGER.info("Creating temporary file")
path_to_app = Path(temp_dir.name) / name
# If doesn't end in .py, add it
- if not path_to_app.suffix == ".py":
- path_to_app = path_to_app.with_suffix(".py")
+ if path_to_app.suffix not in (".py", ".md", ".qmd"):
+ if "__generated_with" in content:
+ path_to_app = path_to_app.with_suffix(".py")
+ elif "marimo-version" in content:
+ path_to_app = path_to_app.with_suffix(".md")
+ else:
+ # Fallback to .py
+ path_to_app = path_to_app.with_suffix(".py")
path_to_app.write_text(content, encoding="utf-8")
LOGGER.info("App saved to %s", path_to_app)
return str(path_to_app)
diff --git a/tests/_cli/test_file_path.py b/tests/_cli/test_file_path.py
index 011b8ae16f..30f35d1f97 100644
--- a/tests/_cli/test_file_path.py
+++ b/tests/_cli/test_file_path.py
@@ -257,6 +257,13 @@ def test_validate_name_with_markdown_file():
)
+def test_validate_name_with_markdown_file_remote() -> None:
+ markdown_tutorial = "https://github.com/marimo-team/marimo/blob/main/marimo/_tutorials/markdown_format.md"
+ assert validate_name(
+ markdown_tutorial, allow_new_file=True, allow_directory=False
+ )[0].endswith("markdown_format.md")
+
+
def test_validate_name_with_jupyter_notebook():
with pytest.raises(click.ClickException) as excinfo:
validate_name(