A Ruby gem to parse HTML containing one or more microformats2 and return a collection of Ruby objects.
JavaScript HTML Ruby
Latest commit 8e340a6 Aug 31, 2016 @veganstraightedge veganstraightedge committed on GitHub Merge pull request #42 from cweiske/patch-1
Fix travis configuration


Microformats2 (ruby)

Build Status Code Climate

A Ruby gem to parse HTML containing one or more microformats2 and return a collection of dynamically defined Ruby objects.

Development Status

This gem sat unmaintained for quite a long time. It's now under new management. Work will begin shortly on getting it on par with the other Microformats2 parsers and the current state of the spec. (2015-12-23)

A work in progress.


Not Implemented:

Current Version


Version 2.0.3



Add this line to your application's Gemfile:

gem "microformats2"

And then execute:


Or install it yourself as:

gem install microformats2


require "microformats2"

source = "<div class='h-card'><p class='p-name'>Jessica Lynn Suttles</p></div>"
collection = Microformats2.parse(source)
# using singular accessors
collection.card.name.to_s #=> "Jessica Lynn Suttles"
# using plural accessors
collection.cards.first.names.first.to_s #=> "Jessica Lynn Suttles"

source = "<article class='h-entry'>
  <h1 class='p-name'>Microformats 2</h1>
  <div class='h-card p-author'><p class='p-name'>Jessica Lynn Suttles</p></div>
collection = Microformats2.parse(source)
collection.entry.name.to_s #=> "Microformats 2"
# accessing nested microformats
collection.entry.author.format.name.to_s #=> "Jessica Lynn Suttles"

# getting a copy of the canonical microformats2 hash structure

# the above, as JSON in a string
  • source can be a URL, filepath, or HTML



  1. Fork it
  2. Get it running (see Installation above)
  3. Create your feature branch (git checkout -b my-new-feature)
  4. Write your code and specs
  5. Commit your changes (git commit -am 'Add some feature')
  6. Push to the branch (git push origin my-new-feature)
  7. Create new Pull Request

If you find bugs, have feature requests or questions, please file an issue.


TODO remove this and use the microformats tests repo instead.

To update spec cases that are scraped from other sites. Warning: This could break specs.

rake specs:update

To run specs

rake spec


Microformats2 (ruby) is dedicated to the public domain using Creative Commons -- CC0 1.0 Universal.