erlmark (erlmark v0.1.1)

View Source

Fast, pure Erlang Markdown to HTML converter.

Implements CommonMark 0.31.2 plus the GFM tables, strikethrough and task-list extensions. Extended autolinks and the tagfilter are opt-in.

  1> 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

Types

Conversion options

Functions

Convert Markdown to an HTML binary. See option() for the available options. Errors raised while converting in a helper process are re-raised in the caller.

Types

option/0

-type option() ::
          {spawn_above, non_neg_integer() | infinity} |
          {parallel, false | auto | pos_integer()} |
          {extensions, [autolink | tagfilter]}.

Conversion options:

{spawn_above, Bytes | infinity}
Inputs larger than Bytes are converted in a short-lived helper process with a pre-sized heap, which avoids most garbage collection. infinity always converts in the calling process. Default: 256.
{parallel, false | auto | N}
Split large documents at top-level block boundaries and convert the pieces on N schedulers (auto is all online ones). The output is identical to sequential conversion. Documents under 16 KB are never split. Default: false.
{extensions, [autolink | tagfilter]}
Opt-in GFM extensions. autolink turns bare www., http(s):// and ftp:// URLs and e-mail addresses into links. tagfilter escapes &lt;script&gt;, &lt;style&gt; and similar tags. Conversion with extensions is always sequential. Default: none.

refs/0

-type refs() :: #{binary() => {binary(), binary() | none}}.

Functions

to_html(Markdown)

-spec to_html(iodata()) -> binary().

Equivalent to to_html(Markdown, []).

Convert Markdown to an HTML binary, with default options.

to_html(Markdown, Opts)

-spec to_html(iodata(), [option()]) -> binary().

Convert Markdown to an HTML binary. See option() for the available options. Errors raised while converting in a helper process are re-raised in the caller.

  1> erlmark:to_html(<<"www.example.com">>, [{extensions, [autolink]}]).
  <<"<p><a href=\"http://www.example.com\">www.example.com</a></p>\n">>