From f53eabdbf62eee6d0d4f392d26483aa65acba039 Mon Sep 17 00:00:00 2001 From: Dmitriy Pleshevskiy Date: Mon, 12 Dec 2022 23:14:38 +0300 Subject: [PATCH] d2: preserve leading comment spacing --- ...402_preserve_leading_comment_spacing.patch | 23 +++++++++++++++++++ pkgs/d2.nix | 4 +++- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 patches/d2/402_preserve_leading_comment_spacing.patch diff --git a/patches/d2/402_preserve_leading_comment_spacing.patch b/patches/d2/402_preserve_leading_comment_spacing.patch new file mode 100644 index 0000000..3c7c696 --- /dev/null +++ b/patches/d2/402_preserve_leading_comment_spacing.patch @@ -0,0 +1,23 @@ +diff --git a/d2format/format.go b/d2format/format.go +index 754e3302..a45d55f6 100644 +--- a/d2format/format.go ++++ b/d2format/format.go +@@ -76,17 +76,17 @@ func (p *printer) node(n d2ast.Node) { + p.edgeIndex(n) + } + } + + func (p *printer) comment(c *d2ast.Comment) { + lines := strings.Split(c.Value, "\n") + for i, line := range lines { + p.sb.WriteString("#") +- if line != "" && !strings.HasPrefix(line, " ") { ++ if line != "" { + p.sb.WriteByte(' ') + } + p.sb.WriteString(line) + if i < len(lines)-1 { + p.newline() + } + } + } diff --git a/pkgs/d2.nix b/pkgs/d2.nix index 1939e7f..d6921f7 100644 --- a/pkgs/d2.nix +++ b/pkgs/d2.nix @@ -27,7 +27,9 @@ buildGoModule { nativeBuildInputs = [ installShellFiles ]; - patches = [ ]; + patches = [ + ../patches/d2/402_preserve_leading_comment_spacing.patch + ]; postInstall = "installManPage ci/release/template/man/d2.1";