Repository: gohugoio/hugo (language: go)

Issue:
hugo convert toTOML inserts blank line before closing delimiter
content/post/test.md - BEFORE

```
---
title: Test
date: "2022-10-03T17:16:07-07:00"
draft: false
---
```

command

```bash
hugo convert toTOML --unsafe
```

content/post/test.md - AFTER

```
+++
date = '2022-10-03T17:16:07-07:00'
draft = false
title = 'Test'
                                    <-- blank line
+++
```

This does not happen when specifying `toJSON` or `toYAML`.

Hugo has behaved this way since v0.54.0 (and probably earlier), so this was _not_ introduced during the migration to v2 of github.com/pelletier/go-toml.

Reference: <https://discourse.gohugo.io/t/40792/2>





Discussion / hints:

Fix patch:
diff --git a/parser/frontmatter.go b/parser/frontmatter.go
index 150ce038fef..ced8b84fc47 100644
--- a/parser/frontmatter.go
+++ b/parser/frontmatter.go
@@ -109,7 +109,7 @@ func InterfaceToFrontMatter(in any, format metadecoders.Format, w io.Writer) err
 			return err
 		}
 
-		_, err = w.Write([]byte("\n" + tomlDelimLf))
+		_, err = w.Write([]byte(tomlDelimLf))
 		return err
 
 	default:


Test patch: