Skip to content
/ front Public

extracts frontmatter from text files with ease with golang.

License

Notifications You must be signed in to change notification settings

gernest/front

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

front Build Status GoDocCoverage Status

extracts frontmatter from text files with ease.

Features

  • Custom delimiters. You are free to register any delimiter of your choice. Provided its a three character string. e.g +++, $$$, ---, %%%
  • Custom Handlers. Anything that implements HandlerFunc can be used to decode the values from the frontmatter text, you can see the JSONHandler for how to implement one.
  • Support YAML frontmatter
  • Support JSON frontmatter.

Installation

go get github.com/gernest/front

How to use

package main

import (
	"fmt"
	"strings"

	"github.com/gernest/front"
)

var txt = `+++
{
    "title":"front"
}
+++

# Body
Over my dead body
`

func main() {
	m := front.NewMatter()
	m.Handle("+++", front.JSONHandler)
	f, body, err := m.Parse(strings.NewReader(txt))
	if err != nil {
		panic(err)
	}

	fmt.Printf("The front matter is:\n%#v\n", f)
	fmt.Printf("The body is:\n%q\n", body)
}

Please see the tests formore details

Licence

This project is under the MIT Licence. See the LICENCE file for the full license text.

About

extracts frontmatter from text files with ease with golang.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages