You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Christian Kruse 8c673ae24e
Merge pull request #6 from myfreeweb/master
2 years ago
config initial commit 5 years ago
lib Fix implied_photo_deep trying to use a string as an element 2 years ago
test fix: also check for an empty list on Floki.attribute(child, "alt") call 2 years ago
.formatter.exs mix format 3 years ago
.gitignore the great refactoring[tm] 2 years ago
LICENSE relicensing to MIT license 3 years ago Allow parsing pre-parsed HTML trees 2 years ago
mix.exs version push 2 years ago
mix.lock mix deps.update --all 2 years ago


A Microformats2 parser for Elixir.


This parser is available in Hex:

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

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


Give the parser an HTML string:

Microformats2.parse("""<div class="h-card">
  <img class="u-photo" alt="photo of Mitchell"
  <a class="p-name u-url"
     href="">Mitchell Baker</a>
  (<a class="u-url" href="">@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.
  <span class="p-category">Strategy</span>
  <span class="p-category">Leadership</span>

It will parse the object to a structure like that:

%{rels: [],
  rel_urls: [],
  items: [%{type: ["h-card"],
            properties: %{photo: [""],
                          name: ["Mitchell Baker"],
                          url: ["",
                          org: ["Mozilla Foundation"],
                          note: ["Mitchell is responsible for setting the direction and scope of the Mozilla Foundation and its activities."],
                          category: ["Strategy",

You can also provide HTML trees already parsed with Floki:

Microformats2.parse(Floki.parse("""<div class="h-card">...</div>"""))


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



Not implemented:


This software is licensed under the MIT license.