Back to godoc.org
github.com/gernest/front

Package front

v0.0.0-...-ed80ca3
Latest Go to latest

The latest major version is .

Published: Nov 29, 2018 | License: MIT | Module: github.com/gernest/front

Overview

Package front is a frontmatter extraction library.

Index

Variables

var (
	//ErrIsEmpty is an error indicating no front matter was found
	ErrIsEmpty = errors.New("front: an empty file")

	//ErrUnknownDelim is returned when the delimiters are not known by the
	//FrontMatter implementation.
	ErrUnknownDelim = errors.New("front: unknown delim")
)

func JSONHandler

func JSONHandler(front string) (map[string]interface{}, error)

JSONHandler implements HandlerFunc interface. It extracts front matter data from the given string argument by interpreting it as a json string.

func YAMLHandler

func YAMLHandler(front string) (map[string]interface{}, error)

YAMLHandler decodes ymal string into a go map[string]interface{}

type HandlerFunc

type HandlerFunc func(string) (map[string]interface{}, error)

HandlerFunc is an interface for a function that process front matter text.

type Matter

type Matter struct {
	// contains filtered or unexported fields
}

Matter is all what matters here.

func NewMatter

func NewMatter() *Matter

NewMatter creates a new Matter instance

func (*Matter) Handle

func (m *Matter) Handle(delim string, fn HandlerFunc)

Handle registers a handler for the given frontmatter delimiter

func (*Matter) Parse

func (m *Matter) Parse(input io.Reader) (front map[string]interface{}, body string, err error)

Parse parses the input and extract the frontmatter

Package Files

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier