mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-12-11 14:16:44 +08:00
Add support for plain text output (#1790)
This commit is contained in:
parent
f172acca47
commit
9d1767dd50
3 changed files with 12 additions and 2 deletions
|
|
@ -45,8 +45,10 @@ defprotocol Livebook.Runtime do
|
||||||
:ignored
|
:ignored
|
||||||
# IO output, adjacent such outputs are treated as a whole
|
# IO output, adjacent such outputs are treated as a whole
|
||||||
| {:stdout, binary()}
|
| {:stdout, binary()}
|
||||||
# Standalone text block
|
# Standalone text block otherwise matching :stdout
|
||||||
| {:text, binary()}
|
| {:text, binary()}
|
||||||
|
# Plain text content
|
||||||
|
| {:plain_text, binary()}
|
||||||
# Markdown content
|
# Markdown content
|
||||||
| {:markdown, binary()}
|
| {:markdown, binary()}
|
||||||
# A raw image in the given format
|
# A raw image in the given format
|
||||||
|
|
|
||||||
|
|
@ -251,7 +251,7 @@ defmodule LivebookWeb.AppLive do
|
||||||
end
|
end
|
||||||
|
|
||||||
defp filter_output({idx, output})
|
defp filter_output({idx, output})
|
||||||
when elem(output, 0) in [:markdown, :image, :js, :control],
|
when elem(output, 0) in [:plain_text, :markdown, :image, :js, :control],
|
||||||
do: {idx, output}
|
do: {idx, output}
|
||||||
|
|
||||||
defp filter_output({idx, {:tabs, outputs, metadata}}) do
|
defp filter_output({idx, {:tabs, outputs, metadata}}) do
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,14 @@ defmodule LivebookWeb.Output do
|
||||||
"""
|
"""
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp render_output({:plain_text, text}, %{id: id}) do
|
||||||
|
assigns = %{id: id, text: text}
|
||||||
|
|
||||||
|
~H"""
|
||||||
|
<div id={@id} class="text-gray-700"><%= @text %></div>
|
||||||
|
"""
|
||||||
|
end
|
||||||
|
|
||||||
defp render_output({:markdown, markdown}, %{id: id, session_id: session_id}) do
|
defp render_output({:markdown, markdown}, %{id: id, session_id: session_id}) do
|
||||||
live_component(Output.MarkdownComponent,
|
live_component(Output.MarkdownComponent,
|
||||||
id: id,
|
id: id,
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue