From cffb29c9195e6e80e51105e56d7a67d43a36230a Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sun, 18 Dec 2022 10:48:57 -0800 Subject: [PATCH] d2: Add trailing newline to svg output The convention. Also makes log messages clearer when input/output is - as without the newline, you get this occasionally: success: successfully compiled - to - --- main.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.go b/main.go index f37c40c0a..ce2af7899 100644 --- a/main.go +++ b/main.go @@ -243,6 +243,10 @@ func compile(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, pad, if err != nil { return svg, false, err } + } else { + if len(out) > 0 && out[len(out)-1] != '\n' { + out = append(out, '\n') + } } err = ms.WritePath(outputPath, out)