From bbf7ee41bc361ac9bc3fec242847f9ccad86a0a8 Mon Sep 17 00:00:00 2001 From: facundoolano Date: Fri, 9 Feb 2024 16:55:36 -0300 Subject: [PATCH] fix line breaks --- main.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 939de16..5343b26 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "bufio" + "bytes" "errors" "flag" "fmt" @@ -144,16 +145,18 @@ func extractFrontMatter(file *os.File) ([]byte, map[string]interface{}, error) { closed = true break } - yamlContent = append(yamlContent, []byte("\n"+line)...) + yamlContent = append(yamlContent, []byte(line+"\n")...) } if !closed { return nil, nil, errors.New("front matter not closed") } } else { // non front matter/yaml content goes to the output slice - outContent = append(outContent, []byte(line)...) + outContent = append(outContent, []byte(line+"\n")...) } } + // drop the extraneous last line break + outContent = bytes.TrimRight(outContent, "\n") var frontMatter map[string]interface{} if len(yamlContent) != 0 {