microformats2-parser: A Microformats 2 parser.

[ library, program, public-domain, web ] [ Propose Tags ]

[Skip to Readme]
Versions [RSS] [faq] 0.1.0, 0.1.1, 1.0.0, 1.0.1,,,,,,,,,,
Dependencies aeson, aeson-pretty, aeson-qq, base (>= && <5), blaze-html, blaze-markup, bytestring, containers, data-default, either, html-conduit, lens-aeson, microformats2-parser, network, network-uri, options, pcre-heavy, safe, scotty, streaming-commons, stringable, text, time, transformers, unordered-containers, vector, wai-extra, warp, xml-lens, xss-sanitize [details]
License LicenseRef-PublicDomain
Copyright 2015 Greg V <greg@unrelenting.technology>
Author Greg V
Maintainer greg@unrelenting.technology
Category Web
Home page https://github.com/myfreeweb/microformats2-parser
Source repo head: git clone git://github.com/myfreeweb/microformats2-parser.git
Uploaded by myfreeweb at 2015-08-25T18:54:13Z
Distributions NixOS:
Executables microformats2-parser
Downloads 7583 total (55 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Hackage Matrix CI
Docs available [build log]
Last success reported on 2015-08-25 [all 1 reports]




Maintainer's Corner

For package maintainers and hackage trustees


Readme for microformats2-parser-

[back to package description]

microformats2-parser Hackage Build Status unlicense

Microformats 2 parser for Haskell! #IndieWeb

Originally created for sweetroll.

  • parses items, rels, rel-urls
  • resolves relative URLs (with support for the <base> tag)
  • handles malformed HTML (the actual HTML parser is tagstream-conduit)
  • high performance
  • extensively tested

Also check out http-link-header because you often need to read links from the Link header!



Look at the API docs on Hackage for more info, here's a quick overview:

{-# LANGUAGE OverloadedStrings #-}

import Data.Microformats2.Parser
import Data.Default
import Network.URI

parseMf2 def $ documentRoot $ parseLBS "<body><p class=h-entry><h1 class=p-name>Yay!</h1></p></body>"

parseMf2 (def { baseUri = parseURI "https://where.i.got/that/page/from/" }) $ documentRoot $ parseLBS "<body><base href=\"base/\"><link rel=micropub href='micropub'><p class=h-entry><h1 class=p-name>Yay!</h1></p></body>"

The def is the default configuration.

The configuration includes:

  • htmlMode, an HTML parsing mode (Unsafe | Escape | Sanitize)
  • baseUri, the Maybe URI that represents the address you retrieved the HTML from, used for resolving relative addresses -- you should set it

parseMf2 will return an Aeson Value structured like canonical microformats2 JSON. lens-aeson is a good way to navigate it.


Use stack to build.
Use ghci to run tests quickly with :test (see the .ghci file).

$ stack build

$ stack test && rm tests.tix

$ stack ghci --ghc-options="-fno-hpc"


Please feel free to submit pull requests! Bugfixes and simple non-breaking improvements will be accepted without any questions :-)

By participating in this project you agree to follow the Contributor Code of Conduct.

The list of contributors is available on GitHub.


This is free and unencumbered software released into the public domain.
For more information, please refer to the UNLICENSE file or unlicense.org.