Fast Markdown to HTML conversion for Elixir.
A thin wrapper around erlmark, a pure Erlang CommonMark 0.31.2 converter with the GFM tables, strikethrough and task-list extensions. There are no NIFs or system dependencies.
iex> Erlmark.to_html("# Hello *world*")
"<h1>Hello <em>world</em></h1>\n"Raw HTML in the input is passed through unchanged, as CommonMark requires. Sanitise the output if the input is untrusted.
Summary
Functions
Converts Markdown to HTML.
Types
@type extension() :: :autolink | :tagfilter
An opt-in GFM extension.
@type option() :: {:spawn_above, non_neg_integer() | :infinity} | {:parallel, false | :auto | pos_integer()} | {:extensions, [extension()]}
A conversion option. See to_html/2.
Functions
Converts Markdown to HTML.
markdown is a string or any iodata. Options:
:extensions- a list of opt-in GFM extensions.:autolinkturns barewww.,http(s)://andftp://URLs and e-mail addresses into links.:tagfilterescapes<script>,<style>and similar tags. Conversion with extensions is always sequential. Defaults to[].:parallel-:auto(all online schedulers) or a number of schedulers to convert large documents on. The output is identical to sequential conversion. Documents under 16 KB are never split. Defaults tofalse.:spawn_above- inputs larger than this many bytes are converted in a short-lived process with a pre-sized heap, which avoids most garbage collection.:infinityalways converts in the calling process. Defaults to256.
Raises ArgumentError for an unknown option or an invalid value.
Examples
iex> Erlmark.to_html("*emphasis* and **strong**")
"<p><em>emphasis</em> and <strong>strong</strong></p>\n"
iex> Erlmark.to_html("visit www.example.com", extensions: [:autolink])
"<p>visit <a href=\"http://www.example.com\">www.example.com</a></p>\n"
iex> Erlmark.to_html("| a |\n|---|\n| 1 |")
"<table>\n<thead>\n<tr>\n<th>a</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>1</td>\n</tr>\n</tbody>\n</table>\n"