solve some back end bugs

Former-commit-id: de26609879e875b21de329588ecd1dcb44d152f3 [formerly 78b120bf0d33345808a422980db55d33c52304b7] [formerly d77c47bb41c1a7bf6ee2b2522bf7c86638d087bc [formerly 2819ab24b85a578dc1f572f1e64eccc98cabd6c3]]
Former-commit-id: 3ddee564ddd5ed4fde01ed95f30386115a07df78 [formerly a3a1da0357874b7d99a88bd785c8f60f8170f663]
Former-commit-id: 0e15a59e28993f8178fa9409a466ce93a9936906
This commit is contained in:
Henrique Dias
2017-06-29 10:17:35 +01:00
parent a7b50c2de1
commit bff33c2c1e
10 changed files with 207 additions and 282 deletions

View File

@@ -136,7 +136,7 @@ type Block struct {
Type string
HTMLType string
Content *Content
Parent *Block
Parent *Block `json:"-"`
}
func rawToPretty(config interface{}, parent *Block) *Content {

View File

@@ -1,29 +1,28 @@
package frontmatter
import (
"bytes"
"errors"
"strings"
)
// HasRune checks if the file has the frontmatter rune
func HasRune(file []byte) bool {
return strings.HasPrefix(string(file), "---") ||
strings.HasPrefix(string(file), "+++") ||
strings.HasPrefix(string(file), "{")
func HasRune(file string) bool {
return strings.HasPrefix(file, "---") ||
strings.HasPrefix(file, "+++") ||
strings.HasPrefix(file, "{")
}
// AppendRune appends the frontmatter rune to a file
func AppendRune(frontmatter []byte, mark rune) []byte {
frontmatter = bytes.TrimSpace(frontmatter)
func AppendRune(frontmatter string, mark rune) string {
frontmatter = strings.TrimSpace(frontmatter)
switch mark {
case '-':
return []byte("---\n" + string(frontmatter) + "\n---")
return "---\n" + frontmatter + "\n---"
case '+':
return []byte("+++\n" + string(frontmatter) + "\n+++")
return "+++\n" + frontmatter + "\n+++"
case '{':
return []byte("{\n" + string(frontmatter) + "\n}")
return "{\n" + frontmatter + "\n}"
}
return frontmatter