mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-30 22:34:15 -05:00
027f697fdf
Nuke pre-generation. This may come back in the form of a more general caching layer at some later stage. Nuke index generation. This should likely be rethought and re-implemented.
40 lines
933 B
Go
40 lines
933 B
Go
package markdown
|
|
|
|
import (
|
|
"github.com/BurntSushi/toml"
|
|
)
|
|
|
|
// TOMLMetadataParser is the MetadataParser for TOML
|
|
type TOMLMetadataParser struct {
|
|
metadata Metadata
|
|
}
|
|
|
|
// Parse the metadata
|
|
func (t *TOMLMetadataParser) Parse(b []byte) ([]byte, error) {
|
|
b, markdown, err := extractMetadata(t, b)
|
|
if err != nil {
|
|
return markdown, err
|
|
}
|
|
m := make(map[string]interface{})
|
|
if err := toml.Unmarshal(b, &m); err != nil {
|
|
return markdown, err
|
|
}
|
|
t.metadata.load(m)
|
|
return markdown, nil
|
|
}
|
|
|
|
// Metadata returns parsed metadata. It should be called
|
|
// only after a call to Parse returns without error.
|
|
func (t *TOMLMetadataParser) Metadata() Metadata {
|
|
return t.metadata
|
|
}
|
|
|
|
// Opening returns the opening identifier TOML metadata
|
|
func (t *TOMLMetadataParser) Opening() []byte {
|
|
return []byte("+++")
|
|
}
|
|
|
|
// Closing returns the closing identifier TOML metadata
|
|
func (t *TOMLMetadataParser) Closing() []byte {
|
|
return []byte("+++")
|
|
}
|