d2: preserve leading comment spacing

This commit is contained in:
Dmitriy Pleshevskiy 2022-12-12 23:14:38 +03:00
parent 79301872e5
commit f53eabdbf6
Signed by: pleshevskiy
GPG Key ID: 1B59187B161C0215
2 changed files with 26 additions and 1 deletions

View File

@ -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()
}
}
}

View File

@ -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";