From b701d9f0942cc7d52f4b26e433f7d98ddd64f85d Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Wed, 4 Jan 2017 18:17:47 +0000 Subject: [PATCH] solve #68 --- frontmatter/frontmatter.go | 4 ++++ frontmatter/runes.go | 2 +- handlers/editor.go | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/frontmatter/frontmatter.go b/frontmatter/frontmatter.go index d50df10e..65839abb 100644 --- a/frontmatter/frontmatter.go +++ b/frontmatter/frontmatter.go @@ -36,6 +36,10 @@ func Pretty(content []byte) (*Content, string, error) { kind := reflect.ValueOf(data).Kind() + if kind.String() == "invalid" { + return &Content{}, "", nil + } + object := new(Block) object.Type = objectType object.Name = mainName diff --git a/frontmatter/runes.go b/frontmatter/runes.go index 65d0ddde..718f17c7 100644 --- a/frontmatter/runes.go +++ b/frontmatter/runes.go @@ -17,7 +17,7 @@ func AppendRune(frontmatter []byte, language string) []byte { case "toml": return []byte("+++\n" + string(frontmatter) + "\n+++") case "json": - return frontmatter + return []byte("{\n" + string(frontmatter) + "\n}") } return frontmatter diff --git a/handlers/editor.go b/handlers/editor.go index dead8214..0d827b55 100644 --- a/handlers/editor.go +++ b/handlers/editor.go @@ -2,6 +2,7 @@ package handlers import ( "bytes" + "fmt" "path/filepath" "strings" @@ -60,6 +61,8 @@ func GetEditor(i *file.Info) (*Editor, error) { break } + fmt.Println("Hey") + fallthrough case "markdown", "asciidoc", "rst": if frontmatter.HasRune(i.Content) {