View Source z_html_parse (zotonic_stdlib v1.20.2)
Summary
Types
Special node used by sanitizer for unwanted elements
Functions
Escape a string such that it's safe for HTML (amp; lt; gt;).
Escape a string such that it's safe for HTML attrs (amp; lt; gt; quot;).
tokenize and then transform the token stream into a HTML tree.
Parse an HTML/XML document to a JSON compatible map. Attributes will be added as keys in an @attributes key. Elements will be mapped to keys with value lists. all keys are lowercased.
Parse an HTML/XML document to a JSON compatible map. Attributes will be added as keys in an @attributes key. Elements will be mapped to keys with value lists. all keys are lowercased.
Transform the output of tokens(Doc) into a HTML tree.
Convert a list of html_token() to a HTML document.
Convert a html_node() tree to a list of tokens.
Transform the input UTF-8 HTML into a token stream.
Types
-type end_tag() :: {end_tag, Name :: binary()}.
-type html_attr() :: {html_attr_name(), html_attr_value()}.
-type html_comment() :: {comment, Comment :: binary()}.
-type html_doctype() :: {doctype, [Doctype :: any()]}.
-type html_element() :: html_node() | html_comment() | html_nop() | pi_tag() | inline_html() | {html_tag()} | {html_tag(), [html_element()]} | binary().
-type html_node() :: {html_tag(), [html_attr()], [html_element()]}.
-type html_nop() :: {nop, [html_element()]}.
-type html_token() :: html_data() | start_tag() | end_tag() | pi_tag() | inline_html() | html_comment() | html_doctype().
-type html_tree() :: html_doctype() | html_node() | html_comment() | inline_html() | {html_tag()} | {html_tag(), [html_element()]} | pi_tag().
-type inline_html() :: {'=', binary()}.
Functions
-spec parse_tokens([html_token()]) -> {ok, html_node()} | {error, nohtml}.
-spec to_html([html_token()] | html_tree()) -> iodata().
-spec to_html([html_token()] | html_tree(), options()) -> iodata().
-spec to_tokens(html_tree()) -> [html_token()].
-spec to_tokens(html_tree(), options()) -> [html_token()].
-spec tokens(iodata()) -> [html_token()].
-spec tokens(iodata(), options()) -> [html_token()].