markdown: Fix when md file has front matter but empty body

This commit is contained in:
Matthew Holt 2015-07-25 15:47:33 -06:00
parent 53b7b131cb
commit 453d3eb567

View File

@ -207,11 +207,7 @@ func extractMetadata(parser MetadataParser, b []byte) (metadata []byte, markdown
// Read remaining lines until closing identifier is found // Read remaining lines until closing identifier is found
for { for {
line, err := reader.ReadBytes('\n') line, err := reader.ReadBytes('\n')
if err != nil { if err != nil && err != io.EOF {
if err == io.EOF {
// no closing metadata identifier found
return nil, nil, fmt.Errorf("metadata not closed ('%s' not found)", parser.Closing())
}
return nil, nil, err return nil, nil, err
} }
@ -220,6 +216,11 @@ func extractMetadata(parser MetadataParser, b []byte) (metadata []byte, markdown
break break
} }
// if file ended, by this point no closing identifier was found
if err == io.EOF {
return nil, nil, fmt.Errorf("metadata not closed ('%s' not found)", parser.Closing())
}
metaBuf.Write(line) metaBuf.Write(line)
metaBuf.WriteString("\r\n") metaBuf.WriteString("\r\n")
} }