frontmatter: Parses frontmatter as used in Jekyll markdown files.

[ data, library, mit ] [ Propose Tags ] [ Report a vulnerability ]

Parses frontmatter as used in Jekyll markdown files.

Provides a parser that'll parse the frontmatter only and one that'll execute a YAML parser on it, so that it's a YAML frontmatter parser.


[Skip to Readme]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.0.1, 0.1.0.2
Change log changelog.md
Dependencies attoparsec (>=0.11.3.0), base (>=4 && <5), bytestring, yaml [details]
Tested with ghc >=7.8
License MIT
Copyright Copyright (c) 2015 Pedro Tacla Yamada
Author Pedro Tacla Yamada
Maintainer tacla.yamada@gmail.com
Category Data
Home page https://github.com/yamadapc/haskell-frontmatter
Source repo head: git clone git://github.com/yamadapc/haskell-frontmatter.git
Uploaded by yamadapc at 2015-12-20T03:46:12Z
Distributions LTSHaskell:0.1.0.2, NixOS:0.1.0.2, Stackage:0.1.0.2
Reverse Dependencies 4 direct, 0 indirect [details]
Downloads 3538 total (38 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2015-12-20 [all 1 reports]

Readme for frontmatter-0.1.0.2

[back to package description]

haskell-frontmatter

Build Status Hackage Version


Attoparsec parsers for YAML frontmatter as used in Jekyll. Because of how Data.Yaml is implemented using Data.Aeson, the Data.Yaml.Frontmatter.frontmatterYaml instance of Parser works with YAML and JSON.

Installation

This actually won't work right now

$ stack install frontmatter

Usage

import Data.Frontmatter
import Data.Yaml (Value)

main = ByteString.readFile "something.md" >>= parseYamlFrontmatter >>= \case
    Done ri fm -> do
        print (fm :: Value) -- aeson object in the frontmatter (the explicit
                            -- type required because the parser will return
                            -- anything with a FromJSON

        putStrLn ri         -- rest of the document
    _ -> error "Parse failure"

See the haddocks for more information. Essentially exports an Attoparsec parser and some helpers. Usage examples also available at the test directory.

Why?

I'm working on the Haskell workshop tool workhs. In my mind, using markdown file names as metadata is a very sensible decision. However, I'd like for tutorial writers to be able to override metadata. Then, Jekyll's YAML frontmatter format is a great choice:

  • It's familiar
  • It's very, very easy to implement

License

This software is published under the MIT license. For more information refer to the LICENSE file.