solve some back end bugs

This commit is contained in:
Henrique Dias committed 2017-06-29 10:17:35 +01:00
1 parent 193adea6bb
commit 2819ab24b8
10 files changed
+207 -282

No files matched your search

+1 -1
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 {
+9 -10
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