Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jgarber623/micromicro
A Ruby gem for extracting microformats2-encoded data from HTML documents.
https://github.com/jgarber623/micromicro
html-parser microformats microformats2 ruby rubygems
Last synced: 3 months ago
JSON representation
A Ruby gem for extracting microformats2-encoded data from HTML documents.
- Host: GitHub
- URL: https://github.com/jgarber623/micromicro
- Owner: jgarber623
- License: mit
- Created: 2019-08-19T20:08:30.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2024-08-02T00:52:45.000Z (6 months ago)
- Last Synced: 2024-10-05T13:30:53.588Z (4 months ago)
- Topics: html-parser, microformats, microformats2, ruby, rubygems
- Language: Ruby
- Homepage: https://rubygems.org/gems/micromicro
- Size: 356 KB
- Stars: 3
- Watchers: 3
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# MicroMicro
**A Ruby gem for extracting [microformats2](https://microformats.org/wiki/microformats2)-encoded data from HTML documents.**
[![Gem](https://img.shields.io/gem/v/micromicro.svg?logo=rubygems&style=for-the-badge)](https://rubygems.org/gems/micromicro)
[![Downloads](https://img.shields.io/gem/dt/micromicro.svg?logo=rubygems&style=for-the-badge)](https://rubygems.org/gems/micromicro)
[![Build](https://img.shields.io/github/actions/workflow/status/jgarber623/micromicro/ci.yml?branch=main&logo=github&style=for-the-badge)](https://github.com/jgarber623/micromicro/actions/workflows/ci.yml)## Key Features
- Parses microformats2-encoded HTML documents according to the [microformats2 parsing specification](https://microformats.org/wiki/microformats2-parsing)
- Passes all microformats2 tests from [the official test suite](https://github.com/microformats/tests)¹
- Supports Ruby 3.0 and newer**Note:** MicroMicro **does not** parse [Classic Microformats](https://microformats.org/wiki/Main_Page#Classic_Microformats) (referred to in [the parsing specification](https://microformats.org/wiki/microformats2-parsing#note_backward_compatibility_details) as "backcompat root classes" and "backcompat properties" and in vocabulary specifications in the "Parser Compatibility" sections [e.g. [h-entry](https://microformats.org/wiki/h-entry#Parser_Compatibility)]). To parse documents marked up with Classic Microformats, consider using [the official microformats-ruby parser](https://github.com/microformats/microformats-ruby).
¹ …with some exceptions until [this pull request](https://github.com/microformats/tests/pull/112) is merged.
## Installation
Before installing and using MicroMicro, you'll want to have [Ruby](https://www.ruby-lang.org) 3.0 (or newer) installed. If you're using [Bundler](https://bundler.io) to manage gem dependencies, add MicroMicro to your project's Gemfile:
```ruby
gem 'micromicro'
```…and run `bundle install` in your shell.
To install the gem manually, run the following in your shell:
```sh
gem install micromicro
```## Usage
MicroMicro's `parse` method accepts two arguments: a `String` of markup and a `String` representing the URL associated with that markup. The resulting `MicroMicro::Document` may be converted to a `Hash` which may be further manipulated using conventional Ruby tooling.
```ruby
require 'micromicro'doc = MicroMicro.parse('
Jason Garber', 'https://sixtwothree.org')
#=> #]>, relationships: #>doc.to_h
#=> { :items => [{ :type => ["h-card"], :properties => { :name => ["Jason Garber"] } }], :rels => {}, :"rel-urls" => {} }
```See [USAGE.md](https://github.com/jgarber623/micromicro/blob/main/USAGE.md) for detailed examples of MicroMicro's features. Additional structured documentation is available on [RubyDoc.info](https://rubydoc.info/gems/micromicro).
## Acknowledgments
MicroMicro wouldn't exist without the hard work of everyone involved in the [microformats](https://microformats.org) community. Additionally, the comprehensive [microformats test suite](https://github.com/microformats/tests) was invaluable in the development of this Ruby gem.
MicroMicro is written and maintained by [Jason Garber](https://sixtwothree.org).
## License
MicroMicro is freely available under the [MIT License](https://opensource.org/licenses/MIT). Use it, learn from it, fork it, improve it, change it, tailor it to your needs.