sebastiandedeyne / yaml_front_matter

Parse a file or string containing front matter and a document body

Home Page:https://hex.pm/packages/yaml_front_matter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

YamlFrontMatter

Hex.pm Hex.pm Travis

Parse a file or string containing front matter and a document body.

Front matter is a block of yaml wrapped between two lines containing ---. In this example, the front matter contains title: Hello, and the body is Hello, world:

---
title: Hello
---
Hello, world

After parsing the document, front matter is returned as a map, and the body as a string.

YamlFrontMatter.parse_file "hello_world.md"
{:ok, %{"title" => "Hello"}, "Hello, world"}    

Installation

Add yaml_front_matter to your list of dependencies in mix.exs:

def deps do
  [{:yaml_front_matter, "~> 1.0.0"}]
end

Ensure yaml_front_matter is started before your application:

def application do
  [applications: [:yaml_front_matter]]
end

Usage

See https://hexdocs.pm/yaml_front_matter/

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ mix test

Contributing

Pull requests are welcome!

Credits

License

The MIT License (MIT). Please check the LICENSE for more information.

About

Parse a file or string containing front matter and a document body

https://hex.pm/packages/yaml_front_matter

License:MIT License


Languages

Language:Elixir 100.0%