markdownz_emphasis (markdownz v1.0.1)

View Source

CommonMark emphasis delimiter scanning, balancing, and tree building.

Delimiters are first collected as immutable data. A balancing pass then pairs openers and closers, including CommonMark's rule of three. Finally, the pair plan is folded into z_html_parse compatible nodes. This keeps the grammar decisions separate from rendering and avoids special-case regular expressions for particular combinations of * and _.

Summary

Types

action/0

-type action() :: blank | {open, binary()} | {close, binary()}.

delimiter/0

-type delimiter() ::
          #{marker := $* | $_,
            length := pos_integer(),
            position := non_neg_integer(),
            run := non_neg_integer(),
            can_open := boolean(),
            can_close := boolean(),
            pair := none | non_neg_integer()}.

plan/0

-type plan() ::
          #{actions := #{non_neg_integer() => action()},
            pairs := #{non_neg_integer() => non_neg_integer()}}.

Functions

plan(Source, State)

-spec plan(binary(), map()) -> plan().

resolve(Source, State)

-spec resolve(binary(), map()) -> nomatch | {ok, [markdownz:html_element()], binary(), map()}.