markdownz_emphasis (markdownz v1.0.1)
View SourceCommonMark 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
-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()}.
-type plan() :: #{actions := #{non_neg_integer() => action()}, pairs := #{non_neg_integer() => non_neg_integer()}}.