Skip to content

Commit

Permalink
fix: Render source even if output is empty
Browse files Browse the repository at this point in the history
Issue-57: #57
  • Loading branch information
pawamoy committed Jun 20, 2024
1 parent cc36267 commit d3f1e6b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/markdown_exec/formatters/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ def base_format(
logger.warning(log_message)
return markdown.convert(str(error))

if not output:
if not output and not source:
return Markup()

if html:
Expand Down
16 changes: 16 additions & 0 deletions tests/test_base_formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,22 @@ def test_dont_render_anything_if_output_is_empty(md: Markdown) -> None:
assert not markup


def test_render_source_even_if_output_is_empty(md: Markdown) -> None:
"""Assert source is rendered even if output is empty.
Parameters:
md: A Markdown instance (fixture).
"""
markup = base_format(
language="bash",
run=lambda code, **_: "",
code="whatever",
md=md,
source="tabbed-left",
)
assert "Source" in markup


def test_changing_working_directory(md: Markdown) -> None:
"""Assert we can change the working directory with `workdir`.
Expand Down

0 comments on commit d3f1e6b

Please sign in to comment.