Commit 453d3eb5 authored by Matthew Holt's avatar Matthew Holt

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

parent 53b7b131
......@@ -207,11 +207,7 @@ func extractMetadata(parser MetadataParser, b []byte) (metadata []byte, markdown
// Read remaining lines until closing identifier is found
for {
line, err := reader.ReadBytes('\n')
if err != nil {
if err == io.EOF {
// no closing metadata identifier found
return nil, nil, fmt.Errorf("metadata not closed ('%s' not found)", parser.Closing())
}
if err != nil && err != io.EOF {
return nil, nil, err
}
......@@ -220,6 +216,11 @@ func extractMetadata(parser MetadataParser, b []byte) (metadata []byte, markdown
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.WriteString("\r\n")
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment