PureHTML. Serializer
(PureHTML v0.5.0)
View Source
Converts parsed HTML nodes back to HTML strings.
Implements the HTML fragment serialization algorithm.
Options
:scripting— whether scripting is enabled (default:true).to_html/2is usually called on a treeparse/2built. Parse's scripting flag decides whether noscript children are a text node or elements. With the default parse (scripting on), noscript holds one text node that must be emitted literally, so the serializer default istrue. If the tree was parsed with scripting off, noscript holds elements and this flag does not affect them.
Summary
Functions
Serializes a list of parsed HTML nodes to an HTML string.
True for the HTML void elements, which serialize as a start tag only.
Functions
@spec serialize( [PureHTML.html_node()], keyword() ) :: String.t()
Serializes a list of parsed HTML nodes to an HTML string.
Examples
iex> PureHTML.Serializer.serialize([{"p", [], ["Hello"]}])
"<p>Hello</p>"
iex> PureHTML.Serializer.serialize([{"br", [], []}])
"<br>"
iex> PureHTML.Serializer.serialize([{"span", [{"title", "foo"}], []}])
"<span title=\"foo\"></span>"
True for the HTML void elements, which serialize as a start tag only.