markdownz_zipper (markdownz v1.0.1)

View Source

A zipper over a z_html_parse compatible forest.

The current level is {Left, Right}. Left is stored in reverse order and Right starts with the current node. Parent frames retain the element and its siblings, so moving and replacing nodes does not rebuild unrelated branches.

Summary

Functions

Bottom-up map. Children are transformed before their parent. This is useful for rules whose parent decoration depends on rewritten descendants.

Types

frame/0

-type frame() :: {binary(), list(), [html_node()], [html_node()]}.

html_node/0

-type html_node() :: markdownz:html_element().

zipper/0

-type zipper() :: {[frame()], {[html_node()], [html_node()]}}.

Functions

current(_)

-spec current(zipper()) -> html_node().

delete(_)

-spec delete(zipper()) -> zipper().

down(_)

-spec down(zipper()) -> zipper().

from_list(Nodes)

-spec from_list([html_node()]) -> zipper().

insert(Node, _)

-spec insert(html_node(), zipper()) -> zipper().

map(Fun, Nodes)

-spec map(fun((html_node()) -> html_node()), [html_node()]) -> [html_node()].

Bottom-up map. Children are transformed before their parent. This is useful for rules whose parent decoration depends on rewritten descendants.

next(_)

-spec next(zipper()) -> zipper().

previous(_)

-spec previous(zipper()) -> zipper().

replace(Node, _)

-spec replace(html_node(), zipper()) -> zipper().

to_list(_)

-spec to_list(zipper()) -> [html_node()].

top(Zipper)

-spec top(zipper()) -> zipper().

up(_)

-spec up(zipper()) -> zipper().