MyNixOS website logo
Description

Parses frontmatter as used in Jekyll markdown files.

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.

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.

Metadata

Version

0.1.0.2

License

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows