mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-10-22 19:36:28 +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
|
||||
# IO output, adjacent such outputs are treated as a whole
|
||||
| {:stdout, binary()}
|
||||
# Standalone text block
|
||||
# Standalone text block otherwise matching :stdout
|
||||
| {:text, binary()}
|
||||
# Plain text content
|
||||
| {:plain_text, binary()}
|
||||
# Markdown content
|
||||
| {:markdown, binary()}
|
||||
# A raw image in the given format
|
||||
|
|
|
@ -251,7 +251,7 @@ defmodule LivebookWeb.AppLive do
|
|||
end
|
||||
|
||||
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}
|
||||
|
||||
defp filter_output({idx, {:tabs, outputs, metadata}}) do
|
||||
|
|
|
@ -47,6 +47,14 @@ defmodule LivebookWeb.Output do
|
|||
"""
|
||||
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
|
||||
live_component(Output.MarkdownComponent,
|
||||
id: id,
|
||||
|
|
Loading…
Add table
Reference in a new issue