Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yamadapc/haskell-frontmatter
Attoparsec parsers for YAML frontmatter as used in Jekyll
https://github.com/yamadapc/haskell-frontmatter
Last synced: 3 months ago
JSON representation
Attoparsec parsers for YAML frontmatter as used in Jekyll
- Host: GitHub
- URL: https://github.com/yamadapc/haskell-frontmatter
- Owner: yamadapc
- License: mit
- Created: 2015-12-19T22:50:09.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2023-12-21T23:42:28.000Z (about 1 year ago)
- Last Synced: 2024-04-26T20:21:16.926Z (9 months ago)
- Language: Haskell
- Homepage:
- Size: 12.7 KB
- Stars: 6
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.md
- License: LICENSE
Awesome Lists containing this project
README
# haskell-frontmatter
[![Build Status](https://travis-ci.org/yamadapc/haskell-frontmatter.svg?branch=master)](https://travis-ci.org/yamadapc/haskell-frontmatter)
[![Hackage Version](https://img.shields.io/hackage/v/frontmatter.svg)](http://hackage.haskell.org/package/frontmatter)
- - -
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
```
$ stack install frontmatter
```## Usage
```haskell
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 FromJSONputStrLn 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`](https://github.com/haskellbr/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](/LICENSE) file.