Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leading space in string renders a strange output in a literal style #2183

Open
vit-zikmund opened this issue Oct 29, 2024 · 0 comments
Open
Labels

Comments

@vit-zikmund
Copy link
Contributor

vit-zikmund commented Oct 29, 2024

Describe the bug
I think I have found an ugly sibling of #566, where a leading space in a string to be rendered in the literal style produces a little awkward output, that doesn't seem to be a valid YAML. Although yq itself (and yj, both based on the go-yaml/yaml module) can read it back 😏, other parsers like the Online Yaml Parser are not that cool with it.

Version of yq: 4.44.3
Operating system: linux_amd64
Installed via: binary release

Input Yaml
input.yaml:

value: "  with leading spaces"

Command

yq '.value style = "literal"' input.yaml

Actual behavior

value:2-
    with leading spaces

Expected behavior

value: |2-
    with leading spaces

Additional context
Simply, the space and the pipe character ( |) prefix seems to be missing in this case.
I fear this would be yet another transitive case for https://github.com/go-yaml/yaml/issues 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants
@vit-zikmund and others