Cmark

Compiles Markdown formatted text into HTML

Provides:

Summary

Functions

Compiles one or more (list) Markdown documents to HTML and returns result

Compiles one or more (list) Markdown documents to HTML and calls function with result

Compiles a list of Markdown documents and calls function for each item

Functions

to_html(data)

Compiles one or more (list) Markdown documents to HTML and returns result

Examples

iex> "test" |> Cmark.to_html
"<p>test</p>\n"

iex> ["# also works", "* with list", "`of documents`"] |> Cmark.to_html
["<h1>also works</h1>\n",
"<ul>\n<li>with list</li>\n</ul>\n",
"<p><code>of documents</code></p>\n"]
to_html(data, callback)

Compiles one or more (list) Markdown documents to HTML and calls function with result

Examples

iex> callback = fn (html) -> "HTML is #{html}" |> String.strip end
iex> "test" |> Cmark.to_html(callback)
"HTML is <p>test</p>"

iex> callback = fn (htmls) ->
iex>   Enum.map(htmls, &String.strip/1) |> Enum.join("<hr>")
iex> end
iex> ["list", "test"] |> Cmark.to_html(callback)
"<p>list</p><hr><p>test</p>"
to_html_each(data, callback)

Compiles a list of Markdown documents and calls function for each item

Examples

iex> callback = fn (html) -> "HTML is #{html |> String.strip}" end
iex> ["list", "test"] |> Cmark.to_html_each(callback)
["HTML is <p>list</p>", "HTML is <p>test</p>"]