caddy/middleware/markdown/metadata/metadata_none.go
2016-04-16 14:45:32 -07:00

50 lines
1.1 KiB
Go

package metadata
import (
"bytes"
)
// TOMLMetadataParser is the MetadataParser for TOML
type NoneMetadataParser struct {
metadata Metadata
markdown *bytes.Buffer
}
func (n *NoneMetadataParser) Type() string {
return "None"
}
// Parse metadata/markdown file
func (n *NoneMetadataParser) Init(b *bytes.Buffer) bool {
m := make(map[string]interface{})
n.metadata = NewMetadata()
n.metadata.load(m)
n.markdown = bytes.NewBuffer(b.Bytes())
return true
}
// Parse the metadata
func (n *NoneMetadataParser) Parse(b []byte) ([]byte, error) {
return nil, nil
}
// Metadata returns parsed metadata. It should be called
// only after a call to Parse returns without error.
func (n *NoneMetadataParser) Metadata() Metadata {
return n.metadata
}
func (n *NoneMetadataParser) Markdown() []byte {
return n.markdown.Bytes()
}
// Opening returns the opening identifier TOML metadata
func (n *NoneMetadataParser) Opening() []byte {
return []byte("...")
}
// Closing returns the closing identifier TOML metadata
func (n *NoneMetadataParser) Closing() []byte {
return []byte("...")
}