caddy: github.com/mholt/caddy/caddyhttp/markdown/metadata Index | Files

package metadata

import "github.com/mholt/caddy/caddyhttp/markdown/metadata"

Index

Package Files

metadata.go metadata_json.go metadata_none.go metadata_toml.go metadata_yaml.go

type JSONParser Uses

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

JSONParser is the MetadataParser for JSON

func (*JSONParser) Init Uses

func (j *JSONParser) Init(b *bytes.Buffer) bool

Init prepares the metadata metadata/markdown file and parses it

func (*JSONParser) Markdown Uses

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

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

func (*JSONParser) Metadata Uses

func (j *JSONParser) Metadata() Metadata

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

func (*JSONParser) Type Uses

func (j *JSONParser) Type() string

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

type Metadata Uses

type Metadata struct {
    // Page title
    Title string

    // Page template
    Template string

    // Publish date
    Date time.Time

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

Metadata stores a page's metadata

func NewMetadata Uses

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

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

type NoneParser Uses

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

NoneParser is the parser for plaintext markdown with no metadata.

func (*NoneParser) Init Uses

func (n *NoneParser) Init(b *bytes.Buffer) bool

Init preparses and parses the metadata and markdown file

func (*NoneParser) Markdown Uses

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

Markdown returns parsed markdown. It should be called only after a call to Parse returns without error.

func (*NoneParser) Metadata Uses

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 Uses

func (n *NoneParser) Parse(b []byte) ([]byte, error)

Parse the metadata

func (*NoneParser) Type Uses

func (n *NoneParser) Type() string

Type returns the kind of parser this struct is.

type Parser Uses

type Parser interface {
    // Initialize a parser
    Init(b *bytes.Buffer) bool

    // Type of metadata
    Type() string

    // Parsed metadata.
    Metadata() Metadata

    // Raw markdown.
    Markdown() []byte
}

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

func GetParser Uses

func GetParser(buf []byte) Parser

GetParser returns a parser for the given data

type TOMLParser Uses

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

TOMLParser is the Parser for TOML

func (*TOMLParser) Init Uses

func (t *TOMLParser) Init(b *bytes.Buffer) bool

Init prepares and parses the metadata and markdown file itself

func (*TOMLParser) Markdown Uses

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

Markdown returns parser markdown. It should be called only after a call to Parse returns without error.

func (*TOMLParser) Metadata Uses

func (t *TOMLParser) Metadata() Metadata

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

func (*TOMLParser) Type Uses

func (t *TOMLParser) Type() string

Type returns the kind of parser this struct is.

type YAMLParser Uses

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

YAMLParser is the Parser for YAML

func (*YAMLParser) Init Uses

func (y *YAMLParser) Init(b *bytes.Buffer) bool

Init prepares the metadata parser for parsing.

func (*YAMLParser) Markdown Uses

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

Markdown renders the text as a byte array

func (*YAMLParser) Metadata Uses

func (y *YAMLParser) Metadata() Metadata

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

func (*YAMLParser) Type Uses

func (y *YAMLParser) Type() string

Type returns the kind of metadata parser.

Package metadata imports 6 packages (graph) and is imported by 107 packages. Updated 2019-02-05. Refresh now. Tools for package owners.