Premailex v0.3.7 Premailex.HTMLParser View Source
Module that provide HTML parsing API using an underlying HTML parser library.
Link to this section Summary
Functions
Searches an HTML tree for the selector.
Filters elements matching the selector from the HTML tree.
Parses a HTML string into an HTML tree.
Extracts text elements from the HTML tree.
Turns an HTML tree into a string.
Link to this section Types
Link to this type
html_tree() View Source
Link to this section Functions
Link to this function
all(tree, selector) View Source
Searches an HTML tree for the selector.
Examples
iex> Premailex.HTMLParser.all({"html", [], [{"head", [], []}, {"body", [], [{"h1", [], ["Title"]}]}]}, "h1")
[{"h1", [], ["Title"]}]
Link to this function
filter(tree, selector) View Source
Filters elements matching the selector from the HTML tree.
Examples
iex> Premailex.HTMLParser.filter([{"html", [], [{"head", [], []}, {"body", [], [{"h1", [], ["Title"]}]}]}], "h1")
[{"html", [], [{"head", [], []}, {"body", [], []}]}]
Link to this function
parse(html) View Source
Parses a HTML string into an HTML tree.
Examples
iex> Premailex.HTMLParser.parse("<html><head></head><body><h1>Title</h1></body></html>")
{"html", [], [{"head", [], []}, {"body", [], [{"h1", [], ["Title"]}]}]}
Link to this function
text(tree) View Source
Extracts text elements from the HTML tree.
Examples
iex> Premailex.HTMLParser.text({"html", [], [{"head", [], []}, {"body", [], [{"h1", [], ["Title"]}]}]})
"Title"
Link to this function
to_string(tree) View Source
Turns an HTML tree into a string.
Examples
iex> Premailex.HTMLParser.to_string({"html", [], [{"head", [], []}, {"body", [], [{"h1", [], ["Title"]}]}]})
"<html><head></head><body><h1>Title</h1></body></html>"