Mercurial > yakumo_izuru > aya
changeset 2:fd79b3a90bef draft
fixed empty header in markdown
author | zaitsev.serge |
---|---|
date | Fri, 05 Dec 2014 17:09:10 +0000 |
parents | d647affd8ae9 |
children | 53dea9841cd9 |
files | zs.go zs_test.go |
diffstat | 2 files changed, 15 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/zs.go Fri Dec 05 17:05:46 2014 +0000 +++ b/zs.go Fri Dec 05 17:09:10 2014 +0000 @@ -32,7 +32,9 @@ func md(s string) (map[string]string, string) { v := map[string]string{} - // FIXME: if no header? + if strings.Index(s, "\n\n") == -1 { + return map[string]string{}, s + } header, body := split2(s, "\n\n") for _, line := range strings.Split(header, "\n") { key, value := split2(line, ":")
--- a/zs_test.go Fri Dec 05 17:05:46 2014 +0000 +++ b/zs_test.go Fri Dec 05 17:09:10 2014 +0000 @@ -46,6 +46,18 @@ if body != "this: is a content" { t.Error(body) } + + // Test empty md + v, body = md("") + if len(v) != 0 || len(body) != 0 { + t.Error(v, body) + } + + // Test empty header + v, body = md("Hello") + if len(v) != 0 || body != "Hello" { + t.Error(v, body) + } } func TestRender(t *testing.T) {