Reputation: 7173
I tried to understand the specifications here but they're actually quite difficult to understand.
http://www.yaml.org/spec/1.2/spec.html#id2779048
As far as I can see, there are three ways of wrapping text but their function is very similar... in fact so similar that I don't get the point in having all of them instead of one or two.
Well my problem is that I have some String that is really long (~700 characters) but has no whitespaces. Now of course I want to put it into multiple lines but there seems to be no way to do so without having any linefeeds or space characters that I do not want.
So is this actually possible?
---
aTest:
hereComes
SomeText
ThatShould
NotHave
AnyWhitespaces
Upvotes: 80
Views: 42807
Reputation: 3050
It's possible. See. Is there a way to represent a long string that doesnt have any whitespace on multiple lines in a YAML document?
Double-quoted example:
"abcdefghi\
jklmnopqr\
stuvwxyz"
Single quotes may also work depending on the parsing library so YMMV.
Upvotes: 92
Reputation: 356
If your yaml is ansible, you can use jinja2 to join the pieces together.
long_list:
- foo
- bar
- baz
long_string: "{{ long_list | join('') }}"
Yields "foobarbaz"
Upvotes: 1