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

Space at end of line will not result in yaml multiline string #1

Open
gambrose opened this issue Jul 10, 2018 · 3 comments
Open

Space at end of line will not result in yaml multiline string #1

gambrose opened this issue Jul 10, 2018 · 3 comments

Comments

@gambrose
Copy link

If we modify the example on the home page

echo '{"test":"test string with\nmultiple lines"}' | gojsontoyaml
test: |-
  test string with
  multiple lines

To include a space char after test string with then the output is not a multiline yaml string as expected.

echo '{"test":"test string with \nmultiple lines"}' | gojsontoyaml
test: "test string with \nmultiple lines"
@brancz
Copy link
Owner

brancz commented Jul 10, 2018

I think this is in line with the yaml spec, how would the multi-line string express the trailing whitespace?

@gambrose
Copy link
Author

I'm not too familiar with the intricacies of the yaml spec.

I was expecting

test: |-
  test string with 
  multiple lines

I.e. the same as example but with a space at the end of line that says test string with.

I think this is still valid yaml.
According to https://stackoverflow.com/questions/3790454/in-yaml-how-do-i-break-a-string-over-multiple-lines trailing spaces are kept when using |-.

@gambrose
Copy link
Author

I found this issue when rendering out a k8s ConfigMap.
I had the contents of a config file render as a large ugly json string and it took me a while to workout why this was happening.
It's not that I want to keep the trailing whitespace it's more that having it results in difficult to diagnose issue as to why it was not using multiline output.

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

No branches or pull requests

2 participants