metadata

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2018 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSONParser

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

JSONParser is the MetadataParser for JSON

func (*JSONParser) Body

func (j *JSONParser) Body() []byte

Body returns the body text. It should be called only after a call to Parse returns without error.

func (*JSONParser) Metadata

func (j *JSONParser) Metadata() Metadata

Metadata returns parsed metadata. It should be called only after a call to Parse returns without error.

func (*JSONParser) Parse

func (j *JSONParser) Parse(by []byte) bool

Parse processes the document and prepares the metadata and body

func (*JSONParser) Type

func (j *JSONParser) Type() string

Type returns the kind of metadata parser implemented by this struct.

type Metadata

type Metadata struct {
	// Page title
	Title string

	// Page template name
	Template string

	// Variables to be used with Template
	Variables map[string]interface{}
}

Metadata stores a page's metadata

func NewMetadata

func NewMetadata(parsedMap map[string]interface{}) Metadata

NewMetadata returns a new Metadata struct, loaded with the given map

type NoneParser

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

NoneParser is the parser for plaintext with no metadata.

func (*NoneParser) Body

func (n *NoneParser) Body() []byte

Body returns parsed body. It should be called only after a call to Parse returns without error.

func (*NoneParser) Metadata

func (n *NoneParser) Metadata() Metadata

Metadata returns parsed metadata. It should be called only after a call to Parse returns without error.

func (*NoneParser) Parse

func (n *NoneParser) Parse(b []byte) bool

Parse prepases and parses the metadata and body

func (*NoneParser) Type

func (n *NoneParser) Type() string

Type returns the kind of parser this struct is.

type Parser

type Parser interface {
	// Initialize a parser
	Parse(b []byte) bool

	// Type of metadata
	Type() string

	// Parsed metadata.
	Metadata() Metadata

	// Raw body
	Body() []byte
}

Parser is a an interface that must be satisfied by each parser

func GetParser

func GetParser(by []byte) Parser

GetParser returns a parser for the given data

type TOMLParser

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

TOMLParser is the Parser for TOML

func (*TOMLParser) Body

func (t *TOMLParser) Body() []byte

Body returns parser the body. It should be called only after a call to Parse returns without error.

func (*TOMLParser) Metadata

func (t *TOMLParser) Metadata() Metadata

Metadata returns parsed metadata. It should be called only after a call to Parse returns without error.

func (*TOMLParser) Parse

func (t *TOMLParser) Parse(by []byte) bool

Parse prepares and parses the metadata and body

func (*TOMLParser) Type

func (t *TOMLParser) Type() string

Type returns the kind of parser this struct is.

type YAMLParser

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

YAMLParser is the Parser for YAML

func (*YAMLParser) Body

func (y *YAMLParser) Body() []byte

Body renders the text as a byte array

func (*YAMLParser) Metadata

func (y *YAMLParser) Metadata() Metadata

Metadata returns parsed metadata. It should be called only after a call to Parse returns without error.

func (*YAMLParser) Parse

func (y *YAMLParser) Parse(by []byte) bool

Parse prepares the metadata parser for parsing.

func (*YAMLParser) Type

func (y *YAMLParser) Type() string

Type returns the kind of metadata parser.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL