wojtekmach / easyhtml

EasyHTML makes it easy to work with HTML in Elixir.
Apache License 2.0
48 stars 4 forks source link

EasyHTML

Version CI

EasyHTML makes working with HTML easy.

It is a tiny wrapper around Floki that adds conveniences:

Usage

Mix.install([
  {:easyhtml, "~> 0.3.0"}
])

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

doc["em"]
#=> ~HTML[<em>world</em>]

to_string(doc)
#=> "Hello, world!"

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