53

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
swenzel
  • 6,025
  • 2
  • 20
  • 37
  • 1
    Possible duplicate of [Is there a way to represent a long string that doesnt have any whitespace on multiple lines in a YAML document?](http://stackoverflow.com/questions/6268391/is-there-a-way-to-represent-a-long-string-that-doesnt-have-any-whitespace-on-mul) – Helen Nov 17 '16 at 17:40

1 Answers1

64

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?

Quoted example:

"abcdefghi\
jklmnopqr\
stuvwxyz"

Single quotes may also work depending on the parsing library so YMMV.

AmanicA
  • 4,313
  • 1
  • 31
  • 49
Tek
  • 2,733
  • 5
  • 42
  • 70
  • 7
    See [this other StackOverflow answer](http://stackoverflow.com/questions/3790454/in-yaml-how-do-i-break-a-string-over-multiple-lines/21699210#21699210) for a good overview of all the different wrapping styles in YAML. – Christian Long May 09 '16 at 21:54
  • 7
    Single quotes do not work - you get a literal backslash and newline – OrangeDog Jun 28 '18 at 12:16
  • Single quotes worked on a YAML parsing library I was using at the time, may have been a bug in the library perhaps. Sorry about that guys – Tek Oct 10 '18 at 17:46
  • I tested with an online tool and worked differently than kustomize (the tool I'm using). Always test with your actual services! – Martín Coll Sep 25 '20 at 19:07