"gopkg.in/yaml.v2"
)
-type FrontmatterType struct {
+type frontmatterType struct {
markstart, markend []byte
Parse func([]byte) (interface{}, error)
includeMark bool
}
}
+// TODO(bep) move to helpers
func FormatSanitize(kind string) string {
switch strings.ToLower(kind) {
case "yaml", "yml":
}
}
-func DetectFrontMatter(mark rune) (f *FrontmatterType) {
+func detectFrontMatter(mark rune) (f *frontmatterType) {
switch mark {
case '-':
- return &FrontmatterType{[]byte(YAML_DELIM), []byte(YAML_DELIM), HandleYAMLMetaData, false}
+ return &frontmatterType{[]byte(YAML_DELIM), []byte(YAML_DELIM), HandleYAMLMetaData, false}
case '+':
- return &FrontmatterType{[]byte(TOML_DELIM), []byte(TOML_DELIM), HandleTOMLMetaData, false}
+ return &frontmatterType{[]byte(TOML_DELIM), []byte(TOML_DELIM), HandleTOMLMetaData, false}
case '{':
- return &FrontmatterType{[]byte{'{'}, []byte{'}'}, HandleJSONMetaData, true}
+ return &frontmatterType{[]byte{'{'}, []byte{'}'}, HandleJSONMetaData, true}
default:
return nil
}
frontmatter := p.FrontMatter()
if len(frontmatter) != 0 {
- fm := DetectFrontMatter(rune(frontmatter[0]))
+ fm := detectFrontMatter(rune(frontmatter[0]))
meta, err = fm.Parse(frontmatter)
if err != nil {
return