Livebook (Anoma v0.25.0)

I generate out extra information for Livebook

My main purpose is to generate out the TOC for each livebook document we have.

to do this please run toc_toplevel/0

To set a certain order please set sort_order/0 to have the updated order

API

Summary

Functions

I replace the header with the given TOC

I provide an example of what a TOC looks like

Generates out a TOC, given a series of nested documents

I get out all live view docs

Gets all livemd documents in a sorted list given a path.

I generate out the TOC for all liveview docs

Types

@type sort() :: [{String.t(), sort()}]

Functions

Link to this function

add_heading_num(documents)

@spec add_heading_num([String.t()]) :: [
  {String.t(), non_neg_integer(), non_neg_integer()}
]
Link to this function

change_header(markdown, header_level, start_header, new_text)

I replace the header with the given TOC

Example

markdown_text = "## Intro ...

Index

text here ## Conclusion All good"

Livebook.change_header(markdown_text, "##", "Index", "New Content") |> IO.puts

 ## Intro ...
 ## Index
 New Content
 ## Conclusion
 All good
:ok
Link to this function

count_depth(path)

@spec count_depth(Path.t()) :: non_neg_integer()
Link to this function

dir_from_path(dir)

@spec dir_from_path(String.t()) :: [String.t()]
@spec example_toc() :: :ok

I provide an example of what a TOC looks like

Link to this function

generate_heading(path, depth, numbering, from_depth \\ 1)

@spec generate_heading(
  String.t(),
  non_neg_integer(),
  non_neg_integer(),
  non_neg_integer()
) :: String.t()
Link to this function

generate_TOC(documents, from_depth \\ 0)

@spec generate_TOC([Path.t()], non_neg_integer()) :: String.t()

Generates out a TOC, given a series of nested documents

We take a path, and a place where we should be calculating the TOC from.

Example

Link to this function

get_all_livemd_documents()

@spec get_all_livemd_documents() :: [Path.t()]

I get out all live view docs

Link to this function

get_livemd_documents(dir)

@spec get_livemd_documents(Path.t()) :: [Path.t()]

Gets all livemd documents in a sorted list given a path.

Link to this function

inject_TOC(toc, path)

@spec inject_TOC(String.t(), Path.t()) :: :ok
@spec sort_order() :: sort()

I generate out the TOC for all liveview docs