defmodule Microdata do @moduledoc """ `Microdata` is an Elixir library for parsing [microdata](https://www.w3.org/TR/microdata) from a provided document. ### Dependencies #### Meeseeks + Rust Microdata parses HTML with [Meeseeks](https://github.com/mischov/meeseeks), which depends on [html5ever](https://github.com/servo/html5ever) via [meeseeks_html5ever](https://github.com/mischov/meeseeks_html5ever). Because html5ever is a Rust library, you will need to have the Rust compiler [installed](https://www.rust-lang.org/en-US/install.html). This dependency is necessary because there are no HTML5 spec compliant parsers written in Elixir/Erlang. #### HTTPoison If you are using the provided `Microdata.parse(url: ...)` helper function, your library / application will need to declare a dep on HTTPoison (see below). ### Installation - Ensure your build machine has the Rust compiler installed (see above) - Add `microdata` to your `mix.exs` deps - If you plan to use the `Microdata.parse(url: ...)` helper function, include a line for `{:httpoison, "~> 1.0"}` ```elixir def deps do [ {:microdata, "~> 0.1.0"}, {:httpoison, "~> 1.0"} # optional ] end ``` - Run `mix deps.get` ### Usage Available [on HexDocs](https://hexdocs.pm/microdata). TL;DR: - `Microdata.parse(html_text)`, if you've already fetched / read your HTML - `Microdata.parse(file: "path_to_file.html")`, if you're reading from file - `Microdata.parse(url: "https://website.com/path/to/page")`, if you'd like to fetch & parse - Uses `HTTPoison ~> 1.0` under the hood; this is an optional dep so you'll want to add it to your `mix.exs` deps as well (see above) It should be noted that even though the library will find and read JSON-LD in an HTML page's `