mirror of
https://github.com/livebook-dev/livebook.git
synced 2025-10-13 06:55:54 +08:00
* Initial file import/export * Add renderer tests * Refactor renderer * Depend only on EarmarkParser * Add test for export * Add import tests * Improve import * Document the ExMd file format * Rename ExMd to ExMarkdown * Rename ExMarkdown to LiveMarkdown * Build iodata when exporting a notebook * Persist metadata as a single JSON object * Move Markdown to LiveMarkdown.MarkdownHelpers * Make LiveMarkdown private * Always move primary heading to the top during import * Hint the user not to use heading 1 and 2 * Return a list of messages from the import function * Update headings warning * Add import and export test for non-elixir snippets * Merge markdown renderer into MarkdownHelpers * Add import messages on AST rewrites
35 lines
752 B
Elixir
35 lines
752 B
Elixir
defmodule LiveBook.Notebook.Section do
|
|
@moduledoc false
|
|
|
|
# Data structure representing a single section in a notebook.
|
|
#
|
|
# Each section contains a number of cells and is isolated
|
|
# in the sense that cells don't interfere with cells in other sections.
|
|
|
|
defstruct [:id, :name, :cells, :metadata]
|
|
|
|
alias LiveBook.Notebook.Cell
|
|
alias LiveBook.Utils
|
|
|
|
@type id :: Utils.id()
|
|
|
|
@type t :: %__MODULE__{
|
|
id: id(),
|
|
name: String.t(),
|
|
cells: list(Cell.t()),
|
|
metadata: %{String.t() => term()}
|
|
}
|
|
|
|
@doc """
|
|
Returns a blank section.
|
|
"""
|
|
@spec new() :: t()
|
|
def new() do
|
|
%__MODULE__{
|
|
id: Utils.random_id(),
|
|
name: "Section",
|
|
cells: [],
|
|
metadata: %{}
|
|
}
|
|
end
|
|
end
|