Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ test-cov:

# Run static type checker.
typecheck:
pyright src/marimo_md_export
pyright

# Build the documentation using Zensical.
docs:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "uv_build"

[project]
name = "marimo-md-export"
version = "0.5.1"
version = "0.5.2"
description = "A minimal solution for exporting marimo notebooks to markdown *with* rendered HTML outputs, designed for mkdocs/zensical sites."
authors = [
{ name = "Joe Marsh Rossney", email = "[email protected]" }
Expand Down
2 changes: 1 addition & 1 deletion src/marimo_md_export/parse_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def _format_error(output: dict) -> str:
return f"<pre>{escape(combined)}</pre>"


_MARIMO_TYPE_RE = re.compile(r"^text/plain\+(\w+):(.*)$", re.DOTALL)
_MARIMO_TYPE_RE = re.compile(r"^text/plain(?:\+(\w+))?:(.*)$", re.DOTALL)


def _strip_marimo_type_prefixes(obj: object) -> object:
Expand Down
18 changes: 10 additions & 8 deletions tests/test_export.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import os
import subprocess
import sys
from pathlib import Path
from unittest.mock import patch

import pytest
Expand All @@ -26,7 +28,7 @@ def test_export_html_error_raises():
return_value=_failed_result("something went wrong"),
):
with pytest.raises(RuntimeError, match="marimo export html failed:"):
export_html("notebook.py")
export_html(Path("notebook.py"))


def test_export_md_error_raises():
Expand All @@ -35,7 +37,7 @@ def test_export_md_error_raises():
return_value=_failed_result("md fail"),
):
with pytest.raises(RuntimeError, match="marimo export md failed:"):
export_md("notebook.py")
export_md(Path("notebook.py"))


def test_export_html_timeout_raises():
Expand All @@ -44,7 +46,7 @@ def test_export_html_timeout_raises():
side_effect=subprocess.TimeoutExpired(cmd="marimo", timeout=10),
):
with pytest.raises(RuntimeError, match="timed out"):
export_html("notebook.py", timeout=10)
export_html(Path("notebook.py"), timeout=10)


def test_export_md_timeout_raises():
Expand All @@ -53,21 +55,21 @@ def test_export_md_timeout_raises():
side_effect=subprocess.TimeoutExpired(cmd="marimo", timeout=10),
):
with pytest.raises(RuntimeError, match="timed out"):
export_md("notebook.py", timeout=10)
export_md(Path("notebook.py"), timeout=10)


class TestRunWithVisibleOutput:
env = {**os.environ, "PYTHONDONTWRITEBYTECODE": "1"}

def test_success(self):
result = _run_with_visible_output(
[os.sys.executable, "-c", "pass"], env=self.env, timeout=10
[sys.executable, "-c", "pass"], env=self.env, timeout=10
)
assert result.returncode == 0

def test_stderr_captured(self):
result = _run_with_visible_output(
[os.sys.executable, "-c", "import sys; print('err', file=sys.stderr)"],
[sys.executable, "-c", "import sys; print('err', file=sys.stderr)"],
env=self.env,
timeout=10,
)
Expand All @@ -76,7 +78,7 @@ def test_stderr_captured(self):

def test_nonzero_exit_code(self):
result = _run_with_visible_output(
[os.sys.executable, "-c", "import sys; sys.exit(42)"],
[sys.executable, "-c", "import sys; sys.exit(42)"],
env=self.env,
timeout=10,
)
Expand All @@ -85,7 +87,7 @@ def test_nonzero_exit_code(self):
def test_timeout(self):
with pytest.raises(subprocess.TimeoutExpired):
_run_with_visible_output(
[os.sys.executable, "-c", "import time; time.sleep(60)"],
[sys.executable, "-c", "import time; time.sleep(60)"],
env=self.env,
timeout=1,
)
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading