google / google/yamlfmt

yamlfmt is unstable with folded block scalars starting with the [ character

Open
#264 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
Go
Stars
1.8k
Forks
75
PR merge metrics
No merged PRs in 30d

Description

This is incredibly bizarre. If you have a folded block scalar (denoted with `>`) and the first character is a `[`, yamlfmt becomes unstable and adds an additional newline each time the tool is run

Given the initial input of

```yaml
key: >
[
This is not YAML
]
```

Running `yamlfmt` on this once yields

```yaml
key: >
[

This is not YAML
]
```

Running it again yields

```yaml
key: >
[

This is not YAML
]
```

and so on.

This doesn't happen if it's an unfolded scalar (i.e., if the first line of my example is `key: |`) and it doesn't happen for any other first lines in the string (at least, not any I tried).

I can't imagine why the parser would care at all what the contents of a string literal are, but it sure seems to.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.