front: github.com/gernest/front Index | Files

package front

import "github.com/gernest/front"

Package front is a frontmatter extraction library.

Index

Package Files

front.go

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 Uses

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 Uses

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

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

type HandlerFunc Uses

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

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

type Matter Uses

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

Matter is all what matters here.

func NewMatter Uses

func NewMatter() *Matter

NewMatter creates a new Matter instance

func (*Matter) Handle Uses

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

Handle registers a handler for the given frontmatter delimiter

func (*Matter) Parse Uses

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

Parse parses the input and extract the frontmatter

Package front imports 7 packages (graph) and is imported by 5 packages. Updated 2018-12-11. Refresh now. Tools for package owners.