1

Is it possible in Yaml to have multi-line syntax for strings without an additional character generated between newlines?

Folded (>) syntax puts spaces, literal syntax (|) puts newlines between lines. The summary here does not give a solution: In YAML, how do I break a string over multiple lines?.

E.g.

>-
  line1_
  line2

generates line1<space>line2 - I would like to have line1_line2 without additional token.

Community
  • 1
  • 1
levibo
  • 33
  • 5

1 Answers1

1

Use a double-quoted string:

"line1_\
line2"

By escaping the newline character, it is completely removed instead of being translated into a space. It is not possible to do this with block scalars because they have no escape sequences.

flyx
  • 35,506
  • 7
  • 89
  • 126
  • good idea, but I would like to have a similar functionality to block scalars (no escaping) without the additional space / newline – levibo Jan 06 '17 at 14:45
  • Well, there is none. Quoted scalars are the only way to split a scalar at arbitrary points (i.e. not at a space or newline). – flyx Jan 08 '17 at 10:13