70

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,745
  • 3
  • 23
  • 37
  • 2
    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 for "_the specifications_ [...] _they're actually quite difficult to understand._" still holding true almost 10 years later. Every time I look at it I feel like diving deep down into a doctoral thesis that broke out of the university ivory tower accidentally with a bloodcurdling howl in a moonless, dark night. If RFCs were written like that we'd still use fax only. – Gerold Broser Feb 21 '23 at 22:29

1 Answers1

78

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,659
  • 1
  • 34
  • 49
Tek
  • 2,888
  • 5
  • 45
  • 73
  • 8
    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
  • 8
    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