Changeset 3 in code


Ignore:
Timestamp:
Dec 5, 2014, 5:09:10 PM (11 years ago)
Author:
zaitsev.serge
Message:

fixed empty header in markdown

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/zs.go

    r1 r3  
    3333func md(s string) (map[string]string, string) {
    3434        v := map[string]string{}
    35         // FIXME: if no header?
     35        if strings.Index(s, "\n\n") == -1 {
     36                return map[string]string{}, s
     37        }
    3638        header, body := split2(s, "\n\n")
    3739        for _, line := range strings.Split(header, "\n") {
  • trunk/zs_test.go

    r2 r3  
    4747                t.Error(body)
    4848        }
     49
     50        // Test empty md
     51        v, body = md("")
     52        if len(v) != 0 || len(body) != 0 {
     53                t.Error(v, body)
     54        }
     55
     56        // Test empty header
     57        v, body = md("Hello")
     58        if len(v) != 0 || body != "Hello" {
     59                t.Error(v, body)
     60        }
    4961}
    5062
Note: See TracChangeset for help on using the changeset viewer.