defmodule LivebookWeb.AppSessionLive.SourceComponent do use LivebookWeb, :live_component alias Livebook.Session @impl true def update(assigns, socket) do socket = assign(socket, assigns) socket = assign_new(socket, :source, fn -> # Note: we need to load the notebook, so that we don't track # the whole notebook in assigns notebook = Session.get_notebook(socket.assigns.session.pid) Livebook.LiveMarkdown.notebook_to_livemd(notebook, include_outputs: false) end) {:ok, socket} end @impl true def render(assigns) do ~H"""

App source

This app is built from the following notebook source:

<%= Session.file_name_for_download(@session) <> ".livemd" %>
<.code_preview source_id="export-notebook-source" language="markdown" source={@source} />
""" end end