Do not export setup cell output (#2184)

This commit is contained in:
Jonatan Kłosko 2023-08-25 14:36:42 +02:00 committed by GitHub
parent 070d6a5c0f
commit 867f091557
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 1 deletions

View file

@ -62,7 +62,7 @@ defmodule Livebook.LiveMarkdown.Export do
end)
name = ["# ", notebook.name]
setup_cell = render_setup_cell(setup_cell, ctx)
setup_cell = render_setup_cell(setup_cell, %{ctx | include_outputs?: false})
sections = Enum.map(notebook.sections, &render_section(&1, notebook, ctx))
metadata = notebook_metadata(notebook)

View file

@ -642,6 +642,35 @@ defmodule Livebook.LiveMarkdown.ExportTest do
assert expected_document == document
end
test "does not include setup cell output" do
notebook = %{Notebook.new() | name: "My Notebook"}
notebook =
update_in(notebook.setup_section.cells, fn [setup_cell] ->
[
%{
setup_cell
| source: """
IO.puts("hey")\
""",
outputs: [{0, terminal_text("hey", true)}]
}
]
end)
expected_document = """
# My Notebook
```elixir
IO.puts("hey")
```
"""
{document, []} = Export.notebook_to_livemd(notebook, include_outputs: true)
assert expected_document == document
end
test "removes ANSI escape codes from the output text" do
notebook = %{
Notebook.new()