LivebookFormatter (livebook_formatter v0.1.0)

Documentation for LivebookFormatter

Extracts MarkdownHelpers From the main Livebook Project to reduce compile times for projects that need to reformat .livemd files.

Link to this section Summary

Functions

Determines suitable Markdown fence delimiter for the given code.

Renders Markdown string from the given EarmarkParser AST.

Normalizes comments.

Reformats the given markdown document.

Link to this section Functions

Link to this function

code_block_delimiter(code)

@spec code_block_delimiter(String.t()) :: String.t()

Determines suitable Markdown fence delimiter for the given code.

Link to this function

markdown_from_ast(ast)

@spec markdown_from_ast(EarmarkParser.ast()) :: String.t()

Renders Markdown string from the given EarmarkParser AST.

Link to this function

markdown_to_block_ast(markdown)

@spec markdown_to_block_ast(String.t()) :: {:ok | :error, EarmarkParser.ast(), list()}

Wraps EarmarkParser.as_ast/2.

Markdown blocks are parsed into the AST, while inline content is kept as is.

Link to this function

normalize_comment_lines(lines)

@spec normalize_comment_lines([String.t()]) :: [String.t()]

Normalizes comments.

In single-line comments trims all the whitespace and in multi-line comments removes trailing/leading blank newlines.

Link to this function

reformat(markdown)

@spec reformat(String.t()) :: String.t()

Reformats the given markdown document.