markdownz (markdownz v1.0.1)

View Source

Extensible Markdown parser with z_html_parse compatible output.

Summary

Types

config/0

-type config() ::
          #{options := map(),
            rulers := #{phase() := markdownz_ruler:ruler()},
            renderers := #{binary() => fun((html_element(), config()) -> iodata())}}.

html_element/0

-type html_element() :: binary() | {'=', binary()} | {binary(), [{binary(), term()}], [html_element()]}.

parse_error/0

-type parse_error() :: {error, term(), term()} | {incomplete, binary(), term()}.

phase/0

-type phase() :: block | inline | core.

Functions

add_rule(Config, Phase, Where, Anchor, _)

-spec add_rule(config(), phase(), before | 'after', atom(), {atom(), markdownz_ruler:handler()}) ->
                  config().

disable(Config, Phase, Names)

-spec disable(config(), phase(), atom() | [atom()]) -> config().

enable(Config, Phase, Names)

-spec enable(config(), phase(), atom() | [atom()]) -> config().

new()

-spec new() -> config().

new(Options)

-spec new(default | commonmark | gfm | zotonic | map()) -> config().

parse(Markdown)

-spec parse(iodata()) -> {ok, [html_element()]} | parse_error().

parse(Markdown, Config0)

-spec parse(iodata(), config() | map()) -> {ok, [html_element()]} | parse_error().

parse_bounded(Markdown)

-spec parse_bounded(iodata()) -> {ok, [html_element()]} | parse_error().

Parse in a monitored process with timeout and heap-size bounds. These bounds limit resource use; they do not sanitize raw HTML output.

parse_bounded(Markdown, Config0)

-spec parse_bounded(iodata(), config() | map()) -> {ok, [html_element()]} | parse_error().

replace_rule(Config, Phase, Name, Handler)

-spec replace_rule(config(), phase(), atom(), markdownz_ruler:handler()) -> config().

set_renderer(Config, Tag, Fun)

-spec set_renderer(config(), binary(), fun((html_element(), config()) -> iodata())) -> config().

to_binary(Markdown)

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

to_binary(Markdown, Config)

-spec to_binary(iodata(), config() | map()) -> binary().

to_binary_bounded(Markdown)

-spec to_binary_bounded(iodata()) -> {ok, binary()} | parse_error().

Parse, render, and flatten in a resource-bounded monitored process.

to_binary_bounded(Markdown, Config0)

-spec to_binary_bounded(iodata(), config() | map()) -> {ok, binary()} | parse_error().

to_html(Markdown)

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

to_html(Markdown, Config0)

-spec to_html(iodata(), config() | map()) -> iodata().

to_html_bounded(Markdown)

-spec to_html_bounded(iodata()) -> {ok, iodata()} | parse_error().

Parse and render in a resource-bounded monitored process.

to_html_bounded(Markdown, Config0)

-spec to_html_bounded(iodata(), config() | map()) -> {ok, iodata()} | parse_error().

use(Config, Plugin)

-spec use(config(), module()) -> config().

use(Config, Plugin, Options)

-spec use(config(), module(), map()) -> config().