EasyHTML (easyhtml v0.3.2)

EasyHTML makes working with HTML easy.

It is a tiny wrapper around Floki that adds conveniences:

  • An Inspect implementation to pretty-print them
  • An Access implementation to search them
  • An Enumerable implementation to traverse them
  • A String.Chars implementation to convert them to text

Examples

iex> doc = EasyHTML.parse!("<p>Hello, <em>world</em>!</p>")
~HTML[<p>Hello, <em>world</em>!</p>]
iex> doc["em"]
~HTML[<em>world</em>]
iex> to_string(doc)
"Hello, world!"

iex> import EasyHTML, only: :sigils
iex> doc = ~HTML[<ul><li>foo</li><li>bar</li></ul>]
iex> Enum.to_list(doc["li"])
[~HTML[<li>foo</li>], ~HTML[<li>bar</li>]]

Summary

Functions

Parses a string into an EasyHTML struct.

Handles the ~HTML sigil to create an EasyHTML struct.

Extracts text from the EasyHTML struct.

Functions

Parses a string into an EasyHTML struct.

Examples

iex> EasyHTML.parse!("<p>Hello, <em>World</em>!</p>")
~HTML[<p>Hello, <em>World</em>!</p>]
Link to this macro

sigil_HTML(string, modifiers)

(macro)

Handles the ~HTML sigil to create an EasyHTML struct.

Examples

~HTML[<p>Hello, <em>World</em>!</p>]
Link to this function

to_string(struct)

Extracts text from the EasyHTML struct.

Examples

iex> EasyHTML.to_string(~HTML[<p>Hello, <em>World</em>!</p>])
"Hello, World!"