|
|
@ -83,14 +83,21 @@ func ExtractFrontMatter(contents []string) (FrontMatter, []string, error) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for i, line := range contents {
|
|
|
|
for i, line := range contents {
|
|
|
|
|
|
|
|
// Ignore first line if it matches the delimiter
|
|
|
|
if i == 0 && delimiterRegex.MatchString(line) {
|
|
|
|
if i == 0 && delimiterRegex.MatchString(line) {
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Matches on the ending delimiter.
|
|
|
|
if delimiterRegex.MatchString(line) {
|
|
|
|
if delimiterRegex.MatchString(line) {
|
|
|
|
return matter, contents[i+1:], nil
|
|
|
|
return matter, contents[i+1:], nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Now parsing FrontMatter. If the content is emptystring, skip the line
|
|
|
|
|
|
|
|
if strings.TrimSpace(line) == "" {
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
key, value, err := ParseKeyValueLine(line)
|
|
|
|
key, value, err := ParseKeyValueLine(line)
|
|
|
|
if err != nil && i == 0 {
|
|
|
|
if err != nil && i == 0 {
|
|
|
|
return matter, contents, nil
|
|
|
|
return matter, contents, nil
|
|
|
|