Microformats2 parser in Elixir
Elixir HTML
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
config
lib fix: typos Jan 21, 2017
test fix: tests Feb 25, 2016
.gitignore initial commit Feb 5, 2016
LICENSE Initial commit Feb 5, 2016
README.md
mix.exs deps.update --all Jan 21, 2017
mix.lock deps.update --all Jan 21, 2017

README.md

Microformats2

A Microformats2 parser for Elixir.

Installation

This parser is available in Hex:

  1. Add microformats2 to your list of dependencies in mix.exs:

    def deps do
      [{:microformats2, "~> 0.0.5"}]
    end
    

Usage

Give the parser an HTML string:

Microformats2.parse("""<div class="h-card">
  <img class="u-photo" alt="photo of Mitchell"
       src="https://webfwd.org/content/about-experts/300.mitchellbaker/mentor_mbaker.jpg"/>
  <a class="p-name u-url"
     href="http://blog.lizardwrangler.com/">Mitchell Baker</a>
  (<a class="u-url" href="https://twitter.com/MitchellBaker">@MitchellBaker</a>)
  <span class="p-org">Mozilla Foundation</span>
  <p class="p-note">
    Mitchell is responsible for setting the direction and scope of the Mozilla Foundation and its activities.
  </p>
  <span class="p-category">Strategy</span>
  <span class="p-category">Leadership</span>
</div>
""")

It will parse the object to a structure like that:

%{rels: [],
  rel_urls: [],
  items: [%{type: ["h-card"],
            properties: %{photo: ["https://webfwd.org/content/about-experts/300.mitchellbaker/mentor_mbaker.jpg"],
                          name: ["Mitchell Baker"],
                          url: ["http://blog.lizardwrangler.com/",
                                "https://twitter.com/MitchellBaker"],
                          org: ["Mozilla Foundation"],
                          note: ["Mitchell is responsible for setting the direction and scope of the Mozilla Foundation and its activities."],
                          category: ["Strategy",
                                     "Leadership"]}}]}

Dependencies

We need Floki for HTML parsing and HTTPotion for parsing URLs.

Features

Implemented:

Not implemented:

License

This software is licensed under the AGPL3.