mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
parser: Unexport some internals
This commit is contained in:
parent
5d915e7e96
commit
3a82ae7114
2 changed files with 7 additions and 6 deletions
|
@ -23,7 +23,7 @@ import (
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
type FrontmatterType struct {
|
type frontmatterType struct {
|
||||||
markstart, markend []byte
|
markstart, markend []byte
|
||||||
Parse func([]byte) (interface{}, error)
|
Parse func([]byte) (interface{}, error)
|
||||||
includeMark bool
|
includeMark bool
|
||||||
|
@ -135,6 +135,7 @@ func FormatToLeadRune(kind string) rune {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO(bep) move to helpers
|
||||||
func FormatSanitize(kind string) string {
|
func FormatSanitize(kind string) string {
|
||||||
switch strings.ToLower(kind) {
|
switch strings.ToLower(kind) {
|
||||||
case "yaml", "yml":
|
case "yaml", "yml":
|
||||||
|
@ -148,14 +149,14 @@ func FormatSanitize(kind string) string {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func DetectFrontMatter(mark rune) (f *FrontmatterType) {
|
func detectFrontMatter(mark rune) (f *frontmatterType) {
|
||||||
switch mark {
|
switch mark {
|
||||||
case '-':
|
case '-':
|
||||||
return &FrontmatterType{[]byte(YAML_DELIM), []byte(YAML_DELIM), HandleYAMLMetaData, false}
|
return &frontmatterType{[]byte(YAML_DELIM), []byte(YAML_DELIM), HandleYAMLMetaData, false}
|
||||||
case '+':
|
case '+':
|
||||||
return &FrontmatterType{[]byte(TOML_DELIM), []byte(TOML_DELIM), HandleTOMLMetaData, false}
|
return &frontmatterType{[]byte(TOML_DELIM), []byte(TOML_DELIM), HandleTOMLMetaData, false}
|
||||||
case '{':
|
case '{':
|
||||||
return &FrontmatterType{[]byte{'{'}, []byte{'}'}, HandleJSONMetaData, true}
|
return &frontmatterType{[]byte{'{'}, []byte{'}'}, HandleJSONMetaData, true}
|
||||||
default:
|
default:
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,7 +79,7 @@ func (p *page) Metadata() (meta interface{}, err error) {
|
||||||
frontmatter := p.FrontMatter()
|
frontmatter := p.FrontMatter()
|
||||||
|
|
||||||
if len(frontmatter) != 0 {
|
if len(frontmatter) != 0 {
|
||||||
fm := DetectFrontMatter(rune(frontmatter[0]))
|
fm := detectFrontMatter(rune(frontmatter[0]))
|
||||||
meta, err = fm.Parse(frontmatter)
|
meta, err = fm.Parse(frontmatter)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue